tempad
Readygo技术搜索引擎 >>PHP技术 >> 喜马拉雅山般的难题——有请斑竹、微软专家、VC前辈

喜马拉雅山般的难题——有请斑竹、微软专家、VC前辈

Readygo技术搜索引擎 网络搜索 efish 2008-1-14 16:10:27

喜马拉雅山般的难题——有请斑竹、微软专家、VC前辈

楼主Jiemi(Jiemi)2002-07-20 11:04:43 在 VC/MFC / ATL/ActiveX/COM 提问

为了请求各位关注及帮忙解决这个已经烦扰我多时的问题,恕我夸夸其词了   ~_~  
   
  喜马拉雅山难题是:请问VC的#import指令能导入其他编程工具生成的tlb类型库文件,并完美无误地生成.tlh和.tli文件吗?  
   
  我使用powerbuilder8.0做了一个automation   server,调试通过,并配置生成了类型库文件bms_validate_tlf.tlb,然后在一个VC项目的文件vctest.h中加了如下一行代码:  
   
  //   vctest.h   :   vctest   应用程序的主头文件  
  //  
   
  #import   "h:\bms\validate\bms_validate_tlf.tlb"   //我添加的代码  
  #pragma   once  
   
  #ifndef   __AFXWIN_H__  
  #error   include   "stdafx.h"   before   including   this   file   for   PCH  
  #endif  
   
  #include   "resource.h"               //   主符号  
   
   
  然后我便编译vctest.cpp,预料中的.tlh和.tli文件是生成了,可是也带来了112个错误,大多是语法错误如C4229、C2018、C2143、C2238,还有C2059等,我真不明白,VC自己编译生成的文件也有如此语法错误!  
   
  请求各位前辈襄助,不胜感激!无以为报,惟有100分相送了。  
   
   
  下面是摘录的一部分错误列表:  
  c:\exercise\vctest\Debug\bms_validate_tlf.tlh(48):   warning   C4229:   使用了记时错误   :   忽略数据上的修饰符  
  c:\exercise\vctest\Debug\bms_validate_tlf.tlh(48):   error   C2018:   未知字符“0x40”;不支持   unicode   标识符  
  c:\exercise\vctest\Debug\bms_validate_tlf.tlh(48):   error   C2143:   语法错误   :   缺少“;”(在“常数”的前面)  
  c:\exercise\vctest\Debug\bms_validate_tlf.tlh(48):   error   C2433:   “n_validate::In_validate::postevent”   :   不允许在数据声明中使用“virtual”  
  c:\exercise\vctest\Debug\bms_validate_tlf.tlh(48):   error   C2365:   “n_validate::In_validate::postevent”   :   重定义;以前的定义是“成员函数”  
  c:\exercise\vctest\Debug\bms_validate_tlf.tlh(51):   error   C2238:   意外的标记位于“;”之前  
  c:\exercise\vctest\Debug\bms_validate_tlf.tlh(52):   error   C2018:   未知字符“0x40”;不支持   unicode   标识符  
  c:\exercise\vctest\Debug\bms_validate_tlf.tlh(52):   error   C2143:   语法错误   :   缺少“;”(在“常数”的前面)  
  c:\exercise\vctest\Debug\bms_validate_tlf.tlh(52):   warning   C4229:   使用了记时错误   :   忽略数据上的修饰符  
  c:\exercise\vctest\Debug\bms_validate_tlf.tlh(52):   error   C2433:   “n_validate::In_validate::postevent”   :   不允许在数据声明中使用“virtual”  
  c:\exercise\vctest\Debug\bms_validate_tlf.tlh(52):   error   C2365:   “n_validate::In_validate::postevent”   :   重定义;以前的定义是“成员函数”  
                  c:\exercise\vctest\Debug\bms_validate_tlf.tlh(46)   :   参见“n_validate::In_validate::postevent”的声明  
  c:\exercise\vctest\Debug\bms_validate_tlf.tlh(55):   error   C2238:   意外的标记位于“;”之前  
   
  以下是生成的.tlh文件:  
  //   Created   by   Microsoft   (R)   C/C++   Compiler   Version   13.00.9466   (0f87ba73).  
  //  
  //   c:\exercise\vctest\debug\bms_validate_tlf.tlh  
  //  
  //   C++   source   equivalent   of   Win32   type   library   h:\bms\validate\bms_validate_tlf.tlb  
  //   compiler-generated   file   created   07/20/02   at   10:00:42   -   DO   NOT   EDIT!  
   
  #pragma   once  
  #pragma   pack(push,   8)  
   
  #include   <comdef.h>  
   
  namespace   n_validate   {  
   
  //  
  //   Forward   references   and   typedefs  
  //  
   
  struct   __declspec(uuid("e56abdae-36b9-46e3-99b5-d4e5149bb2f6"))  
  /*   LIBID   */   __n_validate;  
  struct   __declspec(uuid("4abaf86d-07a2-4839-bc97-5339e9a9463e"))  
  /*   interface   */   In_validate;  
  struct   __declspec(uuid("c003a21c-7b45-425e-9087-f3749800da74"))  
  /*   dispinterface   */   Dn_validate;  
  struct   /*   coclass   */   n_validate;  
   
  //  
  //   Smart   pointer   typedef   declarations  
  //  
   
  _COM_SMARTPTR_TYPEDEF(In_validate,   __uuidof(In_validate));  
  _COM_SMARTPTR_TYPEDEF(Dn_validate,   __uuidof(Dn_validate));  
   
  //  
  //   Type   library   items  
  //  
   
  struct   __declspec(uuid("4abaf86d-07a2-4839-bc97-5339e9a9463e"))  
  In_validate   :   IUnknown  
  {  
          //  
          //   Raw   methods   provided   by   interface  
          //  
   
              virtual   BSTR   __cdecl   classname   (   )   =   0;  
              virtual   VARIANT_BOOL   __cdecl   postevent   (  
                  /**/     )   =   0;  
              virtual   VARIANT_BOOL   __cdecl   postevent@2   (  
                  /**/   ,  
                  /**/   long   w,  
                  /**/   long   l   )   =   0;  
              virtual   VARIANT_BOOL   __cdecl   postevent@3   (  
                  /**/   ,  
                  /**/   long   w,  
                  /**/   BSTR   l   )   =   0;  
              virtual   VARIANT_BOOL   __cdecl   postevent@4   (  
                  /**/   BSTR   e   )   =   0;  
              virtual   VARIANT_BOOL   __cdecl   postevent@5   (  
                  /**/   BSTR   e,  
                  /**/   long   w,  
                  /**/   long   l   )   =   0;  
              virtual   VARIANT_BOOL   __cdecl   postevent@6   (  
                  /**/   BSTR   e,  
                  /**/   long   w,  
                  /**/   BSTR   l   )   =   0;  
              virtual   short   __cdecl   triggerevent   (  
                  /**/     )   =   0;  
              virtual   short   __cdecl   triggerevent@8   (  
                  /**/   ,  
                  /**/   long   w,  
                  /**/   long   l   )   =   0;  
              virtual   short   __cdecl   triggerevent@9   (  
                  /**/   ,  
                  /**/   long   w,  
                  /**/   BSTR   l   )   =   0;  
              virtual   short   __cdecl   triggerevent@10   (  
                  /**/   BSTR   e   )   =   0;  
              virtual   short   __cdecl   triggerevent@11   (  
                  /**/   BSTR   e,  
                  /**/   long   w,  
                  /**/   long   l   )   =   0;  
              virtual   short   __cdecl   triggerevent@12   (  
                  /**/   BSTR   e,  
                  /**/   long   w,  
                  /**/   BSTR   l   )   =   0;  
              virtual     __cdecl   typeof   (   )   =   0;  
              virtual     __cdecl   getparent   (   )   =   0;  
              virtual   short   __cdecl   getcontextservice   (  
                  /**/   BSTR   svcname,  
                  /**/     )   =   0;  
              virtual   VARIANT_BOOL   __cdecl   connecttoora   (   )   =   0;  
              virtual   BSTR   __cdecl   uservalidate   (  
                  /**/   BSTR   ls_user_id,  
                  /**/   BSTR   ls_password,  
                  /**/   BSTR   ls_identity   )   =   0;  
  };  
   
  struct   __declspec(uuid("c003a21c-7b45-425e-9087-f3749800da74"))  
  Dn_validate   :   IDispatch  
  {  
          //  
          //   Wrapper   methods   for   error-handling  
          //  
   
          //   Methods:  
          _bstr_t   classname   (   );  
          //   Method   "postevent"   not   emitted   because   argument   "e"   has   invalid   type:    
          //   Method   "postevent@2"   not   emitted   because   argument   "e"   has   invalid   type:    
          //   Method   "postevent@3"   not   emitted   because   argument   "e"   has   invalid   type:    
          VARIANT_BOOL   postevent@4   (  
                  _bstr_t   e   );  
          VARIANT_BOOL   postevent@5   (  
                  _bstr_t   e,  
                  long   w,  
                  long   l   );  
          VARIANT_BOOL   postevent@6   (  
                  _bstr_t   e,  
                  long   w,  
                  _bstr_t   l   );  
          //   Method   "triggerevent"   not   emitted   because   argument   "e"   has   invalid   type:    
          //   Method   "triggerevent@8"   not   emitted   because   argument   "e"   has   invalid   type:    
          //   Method   "triggerevent@9"   not   emitted   because   argument   "e"   has   invalid   type:    
          short   triggerevent@10   (  
                  _bstr_t   e   );  
          short   triggerevent@11   (  
                  _bstr_t   e,  
                  long   w,  
                  long   l   );  
          short   triggerevent@12   (  
                  _bstr_t   e,  
                  long   w,  
                  _bstr_t   l   );  
          //   Method   "typeof"   not   emitted   because   of   invalid   return   type:    
          //   Method   "getparent"   not   emitted   because   of   invalid   return   type:    
          //   Method   "getcontextservice"   not   emitted   because   argument   "svcobj"   has   invalid   type:     *  
          VARIANT_BOOL   connecttoora   (   );  
          _bstr_t   uservalidate   (  
                  _bstr_t   ls_user_id,  
                  _bstr_t   ls_password,  
                  _bstr_t   ls_identity   );  
  };  
   
  struct   __declspec(uuid("829e4446-5450-408f-b580-20e78f96e358"))  
  n_validate;  
          //     dispinterface   Dn_validate  
          //   interface   In_validate  
   
  //  
  //   Wrapper   method   implementations  
  //  
   
  #include   "c:\exercise\vctest\debug\bms_validate_tlf.tli"  
   
  }   //   namespace   n_validate  
   
  #pragma   pack(pop)  
   
  问题点数:0、回复次数:10Top

