Search code examples
winapiclrmode

Using win32 APIs in Windows Forms Projects


I need to use Win32 Functions like GetForegroundWindow(), ShowWindow(), SetForegroundWindow(), SendMessage(), GetWindow().......in my Windows Form Project in Visual C++ 2005 (CLR mode). the error i get when i use these functions is error C3861: 'GetForegroundWindow': identifier not found


Solution

  • The first version of this question said this is C++/CLI code. You don't need pinvoke to use the winapi, C++/CLI was designed as an interop language. Just #include <windows.h> and directly call the API functions you want to use. Nobody can really help you if you don't document the errors you get.