Implementing extern WINAPI call in MFC C++ App

落花浮王杯 提交于 2019-12-13 00:47:22

问题


I am working with Windows Form App C++. I have to use some header file that has

HRESULT extern WINAPI StartUp ( DWORD dwVRequired, LPVERSION lpVersion);

I have to execute this method within Form1.h

private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
    APPVERSION version;
    HRESULT result = APPStartUp(APP_VERSIONS, &version);
}

But I am getting the compile error like this

Error 1 error LNK2028: unresolved token (0A000025) "extern "C" long __stdcall APPStartUp(unsigned long,struct _version *)" (?WFSStartUp@@$$J18YGJKPAU_wfsversion@@@Z) referenced in function "private: void __clrcall MyAppPresenter::Form1::Form1_Load(class System::Object ^,class System::EventArgs ^)" (?Form1_Load@Form1@MyAppPresenter@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z) C:\Projects\MyAppPresenter\MyAppPresenter\MyAppPresenter.obj MyAppPresenter

I assume it has something to do with MSVS2010 C++ Console Code Ported to MSVS2010 C++ GUI is Failing. Why?

But how it can be done? Any clue how it could be fixed?


回答1:


I checked the console C++ project and found that *.vsxproj has

<ItemGroup>
    <Library Include="C:\Program Files\Common Files\GCFApp\lib\msmanager.lib" />
</ItemGroup>

So I just added this code to the Windows Form C++ project file manually and now it works.

Anyway I have no clue how to add it using GUI of VS 2010.



来源:https://stackoverflow.com/questions/33654914/implementing-extern-winapi-call-in-mfc-c-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!