本帖最后由 仙乃日 于 2010-7-26 21:32 编辑
DllCall ( "dll", "返回值类型", "函数名称" [, "类型1", 参数1[, "类型n", 参数n]] )
"返回值类型":除非API函数明确规定了参数类型必须为某类型。不然的话int、long、BOOL、UINT、ULONG、DWORD、ptr、HWND、HANDLE、float可以替用,都是占用4字节。
同样short、USHORT、WORD也可替用。INT64、UINT64、double也行。在字节相等的情况下,一般可以选用别的参数类型,不过最好是按API的参数类型来写。DllCall("user32.dll","int","MessageBoxW","hwnd",0,"wstr","欢迎学习DLLCall!","wstr","例子1","uint",0)
DllCall("user32.dll","long","MessageBoxW","hwnd",0,"wstr","欢迎学习DLLCall!","wstr","例子2","ULONG",0)
DllCall("user32.dll","BOOL","MessageBoxW","hwnd",0,"wstr","欢迎学习DLLCall!","wstr","例子3","HWND",0)
DllCall("user32.dll","DWORD","MessageBoxW","hwnd",0,"wstr","欢迎学习DLLCall!","wstr","例子4","HANDLE",0)
DllCall("user32.dll","float","MessageBoxW","hwnd",0,"wstr","欢迎学习DLLCall!","wstr","例子5","ptr",0)
MessageBoxW定义WINUSERAPI int WINAPI MessageBoxW (HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)
所以dllcall("user32.dll","int","MessageBoxW","hwnd",0,"wstr","欢迎学习DLLCall!","wstr","例子1","uint",0)的写法最适合。 |