1 楼horris(僧推月下门)回复于 2002-07-20 11:53:30 得分 0

试试这个:  
  #import   "h:\bms\validate\bms_validate_tlf.tlb"   no_namespace   named_guids  
  如果有与C/C++语言关键字冲突的标识符,还要加上rename限定词  
  另外,Power   Builder有很多地方作的不标准,比如我记得它做的DLL就不能被别人直接调用.另外它输出TLB时可有一些选项没有设置?Top

2 楼horris(僧推月下门)回复于 2002-07-20 11:56:56 得分 0

VC的#import指令可以导入任何标淮的TLB,不过你的项目设置应该支持CRT和C++   exception,一般来讲都是这样,但在ATL项目中,这两项缺省是关闭的.Top

3 楼Jiemi(Jiemi)回复于 2002-07-20 16:00:26 得分 0

谢谢。  
  好象我已经试过加上#import指令的所有的attribute属性设定了,还是问题依旧,唉Top

4 楼Jiemi(Jiemi)回复于 2002-07-20 17:45:42 得分 0

前辈,再次试过了,不行啊  
   
  我看到msdn里的一篇关于#import指令的文章,得知出现上述语法错误的,多数是因为在导入该类型库前,需要导入另外的某个类型库,可是我的这个生成的tlh文件里没有这个注释提示,如之奈何??Top

