• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
PowerCoder
博客园    首页    新随笔    联系   管理    订阅  订阅

自己写个activex控件,如何知道他的classid(转载)

提问:

 

在网页里用的时候需要知道他的classid
我在代码中看到有

const GUID CDECL BASED_CODE _tlid =
    { 0x89201950, 0x2CAC, 0x4CF7, { 0x99, 0x8, 0x73, 0x38, 0x61, 0x41, 0xEF, 0xD2 } };

这个,可别人的都是10进制的啊?

 

#include <olectl.h>
 #include <idispids.h>

 [ uuid(89201950-2CAC-4CF7-9908-73386141EFD2), version(1.0),
   helpfile("activex.hlp"),
   helpstring("activex ActiveX Control module"),
   control ]
 library activexLib
 {
 importlib(STDOLE_TLB);

 //  Primary dispatch interface for CactivexCtrl

 [ uuid(88F1FDE7-7BD4-48FD-9D0C-6C2AEA01D7FC),
   helpstring("Dispatch interface for activex Control")]
 dispinterface _Dactivex
 {
 properties:
 methods:

 [id(DISPID_ABOUTBOX)] void AboutBox();
 };

 //  Event dispatch interface for CactivexCtrl

 [ uuid(8DE3C33B-2B0B-4669-A636-B6FD893DF39F),
   helpstring("Event interface for activex Control") ]
 dispinterface _DactivexEvents
 {
 properties:
 //  Event interface has no properties

 methods:
 };

 //  Class information for CactivexCtrl

 [ uuid(5161E46C-C157-4BC7-9DB7-7597617722F0),
   helpstring("activex Control"), control ]
 coclass activex
 {
 [default] dispinterface _Dactivex;
 [default, source] dispinterface _DactivexEvents;
 };

 };

这么多 哪个才是?

 

回答:

[ uuid(5161E46C-C157-4BC7-9DB7-7597617722F0),
  helpstring("activex Control"), control ]
coclass activex
-----------------------------------
5161E46C-C157-4BC7-9DB7-7597617722F0这个就是,其实就是C++ MFC项目中生成的idl文件中的最后一个GUID

 

然后在web中调用如下,即可:

<object id="activex" classid="clsid:5161E46C-C157-4BC7-9DB7-7597617722F0"></object>

 

原帖地址

 

posted @ 2017-11-01 16:36  PowerCoder  阅读(2384)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3