使用类型库进行编组 [英] Using type libraries for Marshalling

查看:60
本文介绍了使用类型库进行编组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

当我在本地COM服务器中创建对象的实例时,要求该类提供与封送处理相关的各种接口.正如在网络上看到的那样,可以使用默认的封送拆收器,但是为此,要么必须存在代理DLL,要么应使用typelib.我创建了一个描述我的界面和类的ODL文件:

Hey everyone,

When i create an instance of an object in my local COM-Server the class is requested to provide various interfaces which are marshaling related. As ive seen in the web the default marshaler can be used but for that either a proxy DLL has to be there or a typelib should be used. I created an ODL file describing my interface and class:

import "oaidl.idl";
import "ocidl.idl";

[
	object,
	uuid(3DBCAC5E-1A1B-4E56-B9AD-DCF19597B869),
	pointer_default(unique)
]
interface ITestClass : IUnknown {
	[id(1)] HRESULT Foo(int);
};

[
	uuid(737BB030-CE7A-4361-9C7E-1A1D697B9493),
	version(1.0),
]
library LocalServerLib
{
	importlib("stdole2.tlb");
	[
		uuid(3DBCAC5E-1A1B-4E56-B9AD-DCF19597B868)
	]
	coclass TestClass
	{
		[default] interface ITestClass;
	};
};



根据定义:



With the according definition:

class __declspec(uuid("{3DBCAC5E-1A1B-4E56-B9AD-DCF19597B869}"))
ITestClass : public IUnknown
{
public:
	virtual HRESULT Foo(int value) = 0;
};

// just used for __uuidof, in the server its fully declared
class __declspec(uuid("{3DBCAC5E-1A1B-4E56-B9AD-DCF19597B868}")) 
TestClass
{
};



typelib是使用RegisterTypeLibForUser注册的,并且我的类有一个TypeLib条目,其GUID的类型为lib.
.
但是好吧,COM仍然要求我班上的所有封送处理.我想念什么吗?

问候和感谢
Regner



The typelib is registered using RegisterTypeLibForUser and my class has an entry TypeLib with the GUID of the registered type lib.

But well, still COM requests all the marshaling from my class. Am i missing something?

Greetings and thanks
Regner

推荐答案

oleautomation标签添加到您的接口定义中,然后tlb编组将开始
add the oleautomation tag to your interface definition, and the tlb marshalling will start


服务器"声音就像"DCOM"(分布式COM)一样.这是在M
"Server" sounds like "DCOM" (Distributed COM). It is another technique "out of the M


-Hell之外"的另一种技术.

我建议您寻找一个有效的示例并对其进行修改.不要费力修改UUID ;-)

不能通过某些Web服务将其他技术用作XML.通过C#可以轻松实现.
-Hell".

I advise you to look for a working sample and modify it. Dont ferget to modify the UUIDs ;-)

Cant you use an other technology as XML via some Webservices. That works easy via C#.


这篇关于使用类型库进行编组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