日期:2014-05-17  浏览次数:20750 次

如何在非组件动态链接库的类中调用winapi里的postmessage函数
情况说明如下:
设备提供商给了个用c++写的非组件dll,里面有typedef book (winapi *postmessage_fun)(hand hand,unit msg,wparam wparam,lparam lparam); 并且在extern "c" _declspec(dllimport) int setparent(HWND parent,UINT message,PostMessage_Fun fun)中调用。我想问在根据头文件写动态库的类时,c#语言应该怎么使用[dllimport(path),entryPoint ="setparentWnd"] public,static extern int setParentWnd(IntPtr parent,UInt32 message,Postmessage fun);这个postmessage应该怎么定义?求大神解答。
winapi c++ c# postmessage

------解决方案--------------------
用委托
delegate bool postmsg_func(IntPtr handler,uint msg ,Int32 wparam,Int32 lparam)

------解决方案--------------------
委托只是一个包装,你得写一个实际的方法,才能用委托包装这个方法,然后传给 setparent。