一个COM获取虚拟表指针的问题,我晕菜了,看不懂,用过的朋友指教一个,谢谢
LPVOID FAR* ppIface=NULL;
const GUID MyOcxCLSID = {0xB26F6246,0x4C7D,0x11D1,0x91,0x0E,0x00,0x60,0x08,0x07,0x16,0x3F }; //My CLSID:XCDZIP35.OCX
const IID MyOcxFaceID = {0xB26F6244,0x4C7D,0x11D1,0x91,0x0E,0x00,0x60,0x08,0x07,0x16,0x3F };
if (CoInitialize(NULL) != S_OK)
{
printf("Initialize COM library failed!\n");
return 1L;
}
hResult = CoCreateInstance(MyOcxCLSID, NULL,CLSCTX_INPROC_SERVER, IID_IUnknown, (void **)&pUnknown);
if (hResult != S_OK)
{
printf("Create object failed!\n");
return 1L;
}
hResult = pUnknown->QueryInterface(IID_IUnknown, (void **)&ppIface);
if (hResult != S_OK) {
pUnknown->Release();
printf("QueryInterface IDictionary failed!\n");
return 1L;
}
上面的IID_IUnknown指向的不是我的OCX的对象,是系统OLEXXX的,导致我后面ppIface获取的不是我的OCX接口指针,我用MyOcxFaceID代替也没用,我用OLE-VIEW查了一下我的OCX,
// Generated .IDL file (by the OLE/COM Object Viewer)
// typelib filename: XCDZIP35.OCX
[
uuid(B26F6243-4C7D-11D1-910E-00600807163F),
version(2.78),
helpstring("Xceed Zip ActiveX Control")
]
library XCEEDZIPLib
{
// TLib : // TLib : Standard OLE Types : {BEF6E001-A874-101A-8BBA-00AA00300CAB}
importlib("olepro32.dll");
// TLib : OLE Automation : {00020430-0000-0000-C000-000000000046}
importlib("stdole32.tlb");
// Forward declare all types defined in this typelib
dispinterface _DXceedZip;
dispinterface _DXceedZipEvents;
[
uuid(B26F6244-4C7D-11D1-910E-00600807163F),
helpstring("Dispatch interface for the Xceed Zip Control"),
hidden
]
dispinterface _DXceedZip {
properties:
[id(0x00000001)]
VARIANT_BOOL Abort;
[id(0x00000002)]
short Compression;
………………
[id(0x00000026)]
VARIANT_BOOL SfxInstallMode;
[id(0x00000027), hidden]
BSTR InternalState;
methods:
[id(0x00000028), propget]
BSTR SfxPrompts(short SfxPromptID);
[id(0x00000028), propput]
void SfxPrompts(
short SfxPromptID,
BSTR rhs);
………………
[id(0x0000003b)]
void SfxResetDefaultStrings();
[id(0xfffffdd8)]
void AboutBox();
};
[
uuid(B26F6245-4C7D-11D1-910E-00600807163F),
helpstring("Event interface for the Xceed Zip Control")
]
dispinterface _DXceedZipEvents {
properties:
methods:
[id(0x00000001)]
void Adding(
BSTR* FileName,
long Size,
long PSize,
long Processed,
short FileAttr,
BSTR* FTime,
long CRC,
short Ratio,
short Completion,
short Method,
short Encrypted,
short ComLen,
BSTR* Comment);
………………
};
[
uuid(B26F6246-4C7D-11D1-910E-00600807163F),
helpstring("Xceed Zip Control"),
control
]
coclass XceedZip {
[default] dispinterface _DXceedZip;
[default, source] dispinterface _DXceedZipEvents;
};
};
请问一下,这到底怎么回到,我想获取我的OCX的虚拟表