Compiling an embedded COM client client in a client using VS2010

I am new to COM programming and create my own base pair of COM servers / clients from Visual Studio 2010. Both clients and server projects live in the same solution. I would like to know which most suitable way is to include the created client stub and header file in the client project. I created MIDL in my server project, and when I compile the project, the _h.h, _i.c and _p.c files are generated in the project's source directory.

  • Do I need to compile both .c files in my client project?
  • Is this the best way to compile them in a client project by adding them as linked files to the client project from the source directory of the server project?
  • Is there a way for Visual Studio to find out that the _h.h, _i.c and _p.c files are out of date when I change MIDL, or do I need to remember to recompile the server project anytime I touch MIDL?
  • Where is the best place for the .h file - can it go in the stdafx.h file in the server project? If so, is it correct to add the source directory of the server project to the header, include the client project directories?
  • Should a client project have a Link (in the sense of Visual Studio Reference) to a server project?

Additionally - I want to make this registration free. Is there anything else I need to do in this case, besides having a manifest for my client and server?

..

change

Having a look at the MSDN article here: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366830(v=vs.85).aspx , it looks like from the generated files, if I only want to support in -proc reg-free, I only need to compile _i.c and include the _h.h files in my client program.

dlldata.c and _p.c are apparently used to create a proxy DLL that supports registration on a remote computer (for activation by a remote computer or a local computer from proc? If necessary for a local computer, from proc, why is it necessary considering that the COM server DLL is registered? The COM server DLL is different from the proxy DLL, yes?)

Many thanks,

- Matt

+6
source share
1 answer

The generated _p.c and dlldata.c must be compiled into a separate project to create a proxy / stub DLL. You do not always need it only when you march calls through apartments or processes.

The generated _i.c file provides GUID values. Compile it on the server and proxy / stub. Compiling it into the client is fine, but using the __uuidof keyword is the easiest.

The generated _i.h file contains interface declarations and coclass. You will need to # include it in the server and client.

Midl.exe should automatically recover these files when .idl changes. This, in turn, guarantees the restoration of the client, server and proxy / stub.

stdafx.h excellent, yes in the include directory.

There are no "links", the client and server are not dependent on links.

You will need to write a manifest for reg-free com and paste it into the client.

+5
source

Source: https://habr.com/ru/post/913388/


All Articles