先说问题吧。
Delphi调用VB写的Com,试了一上午了,未果。
我的编译环境 Delphi 2006,在Component -->Import Component -->Import Active Control 导入了这个DLL。
调用就两行代码
var
  ss:_RTPnr;
begin
  ss := CoRTPnr.Create;  //这里就报错了,提示“没有注册类别”
  ss.RTPNRcontent('sfsdf','fdsf');
end;详细报错如下:
“---------------------------
Project2
---------------------------
没有注册类别, ClassID: {2B763A43-5916-4176-A3C5-6A52EDBA3A91}.
---------------------------如果我用Regsvr32 RetrievePNR.dll
提示不能注册 LoadLibrary("RetrievePNR.dll") 失败 - 找不到指定的模块。
提供Dll的朋友告诉我 不是所有的Com都需要注册可是他又不太懂Delphi,有类似经验的朋友帮帮忙,可能就某个地方设置错了,或者代码哪些错了,多谢~~

解决方案 »

  1.   

    导入Dll后生成的文件如下unit RetrievePnr_TLB;// ************************************************************************ //
    // WARNING                                                                    
    // -------                                                                    
    // The types declared in this file were generated from data read from a       
    // Type Library. If this type library is explicitly or indirectly (via        
    // another type library referring to this type library) re-imported, or the   
    // 'Refresh' command of the Type Library Editor activated while editing the   
    // Type Library, the contents of this file will be regenerated and all        
    // manual modifications will be lost.                                         
    // ************************************************************************ //// PASTLWTR : 1.2
    // File generated on 2012-4-16 11:42:29 from Type Library described below.// ************************************************************************  //
    // Type Lib: D:\Work On\InterTicket\TestDLL\Bin\RetrievePnr.dll (1)
    // LIBID: {96C1E224-A271-4062-8532-D189B1A777B9}
    // LCID: 0
    // Helpfile: 
    // HelpString: 
    // DepndLst: 
    //   (1) v2.0 stdole, (C:\WINDOWS\system32\stdole2.tlb)
    // ************************************************************************ //
    {$TYPEDADDRESS OFF} // Unit must be compiled without type-checked pointers. 
    {$WARN SYMBOL_PLATFORM OFF}
    {$WRITEABLECONST ON}
    {$VARPROPSETTER ON}
    interfaceuses Windows, ActiveX, Classes, Graphics, OleServer, StdVCL, Variants;
      // *********************************************************************//
    // GUIDS declared in the TypeLibrary. Following prefixes are used:        
    //   Type Libraries     : LIBID_xxxx                                      
    //   CoClasses          : CLASS_xxxx                                      
    //   DISPInterfaces     : DIID_xxxx                                       
    //   Non-DISP interfaces: IID_xxxx                                        
    // *********************************************************************//
    const
      // TypeLibrary Major and minor versions
      RetrievePnrMajorVersion = 24;
      RetrievePnrMinorVersion = 0;  LIBID_RetrievePnr: TGUID = '{96C1E224-A271-4062-8532-D189B1A777B9}';  IID__RTPnr: TGUID = '{E55F8694-AFE7-46F7-86D5-6B5B64B93831}';
      CLASS_RTPnr: TGUID = '{2B763A43-5916-4176-A3C5-6A52EDBA3A91}';
    type// *********************************************************************//
    // Forward declaration of types defined in TypeLibrary                    
    // *********************************************************************//
      _RTPnr = interface;
      _RTPnrDisp = dispinterface;// *********************************************************************//
    // Declaration of CoClasses defined in Type Library                       
    // (NOTE: Here we map each CoClass to its Default Interface)              
    // *********************************************************************//
      RTPnr = _RTPnr;
    // *********************************************************************//
    // Declaration of structures, unions and aliases.                         
    // *********************************************************************//
      PNRcontent = packed record
        pnrcode: WideString;
        Pnrtext: WideString;
        Faretext: WideString;
        PaxName: PSafeArray;
        Carrier: PSafeArray;
        FlightNO: PSafeArray;
        SubClass: PSafeArray;
        OrigPort: PSafeArray;
        OrigDate: PSafeArray;
        OrigTime: PSafeArray;
        DestPort: PSafeArray;
        DestDate: PSafeArray;
        DestTime: PSafeArray;
        Status: PSafeArray;
      end;
    // *********************************************************************//
    // Interface: _RTPnr
    // Flags:     (4560) Hidden Dual NonExtensible OleAutomation Dispatchable
    // GUID:      {E55F8694-AFE7-46F7-86D5-6B5B64B93831}
    // *********************************************************************//
      _RTPnr = interface(IDispatch)
        ['{E55F8694-AFE7-46F7-86D5-6B5B64B93831}']
        function RTPNRcontent(const amaPNR: WideString; const JiString: WideString): PNRcontent; safecall;
      end;// *********************************************************************//
    // DispIntf:  _RTPnrDisp
    // Flags:     (4560) Hidden Dual NonExtensible OleAutomation Dispatchable
    // GUID:      {E55F8694-AFE7-46F7-86D5-6B5B64B93831}
    // *********************************************************************//
      _RTPnrDisp = dispinterface
        ['{E55F8694-AFE7-46F7-86D5-6B5B64B93831}']
        function RTPNRcontent(const amaPNR: WideString; const JiString: WideString): {??PNRcontent}OleVariant; dispid 1610809344;
      end;// *********************************************************************//
    // The Class CoRTPnr provides a Create and CreateRemote method to          
    // create instances of the default interface _RTPnr exposed by              
    // the CoClass RTPnr. The functions are intended to be used by             
    // clients wishing to automate the CoClass objects exposed by the         
    // server of this typelibrary.                                            
    // *********************************************************************//
      CoRTPnr = class
        class function Create: _RTPnr;
        class function CreateRemote(const MachineName: string): _RTPnr;
      end;implementationuses ComObj;class function CoRTPnr.Create: _RTPnr;
    begin
      Result := CreateComObject(CLASS_RTPnr) as _RTPnr;
    end;class function CoRTPnr.CreateRemote(const MachineName: string): _RTPnr;
    begin
      Result := CreateRemoteComObject(MachineName, CLASS_RTPnr) as _RTPnr;
    end;end.
      

  2.   

     有没有注册 DLLregsvr32 xxx.dll在程序中用api  shellexcute 执行 上面的dos命令
      

  3.   

    试过,Dll无法注册。
    提供Dll的朋友告诉我 不是所有的Com都需要注册
    谁能告诉我还能怎么调用???
      

  4.   

    用 Dependency walker工具看下DLL有没有 DllregisterServer, dllunregisterServer两个方法,
    如果 没有就是DLl本身的问题,不能注册
      

  5.   

    有这两个方法。
    我是用dllexp.exe查看的,结果如下
    Function Name Address Relative Address Ordinal Filename Full Path Type
    DllUnregisterServer 0x11001d00 0x00001d00 4 (0x4) RetrievePnr.dll D:\RetrievePnr.dll Exported Function
    DllRegisterServer 0x11001d2c 0x00001d2c 3 (0x3) RetrievePnr.dll D:\RetrievePnr.dll Exported Function
    DllGetClassObject 0x11001d16 0x00001d16 2 (0x2) RetrievePnr.dll D:\RetrievePnr.dll Exported Function
    DllCanUnloadNow 0x11001d42 0x00001d42 1 (0x1) RetrievePnr.dll D:\RetrievePnr.dll Exported Function
    _RTPnr::RTPNRcontent 1610809344 (0x60030000) RetrievePnr.dll D:\RetrievePnr.dll COM Method
      

  6.   

    最新进展,发现是注册的问题。
    因为我本地的路径里面带空格,所以执行regsvr32 时,后面的路径需要用""。
    多么苦逼的问题。
    应该问题不大了。
    我再继续试试,有其他问题我再说~~~