|
Hello,
This is my first time doing socket programming. I tried to write a program to read binary data from a device, through the serial port and save the data received into a binary file. The device only provide data in binary format, so I do not have an option to send the data in ASCII format.
But I don't how am I going to receive binary data and what data type should I use to receive the binary data. Should I use char, int or?
As I am programming in Linux OS, so I cannot use CString to receive the data.
I tried using integer to receive the data, as the data is in binary, I get integer which is out of the ascii table.
Please help
Your help will be much appreciated.
Thank you.
|
|
|
|
|
You can use String class defined in STL library or use Charater Buffer to Get it
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi, everyone,
I don't have any experiences on COM, and now I need to write a C++ client to use some COM events. The COM dll's .idl file is as below, if anyone can tell me how to write this C++ client. thanks very much.
the event function of COM is OnStatusChange, my C++ client needs to
interface IDumpEx : IDispatch
{
HRESULT MyAction();
};
library FDUMPSVRLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
dispinterface _IExEvents
{
properties:
methods:
HRESULT OnStatusChange([in] long pct);
};
coclass DumpEx
{
[default] interface IDumpEx;
[default, source] dispinterface _IExEvents;
};
};
|
|
|
|
|
Hello littlecuttiepie,
I've created a Windows Client Application that is able to receive the OnStatusChange() event fired from your DumpEx object.
Email to me : bio_lim_2004@yahoo.com together with your return email address and I'll send the VC++ files to you.
Regards,
Bio.
|
|
|
|
|
A few succinct points about Event Handling in COM :
In COM, event handling is achieved via Connection Points. The COM object which fires events is a Connection Point Container. It recognizes several Connection Points which are actually interface methods that must be implemented by a Client Event Listener.
Hence,
COM Object That Fires Events
- implements IConnectionPointContainer.
- contains one or more IConnectionPoint implementations.
- calls event interface methods implemented by clients event listeners.
COM Client that listens to events
- implements Event Interface methods which are fired by COM Object.
- searches for a suitable connection point in event firing COM object via IConnectionPointContainer.FindConnectionPoint().
- connects with event firing object via IConnectionPoint.Advise().
- disconnects with event firing obejct via IConnectionPoint.Unadvise().
Regards,
Bio.
|
|
|
|
|
Hi Bio,
I need to write a straight C++ client, not COM. I saw books talking about using sink object for the client, but not very sure how to write it, Do you know how to do that?
Thanks.
littlecuttiepie
|
|
|
|
|
Hello littlecuttiepie,
>> I need to write a straight C++ client, not COM.
I understand your situation. I believe that what you are trying to say is that your client application is not an ATL-generated. The example code that I'll be sending to you is not ATL-generated. However, you -will- need to add some basic COM code into your client app (e.g. CoInitialize() and CoUnititalize(), and, depending on whether you used #import, you may need to either use smart pointers or use CoCreateInstance()).
>> I saw books talking about using sink object for the client, but not very sure how to write it, Do you know how to do that?
Yes, the sample code that I'm sending you contains an actual implementation of a sink object.
I'm currently writing a CodeProject article based on the sample code. Watch out for it as it will contain the documentation for my code.
Best Regards,
Bio.
|
|
|
|
|
Hello littlecuttiepie,
I have uploaded my code project article :
TEventHandler - A C++ COM Event Handler For IDispatch-Based Events
It is in the latest updates section.
Regards,
Bio.
|
|
|
|
|
All,
I was wondering if anyone could recommend JazzAge[^] or another similar product to accomplish this task. If you would recommend Jazzage, which version have you used?
Thanks,
Rich
|
|
|
|
|
i'm a beginner in com development. can somebody help me to write a com addin for ms project..... thank you........
|
|
|
|
|
Hi ,
Does anyone know if the functions in COM interface can be overloaded or not?
Thank you.
|
|
|
|
|
tpndtbk wrote:
Does anyone know if the functions in COM interface can be overloaded or not?
Nope It Not Possible,Actually Component Technology to Interlink Langauges and concept like Function overloading,Inheritance etc. cannot be found in every language.
so that why Com developer has sacrfice many thing Good Programming Concepts to Create Component.
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
If you are looking at it from the client side then instead of trying to overload the com interface simply create an interface wrapper for the COM object in your client. Your code would then sit inbetween your main client and the COM interface. For info on interface wrappers look here[^]
|
|
|
|
|
You could also take a look at aggregation and containment if you are trying to perform it from the server side. It is not necessarily that COM doesn't support good programming practice, the whole reason for the development of COM was to insulate the client from the details of implementation; thus implementation inheritance is out of the question since it requires too much detailed information over how the "insides" work. COM does support interface inheritance, which is developed through aggregation and containment. These tools allow you to specialize COM interfaces.
|
|
|
|
|
I wrote a piece of code as
hr = CoCreateInstance (&CLSID_DataAccessClient, NULL, CLSCTX_INPROC_SERVER, &IID_IDataAccessClient, &pCOM);
where pCom is of type IDataAccessClient.
The program throws a Fatal error as:
Fatal execution engine error.
Please help me out by giving some suggestions.
Biswa
Email: biswaranjan.rath@amdocs.com
Phone No: 09373311346
|
|
|
|
|
Try this instead:
hr = ::CoCreateInstance(CLSID_DataAccessClient,
NULL,
CLSCTX_INPROC_SERVER,
IID_IDataAccessClient,
(void**)&pCOM);
if(FAILED(hr))
{...}
Notice the absence of the & operator.
I Dream of Absolute Zero
|
|
|
|
|
I tried those options, but i'm using a reference so '&' is needed. again i tried this with (void**). still i got the error. Even this call doesn't return a status.
|
|
|
|
|
Ok. I'm still not quite sure why you need to pass the address of the GUIDs like you did though.
The only other possibility that I can think of is that the COM library was not initialised. Have you called ::CoInitialize(NULL) at the start of your program?
I Dream of Absolute Zero
|
|
|
|
|
I have initialized thye COM library by:
hr = CoInitialize(NULL);
after that i checked the status of hr, which is returning success.
then the program fails in CoCreateInstance()
|
|
|
|
|
biswaranjan_rath wrote:
hr = CoCreateInstance (&CLSID_DataAccessClient, NULL, CLSCTX_INPROC_SERVER, &IID_IDataAccessClient, &pCOM);
What is Return Value of hr here
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hello everyone. I know this is a newbie question but I have to ask. I am pretty comfortable with windows programming in C and C++ as a whole however I am still sketchy over COM development. Specifically I would like to tie in my office solutions to my Visual studio solutions. I understand that interacting with Office requires COm deployment and I was hoping someone might point me in the right direction for finding a good reference. When I first started Windows programming I was told to get Petzold's book. I think it was one of the best investments I ever made. I was wondering and hoping frankly, that there was an equivalent to that with respect to COM programming.
|
|
|
|
|
Hi,
You can check my COM BLOG[^]. I have listed some good book names and useful URL's (Notes: These are my personal favourites)
Have a great day ahead!
Regards,
Sohail Kadiwala
(My Blog - http://blogs.wdevs.com/sohail/[^])
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I have just ordered a copy of Inside COM and I was looking into Inside OLE. I was wondering if anyone has read these books or have any other suggestions.
|
|
|
|
|
Hi Folks,
I am writing an Attributed COM component in Visual C++ 7.1. In standard cases, the name of the coclass is the same as the CLASS name. I want to know if it is possible to change the coclass name ?
For instance, in the following code of mine, IDL will be generated with the coclass named as "CMyData". But, I want to have the coclass name as "MyData" without changing the actual class name.
[CODE]
[
object,
uuid("19088A64-4E82-4FD7-A8A5-A9FEE2577FE8"),
dual, helpstring("IMyData Interface"),
pointer_default(unique)
]
__interface IMyData : IDispatch
{
[id(1), helpstring("method MyMethod")] HRESULT MyMethod();
}
[
coclass,
threading("apartment"),
support_error_info("IMyData"),
vi_progid("MyComponent.MyData"),
progid("MyComponent.MyData.1"),
version(1.0),
uuid("4AF80BC4-6A51-4E83-A3A0-9184230CD2AD"),
helpstring("MyData Class")
]
class ATL_NO_VTABLE CMyData : public IMyData
{
public:
CMyData();
virtual CMyData();
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
STDMETHOD(MyMethod)(void);
}
[/CODE]
Any help would be appreciated.
Regards,
Arun.
|
|
|
|
|
I am trying to develop a COM addin for Outlook 2003 using C#. I have read Hannes Pavelka's article on creating toolbars and buttons in Outlook. But, every button that I added only shows up in the main Outlook window. I'm not able to get anything new to show up in the message composition window. Does anyone know how to do this?
|
|
|
|