5 楼horris(僧推月下门)回复于 2002-07-20 21:41:44 得分 0

用OLE   VIEW能不能打开这个TLB呢?  
  Top

6 楼Jiemi(Jiemi)回复于 2002-07-21 08:52:54 得分 0

可以的。也能保存为IDL或h和c文件。Top

7 楼daehappy(追求120%结贴)回复于 2002-07-21 20:24:09 得分 0

up!gz!Top

8 楼Jiemi(Jiemi)回复于 2002-07-21 22:30:27 得分 0

upTop

责任编辑: efish 参与评论 查找更多:
相关文章
如何解决MFC中,用SetCursor改变光标时的闪烁问题?… 如何解决MFC中,用SetCursor改变光标时的闪烁问题?(在线)
SOS 急救笔记本 急!急!!! SOS 急救笔记本 急!急!!!
请问我这代码有什么问题?老是报什么错!!!! 请问我这代码有什么问题?老是报什么错!!!!
关于自定义函数的应用? 关于自定义函数的应用?
关于盗版Turbo C++3.0的安装问题 关于盗版Turbo C++3.0的安装问题
数据库与程序连接错误?(在线等待) 数据库与程序连接错误?(在线等待)
怎样把dotnetfx做到安装程序里? 怎样把dotnetfx做到安装程序里?
不知CMOS密码又不想清除原有的密码能进入吗? 不知CMOS密码又不想清除原有的密码能进入吗?
vb.net可以在哪些操作系统下运行? vb.net可以在哪些操作系统下运行?
oracle not available的问题! oracle not available的问题!
2秒记住本站域名

玩过泡泡龙吗?Readygo?Go! 再加上.Com.Cn的后缀,那就是大名小顶的readygo.com.cn

分类导航
Readygo技术搜索引擎