I'm new to COM programming, and creating a basic native COM server / client pair from Visual Studio 2010. Both the client and the server projects live in the same solution. I'd like to know what the most appropriate way is to include the generated client stub and header file in the client project. I've created the MIDL in my server project, and when I compile the project the _h.h, _i.c, and _p.c files are generated in my project source directory.
Additionally - I'd like to make this registration free. Is there anything extra I need to do in this case, besides having manifests for my client and server?
..
edit
Looking at the MSDN article here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366830(v=vs.85).aspx, it appears that of the files generated, if I only want to support in-proc reg-free activation, I only need to compile the _i.c and include the _h.h files in my client program.
dlldata.c, and _p.c appear to be used to create a proxy DLL, which supports registration on a remote computer (for activation by a remote computer? or also local computer, out of proc? If it's required for local computer, out of proc, why is it needed given that the COM server's dll is registered? The COM server DLL is different from the proxy DLL, yes?)
Thanks very much,
--Matt
The generated _p.c and dlldata.c must be compiled into a separate project to build the proxy/stub DLL. You don't always need one, only when you marshal calls across apartments or processes.
The generated _i.c file provides the GUID values. Compile it into the server and the proxy/stub. Compiling it into the client is okay but using the __uuidof keyword is easiest.
The generated _i.h file contains the interface and coclass declarations. You'll need to #include it in the server and the client.
Midl.exe should automatically regenerate these files when you change the .idl. Which in turn ensures that client, server and proxy/stub get rebuilt.
stdafx.h is fine, yes on the include directory.
No on the "reference", the client and server have no link dependency.
You'll have to write the manifest for reg-free com and embed it in the client.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With