Board logo

标题: [问题求助] 关于vbs用dynwrap2.dll声明api时的未定义参数问题 [打印本页]

作者: czjt1234    时间: 2012-10-21 09:44     标题: 关于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应该用哪个字母代表呢?





欢迎光临 批处理之家 (http://bathome.net./) Powered by Discuz! 7.2