Delphi调用VB写的Com问题,提示“没有注册类别”

lzg827 2012-04-16 12:08:45
先说问题吧。
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,有类似经验的朋友帮帮忙,可能就某个地方设置错了,或者代码哪些错了,多谢~~



...全文
949 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lzg827 2012-04-16
  • 打赏
  • 举报
回复
导入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}
interface

uses 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;

implementation

uses 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.
onlyou13 2012-04-16
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]

最新进展,发现是注册的问题。
因为我本地的路径里面带空格,所以执行regsvr32 时,后面的路径需要用""。。。。
多么苦逼的问题。。。。
应该问题不大了。
我再继续试试,有其他问题我再说~~~
[/Quote] 这个是个问题,在有些情况下中文的路径也会有些莫名其妙的问题,解决了就好
lzg827 2012-04-16
  • 打赏
  • 举报
回复
最新进展,发现是注册的问题。
因为我本地的路径里面带空格,所以执行regsvr32 时,后面的路径需要用""。。。。
多么苦逼的问题。。。。
应该问题不大了。
我再继续试试,有其他问题我再说~~~
lzg827 2012-04-16
  • 打赏
  • 举报
回复
有这两个方法。
我是用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
onlyou13 2012-04-16
  • 打赏
  • 举报
回复
用 Dependency walker工具看下DLL有没有 DllregisterServer, dllunregisterServer两个方法,
如果 没有就是DLl本身的问题,不能注册
lzg827 2012-04-16
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]
有没有注册 DLL

regsvr32 xxx.dll

在程序中用api shellexcute 执行 上面的dos命令
[/Quote]
试过,Dll无法注册。
提供Dll的朋友告诉我 不是所有的Com都需要注册。。。
谁能告诉我还能怎么调用???
onlyou13 2012-04-16
  • 打赏
  • 举报
回复
有没有注册 DLL

regsvr32 xxx.dll

在程序中用api shellexcute 执行 上面的dos命令

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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