问题描述
嗨!我试图在非托管C ++中使用ActiveX函数的功能.
Hi! I am trying to use a function of an ActiveX function in unmanaged C++.
我所拥有的:
- Dll文件(称为foocontrol.dll)
- 使用activex(com,我的情况是交替使用)的示例mfc项目,该项目具有使用com对象和该类的机器生成的IDispatch包装器类继承CWnd(在该接口中使用invokehelper 函数调用函数 )
- 已注册的Com对象,typelib,接口和Ole-Com对象查看器报告(我要在该类中使用的GUID和类的名称,以及要在该接口中使用的功能)(将它们称为foocontrol类,Ifoocontrol接口 和fooget函数)
- 有关foocontrol.dll的转储报告.在功能表中,Activex并没有什么特别的(顺序,提示,RVA和名称)
1 0 0005E70C CPlApplet
1 00032612 CheckDShowVer
3 2 00036C69 CheckMustRegisterDLL
3 00032605 CheckPIII
7 4 00005DD7 DllCanUnloadNow
5 0000D47C DllGetClassObject
9 6 0000FB4C DllRegisterServer
10 7 0000FB5B DllUnregisterServer
5 8 00033759 InstallMe
6 9 00035221卸载M
- Dll file (Call it foocontrol.dll)
- A sample mfc project using activex (com, I use interchangeably for my case) which has machine generated IDispatch wrapper class utilizing the com object and that class inherits CWnd (uses invokehelper function to call functions in that interface )
- A registered Com object, typelib, interface and an Ole-Com object viewer report(GUIDs and names of the class, interface I wanna use in that class and the function I wanna use within that interface) (Call them foocontrol class, Ifoocontrol interface and fooget function)
- DumpBin report for foocontrol.dll. In function table there is nothing special for an activex here (Ordinal, hint, RVA, name)
1 0 0005E70C CPlApplet
2 1 00032612 CheckDShowVer
3 2 00036C69 CheckMustRegisterDLL
4 3 00032605 CheckPIII
7 4 00005DD7 DllCanUnloadNow
8 5 0000D47C DllGetClassObject
9 6 0000FB4C DllRegisterServer
10 7 0000FB5B DllUnregisterServer
5 8 00033759 InstallMe
6 9 00035221 UninstallM
我没有的东西
- 任何类型的com对象实现的源代码
- 任何类型的com对象构建后的文件(除了dll)(我没有.lib .tlb等)
- Any kind of source code of com object's implementation
- Any kind of files after com object's build(besides dll) (I do not have a .lib .tlb etc)
我不能做什么:
- 在MFC中使用它(很多开销)
- 使用#import导致我实际上没有任何导入(以前的两种方式在示例CPPCOMClient示例中也进行了讨论,我不想这两种方式但另一种提到为C/C ++方式(使用RawConsumeSTAComponent和AutoWrap的RawAPI.h)或 我什至可以使用托管代码,并且它附带互操作服务)
- Use it in MFC (lots and lots of overhead)
- use #import cause I have nothing to import really (previous two ways are also discussed in example CPPCOMClient example and I want not these two but the other one mentioned as C/C++ way (RawAPI.h using RawConsumeSTAComponent and AutoWrap) or I can even use managed code and interop services comes with it)
我目前不擅长的事情
- 互操作方法
- IDL
- 托管C ++
我想做的是仅使用我声明的内容在类的接口中调用该函数. (我到目前为止尝试过的是PInvoke).有了我所拥有的,就不可能做到这一点(我是说,如果我不能做到这一点,我想我不明白这个主意了. 在COM后面.使用注册表是因为没有dll ****(它会被审查.4个字母:你好,减去o)对吗?但是我们总是需要另一件事来导入",那么它们的目的是什么?我也听到了注册免费的COM,但我想使用的全部 一个注册的COM)?谁能告诉我该怎么做?
What I wanna do is to call the function in an interface of a class with only what I stated to have. (What I tried upto now is PInvoke ). With what I have is it impossible to do so (I mean if I cannot do this I guess I did not understand the idea behind COM well. Using registries is for not having dll **** (it gets censored. 4 letters: hello minus o) right? but we always need anoter thing to "import" then what is the purpose of them? I also heard registy free COM but all I wanna use a registered COM)? If it is possible can anyone tell me how to do this?
(另外说我将使用CoCreateInstance.类,接口或类型库的第一个参数UID是什么?我猜答案是类CLSID.那么任何人都可以告诉我如何解释PC的接口吗?我不能做正在关注
(Additionally lets say I will use CoCreateInstance. What will be my first parameter UID of class or interface or type library? I guess answer is class CLSID. Then can anyone tell how can I explain interface to my pc? I cannot do following
CoInitialize(NULL);
IMyInterface* pIFace;
CoCreateInstance(CLSID_MyObject, NULL, CLSCTX_ALL, IID_IMyInterface, &pIFace);
推荐答案
那么,您是否拥有控件的类型库?请注意,类型库不必位于独立的.tlb文件中.更常见的是它作为资源绑定到DLL.
So do you, or don't you, have a type library for your control? Note that a type library doesn't have to be in a standalone .tlb file. More often, it's bound to the DLL as a resource.
在DLL本身上尝试#import.如果知道,它将知道如何读取内部的TLB.有一个.
Try #import on the DLL itself. It knows how to read the TLB inside, if there is one.
这篇关于COM互操作非托管代码示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!