一个关于COM接口的很简单的问题,高手们闭着眼睛都可以回答的

ajet 2002-06-24 09:20:23
只知一个Interface的GUID为"6C44DF74-72B9-4992-A1EC-EF996E0422D4",其它的什么都不知道的情况下,怎么得到它的CComPtr指针?请指教,谢谢!
...全文
160 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
maphis 2002-06-24
  • 打赏
  • 举报
回复
你如果不知道CLSID的话,那么就意味着不能创建相应的实例,所以当然不能得到。

相关原理可以看看讲COM的书。
ajet 2002-06-24
  • 打赏
  • 举报
回复
到底能不能得到?
ultraboy 2002-06-24
  • 打赏
  • 举报
回复
其他什么都不知道,你得到指针能干嘛?
ajet 2002-06-24
  • 打赏
  • 举报
回复
maphis(bool bPoor=true) :谢谢你,谢谢你,太感谢你了!!!(真想亲你一口)
maphis 2002-06-24
  • 打赏
  • 举报
回复
有重定义发生,你可以去掉no_namespace参数,这样你使用的时候注意要加上namespace就可以了。
ajet 2002-06-24
  • 打赏
  • 举报
回复
volcary((冰火山):
我在导出类型库时出错,我是想导出MICROSOFT TTS 引擎的,在StdAfx.h中加入
#import "C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.dll" no_namespace
后编译出错,提示如下:
Compiling...
StdAfx.cpp
d:\abcddd\b\stdafx.h(23) : warning C4192: automatically excluding 'wireHWND' while importing type library 'C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.dll'
d:\abcddd\b\stdafx.h(23) : warning C4192: automatically excluding '_RemotableHandle' while importing type library 'C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.dll'
d:\abcddd\b\stdafx.h(23) : warning C4192: automatically excluding '__MIDL_IWinTypes_0009' while importing type library 'C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.dll'
d:\abcddd\b\stdafx.h(23) : warning C4192: automatically excluding 'IStream' while importing type library 'C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.dll'
d:\abcddd\b\stdafx.h(23) : warning C4192: automatically excluding 'ISequentialStream' while importing type library 'C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.dll'
d:\abcddd\b\stdafx.h(23) : warning C4192: automatically excluding '_LARGE_INTEGER' while importing type library 'C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.dll'
d:\abcddd\b\stdafx.h(23) : warning C4192: automatically excluding '_ULARGE_INTEGER' while importing type library 'C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.dll'
d:\abcddd\b\stdafx.h(23) : warning C4192: automatically excluding 'tagSTATSTG' while importing type library 'C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.dll'
d:\abcddd\b\stdafx.h(23) : warning C4192: automatically excluding '_FILETIME' while importing type library 'C:\Program Files\Common Files\Microsoft Shared\Speech\sapi.dll'
d:\abcddd\b\debug\sapi.tlh(3515) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3515) : warning C4129: 'M' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3515) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3516) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3516) : warning C4129: 'M' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3516) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3517) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3517) : warning C4129: 'M' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3517) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3517) : warning C4129: 'A' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3518) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3518) : warning C4129: 'M' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3518) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3518) : warning C4129: 'A' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3519) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3519) : warning C4129: 'M' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3519) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3519) : warning C4129: 'V' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3520) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3520) : warning C4129: 'M' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3520) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3520) : warning C4129: 'R' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3521) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3521) : warning C4129: 'M' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3521) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3521) : warning C4129: 'A' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3522) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3522) : warning C4129: 'M' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3522) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3522) : warning C4129: 'P' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3523) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3523) : warning C4129: 'M' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3523) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3523) : warning C4129: 'R' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3524) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3524) : warning C4129: 'M' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3524) : warning C4129: 'S' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3524) : warning C4129: 'C' : unrecognized character escape sequence
d:\abcddd\b\debug\sapi.tlh(3551) : warning C4305: 'initializing' : truncation from 'const double' to 'const float'
d:\abcddd\b\debug\sapi.tlh(4511) : error C2011: 'IServiceProvider' : 'struct' type redefinition
d:\abcddd\b\debug\sapi.tlh(6132) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
d:\abcddd\b\debug\sapi.tlh(6695) : error C2039: 'RemoteQueryService' : is not a member of 'IServiceProvider'
c:\program files\microsoft visual studio\vc98\include\servprov.h(108) : see declaration of 'IServiceProvider'
Error executing cl.exe.
Creating browse info file...

b.exe - 2 error(s), 49 warning(s)
volcary 2002-06-24
  • 打赏
  • 举报
回复
1.在HKEY_CLASSES_ROOT\Interface\ 找到
项“6C44DF74-72B9-4992-A1EC-EF996E0422D4”
2.在其项TypeLib下找到GUID是CLSID
3.在HKEY_CLASSES_ROOT\CLSID\ 找到 该CLSID_GUID其中
如果是进程外则找\localserver其中就是本地COM组件
如果是进程内找\InProcServer32
4.注册你的DLL yourcom.dll -regserver32
5.#import "youcom.dll" no_namespace
6.定义 yourcomclassPtr cominter
7.cominter.cocreateinstance()
......//调用
8.cominter.Release();

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