(1) use tool to generate def and .lib from DLL ( assuming no header file)
http://purefractalsolutions.com/show.php?a=utils/expdef
(2) VC++ project linker-->input additional dependency
(3) declare and use in CPP
extern "C" unsigned char Open_USB();
extern "C" unsigned char Accept_LED(int value);
extern "C" void Set_Callback(void* pAny);
void(__stdcall*p)(int); // calling convention matching far pascal, for most c function
//void __cdecl* p; // ptrAny
static void __stdcall CB1(int value) {..} instance function would hast this->* so callback must use static to remove this.
p = &CB1;
::Open_USB();
::Accept_LED(0);
::Set_Callback(p);
again cannot use __cdecl must use __stdcall. It turns out Calling Conversion even affect [DllImport] when re-target .net 4.0 from .net 4.0, must specify CDecl in DllImports
Saturday, December 27, 2014
Call 3rd party DLL from ATL COM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment