1

I've written a com dll using VS2012. I got 2 projects - my DLL project and a PS Project. PS has 3 classes: myproj_i.h myProj_i.c myProj_p.c

now I want to call the dll from another MFC project:

hr = CoCreateInstance( CLSID_MYTASK, NULL, CLSCTX_INPROC_SERVER, IID_IMYTASK, (void**) &pMYTASK );

I have included the myproj_i.h file - so I get all the symbols recognised, yet I can't link them, as I'm missing the _i.c file.

If I add them to the project I get planty of PCH errors.

How should I Link my MFC project and call the DLL ?

I have also tried to use #import of the dll but then I get missing TLH error, and I haven't found that file in the DLL project.

Including the myProjPS.lib did not solve it either...

4

1 回答 1

1

MIDL 生成的 .c 文件不使用预编译的头文件。如果您将它们链接到您的程序中(我通常为它们制作静态库,但这是一种不同的方法),您需要关闭这些特定 .c 文件的预编译头文件。

  • 右键单击解决方案资源管理器中的 myProj_i.c 文件并调出其属性。
  • 在前两个下拉列表中选择所有平台/所有配置。
  • 展开左侧树中的 C++ 设置。
  • 在左侧树中选择 Precompiled Headers
  • 为该文件关闭它们。

这应该允许它成功编译和链接。

于 2013-09-05T08:03:21.457 回答