Home > OS >  Static or dynamic linking when #import abc.exe in c
Static or dynamic linking when #import abc.exe in c

Time:08-25

Does the .exe get statically linked or dynamically linked when #import abc.exe is used in c ?

The question is whether it is required to have abc.exe in the location of executable created by class which is having #import abc.exe to link dynamically?

CodePudding user response:

The answer is Neither. #import will import the typelibrary (binary representation of COM types/interfaces) from that exe. Once your program starts it will start abc.exe (if registered properly) and your process will make inter process calls (RCP) to abc.exe using the COM infrastructure. And abc.exe doesn't have to be in your path, but it must have been registered with windows using abc.exe /RegServer (the information to find abc.exe will end up in the registry)

CodePudding user response:

I suggest you could refer to the Doc: #import directive

Used to incorporate information from a type library. The content of the type library is converted into C classes, mostly describing the COM interfaces.

That lets you import information from a type library.

filename is optionally preceded by a directory specification. The file name must name an existing file. The difference between the two syntax forms is the order in which the preprocessor searches for the type library files when the path is incompletely specified.

  • Related