- 帖子
- 1058
- 积分
- 1559
- 技术
- 112
- 捐助
- 0
- 注册时间
- 2010-4-30
|
[问题求助] 关于vbs用dynwrap2.dll声明api时的未定义参数问题
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
比如这个api,可以这样声明
Dim UserWrap
Set UserWrap = CreateObject("DynamicWrapper")
UserWrap.Register "USER32.DLL", "FindWindow", "I=ss", "f=s", "R=l"
但是有些需要自定义类型的参数类型,在vbs里该如何声明?
比如
Declare Function CLSIDFromString Lib "ole32" (ByVal Str As Long, id As GUID) As Long
用"I=lG", "f=s", "R=l"是不行的
在vb里可以先定义
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
再声明
可用参数类型搜到是这个
const ARGTYPEINFO ArgInfo[] =
{
{'a', sizeof(IDispatch*), VT_DISPATCH}, // a IDispatch*
{'c', sizeof(unsigned char), VT_I4}, // c signed char
{'d', sizeof(double), VT_R8}, // d 8 byte real
{'f', sizeof(float), VT_R4}, // f 4 byte real
{'k', sizeof(IUnknown*), VT_UNKNOWN}, // k IUnknown*
{'h', sizeof(long), VT_I4}, // h HANDLE
{'l', sizeof(long), VT_I4}, // l long
{'p', sizeof(void*), VT_PTR}, // p pointer
{'s', sizeof(BSTR), VT_LPSTR}, // s string
{'t', sizeof(short), VT_I2}, // t short
{'u', sizeof(UINT), VT_UINT}, // u unsigned int
{'w', sizeof(BSTR), VT_LPWSTR}, // w wide string
}
还有
Private Declare Function GdipSaveImageToFile Lib "GDIPlus" (ByVal Image As Long, ByVal FileName As Long, clsidEncoder As GUID, encoderParams As Any) As Long
这个Any应该用哪个字母代表呢? |
|