midl 的类型你自己看
1。MIDL Predefined and Base Types
MIDL supports the following base and predefined types.Data type Description Default sign
Boolean 8 bits. Not compatible with oleautomation interfaces; use VARIANT_BOOL instead. Unsigned
byte 8 bits. (not applicable)
char 8 bits. Unsigned
double 64-bit floating point number. (not applicable)
error_status_t 32-bit unsigned integer for returning status values for error handling. Unsigned
float 32-bit floating point number. (not applicable)
handle_t Primitive handle type for binding. (not applicable)
hyper 64-bit integer. Signed
int 32-bit integer. On 16-bit platforms, cannot appear in remote functions without a size qualifier such as short, small, long or hyper. Signed
__int32 32-bit integer. Equivalent to long.
__int3264 An integer that is 32-bit on 32-bit platforms, and is 64-bit on 64-bit platforms. Signed
__int64 64-bit integer. Equivalent to hyper.
long 32-bit integer. Signed
short 16-bt integer. Signed
small 8-bit integer. Signed
void Indicates that the procedure does not return a value. (not applicable)
void * 32-bit pointer for context handles only. (not applicable)
wchar_t 16-bit predefined type for wide characters. Unsigned 2。Other MIDL Data Types
MIDL recognizes a number of COM and Automation data types, such as BSTR, VARIANT, and SAFEARRAY, and COM handles, such as HMETAFILE_PICT, HENHMETAFILE, HMETAFILE, HBITMAP, HPALETTE, and HGLOBAL. For more information, including the names of the import files needed to use these types, see Marshaling OLE Data Types.
1。MIDL Predefined and Base Types
MIDL supports the following base and predefined types.Data type Description Default sign
Boolean 8 bits. Not compatible with oleautomation interfaces; use VARIANT_BOOL instead. Unsigned
byte 8 bits. (not applicable)
char 8 bits. Unsigned
double 64-bit floating point number. (not applicable)
error_status_t 32-bit unsigned integer for returning status values for error handling. Unsigned
float 32-bit floating point number. (not applicable)
handle_t Primitive handle type for binding. (not applicable)
hyper 64-bit integer. Signed
int 32-bit integer. On 16-bit platforms, cannot appear in remote functions without a size qualifier such as short, small, long or hyper. Signed
__int32 32-bit integer. Equivalent to long.
__int3264 An integer that is 32-bit on 32-bit platforms, and is 64-bit on 64-bit platforms. Signed
__int64 64-bit integer. Equivalent to hyper.
long 32-bit integer. Signed
short 16-bt integer. Signed
small 8-bit integer. Signed
void Indicates that the procedure does not return a value. (not applicable)
void * 32-bit pointer for context handles only. (not applicable)
wchar_t 16-bit predefined type for wide characters. Unsigned 2。Other MIDL Data Types
MIDL recognizes a number of COM and Automation data types, such as BSTR, VARIANT, and SAFEARRAY, and COM handles, such as HMETAFILE_PICT, HENHMETAFILE, HMETAFILE, HBITMAP, HPALETTE, and HGLOBAL. For more information, including the names of the import files needed to use these types, see Marshaling OLE Data Types.
如何定义,如何使用
typedef struct tag_GPOBROWSEINFO
{
DWORD dwSize; // [in] Initialized to the size of this structure
DWORD dwFlags; // [in] Flags defined above
HWND hwndOwner; // [in] Parent window handle (can be NULL)
LPOLESTR lpTitle; // [in] Title bar text. If NULL, "Browse for a Group Policy Object" will be the default text
LPOLESTR lpInitialOU; // [in] Initial Domain/Organizational Unit to open focus on
LPOLESTR lpDSPath; // [in/out] Pointer to the buffer that receives the Active Directory GPO path
DWORD dwDSPathSize; // [in] Size in characters of buffer given in lpDSPath
LPOLESTR lpName; // [in/out] Pointer to a buffer that receives either the computer name or
// the friendly name of the GPO (can be NULL)
DWORD dwNameSize; // [in] Size in characters of buffer given in lpName
GROUP_POLICY_OBJECT_TYPE gpoType; // [out] Specifies the type of GPO
GROUP_POLICY_HINT_TYPE gpoHint; // [out] Specifies a hint of the GPO association
} GPOBROWSEINFO, *LPGPOBROWSEINFO;
typedef enum _GROUP_POLICY_OBJECT_TYPE {
GPOTypeLocal = 0, // GPO on the local machine
GPOTypeRemote, // GPO on a remote machine
GPOTypeDS // GPO in the Active Directory
} GROUP_POLICY_OBJECT_TYPE, *PGROUP_POLICY_OBJECT_TYPE;typedef enum _GROUP_POLICY_HINT_TYPE {
GPHintUnknown = 0, // No link information available
GPHintMachine, // GPO linked to a machine (local or remote)
GPHintSite, // GPO linked to a site
GPHintDomain, // GPO linked to a domain
GPHintOrganizationalUnit // GPO linked to a organizational unit
} GROUP_POLICY_HINT_TYPE, *PGROUP_POLICY_HINT_TYPE;
可以试一下使用VARIANT类型
idl中定义
[
uuid(B424C0DD-3BE7-11D6-812A-00D00912BB28),
helpstring("struct __youstruct"),
]
typedef struct __youstruct
{
int a;
BSTR b;
}youstruct HRESULT GetStruct([out, retval] VARIANT *value);
HRESULT SetStruct([in] VARIANT value);///////////////////
程序中添加变量
youstruct *mystr;STDMETHODIMP CYouCom::SetStruct(VARIANT Value)
{
mystr = Value.pvRecord ;
}
STDMETHODIMP CYouCom::GetStruct(VARIANT *Value)
{
Value->vt = VT_RECORD;
Value->pvRecord = mystr ;
}
别人可以看到它的类型,而不是Variant
thanks
想象一下ADO吧。
2:如果你想返回对象,可以定义这个对象的接口,然后返回这个对象的
接口,当然,这里的对象必须是COM对象,而不可能是别的对象?
在接口中直接使用,上面一个回贴中提到的struct型东西被返回后,如果VB中要调用,
可以在Object viewer 中看到这个结构的定义,然后,再使用这个
参数?这样,就是说VBscript这些语言就无法使用这个含有结构参数
得方法了?