Accessing WIN32 API functions from C++ CLI
First, add the following declaration to stdafx.h:
// TODO: reference additional headers your program requires here
#include “windows.h”
For example, when calling SendMessage, take note of the double colon at the beginning:
::SendMessage((HWND)this->button1->Handle.ToInt32(), WM_LBUTTONDOWN, 0, 0);
The following would not work:
SendMessage((HWND)this->button1->Handle.ToInt32(), WM_LBUTTONDOWN, 0, 0);
and result in the following error:
error C2661: ‘System::Windows::Forms::Control::SendMessage’ : no overloaded function takes 4 arguments
If the error still persists, check Project Properties->Linker->Input->Additional dependencies. Click the button with the dots and turn on the checkbox for “Inherit from parent…”
So what do you do when the same API call is defined in multiple win32api headers….. i.e. NetShareEnum in LMShare.h and SvrAPI.h.