【发布时间】:2011-03-08 21:26:55
【问题描述】:
我需要在 clr 模式下在我的 windows 窗体项目中使用一些 win32 函数。(v c++ 2005) 我在表单项目中直接使用 win32 函数时遇到的错误是
**dbms.obj : error LNK2028: unresolved token (0A00000E) "extern "C" struct HWND__ * __stdcall GetForegroundWindow(void)" (?GetForegroundWindow@@$$J10YGPAUHWND__@@XZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)
dbms.obj : error LNK2019: unresolved external symbol "extern "C" struct HWND__ * __stdcall GetForegroundWindow(void)" (?GetForegroundWindow@@$$J10YGPAUHWND__@@XZ) referenced in function "int __clrcall main(cli::array<class System::String ^ >^)" (?main@@$$HYMHP$01AP$AAVString@System@@@Z)**
我的主要 cpp 代码是:
#include "stdafx.h"
#include "Form1.h"
#include "windows.h"
using namespace dbms;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
HWND neu;
neu=GetForegroundWindow();
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
Application::Run(gcnew Form1());
return 0;
}
代码只是为了演示我得到的错误。 这可能很愚蠢,但我对 win32 prog 至少了解一点,但对 .net 平台一无所知。如果有人可以帮助我在上面的代码中使用 win32 func 将不胜感激。 (我没有包含 form.h 文件。我认为它可能不需要)
【问题讨论】:
-
FindowWindow应该是FindWindow。这只是您的问题中的一个错字吗? -
你想打电话给
FindWindow而不是FindowWindow。
标签: winapi