灾难性错误,各位大侠,帮帮忙 (100分)

S

sccphi

Unregistered / Unconfirmed
GUEST, unregistred user!
前面提的问题,没有看见DLL是一个注册DLL,不好意思,实际问题如下:
我很少使用DLL,现在有一个项目需要调用别个公司开发的DLL(DLL名为MstDll.DLL),
DLL需要通过RegSvr32注册,我通过RegSvr32注册后(注册后的类有Mst)
但还发现一些问题,希望各位能指点,最好有源码。谢谢!

在DLL中有如下一些:
function Connect(const connstr: WideString): boolean; //连接一个ORACLE数据库
function setcall(BH:Integer;const TS: IStarstr): Integer; //TS为一个IStarstr的变量,其相应的结构见后面

我调用的代码如下:
var s:variant;
msg:string;
connstr: WideString;
begin
CoInitialize(nil);
s:=CreateOleObject('Mstdll.Mst'); //这句执行成功
connstr:='Provider=MSDAORA.1;Password=xz;User ID=xz123;Data Source=dd;Persist Security Info=True'; //这句连接ORACLE数据库测试也没有错
if s.Connect(connstr) then
showmessage('连接数据库成功');

程序在执行 if s.Connect(connstr) then 这一句时就报“灾难性错误”
这是为什么?

 
当然要自己定义变量!!
 
在程序中当然要定义.

定义一个recorde类型的就可以了.
 
recorde类型不能定义procedure
 
IStartStr = interface
['{322F579E-0255-4F53-9DA6-0D932E4C06C5}']//这里写其他公司Dll那个IStartStr接口的GUID
property Count: Integer readonly;
property Items[index: Integer]: Cond readonly
procedure Add(const csd: Cond);
procedure Clear;
procedure Delete(index: Integer);
end;
Cond类似
 
“灾难性错误”:这种提示不象是系统的提示。

很可能你是非法用户,程序判断后抛出的一个异常串。
 
我感觉jsxjd说的对
 
我如果将调用的代码改为如下:
var s:variant;
msg:string;
connstr: WideString;
const a:TGUID='{82F4B242-8A47-46F0-87BD-CCC02AD2D113}';
begin
CoInitialize(nil);
s:=CreateComObject(a); //这句执行成功
connstr:='Provider=MSDAORA.1;Password=xz;User ID=xz123;Data Source=dd;Persist Security Info=True'; //这句连接ORACLE数据库测试也没有错
if s.Connect(connstr) then
showmessage('连接数据库成功');

[red]错误如下[/red]:
程序在执行 if s.Connect(connstr) then 这一句时就又报“variant doesn't reference an automation object”
这是为什么?
 
该对象是 COM 对象,但不支持 Automation
应转换成实际的接口类型!!!
 
请问jsxjd
如何换成实际的接口类型??
谢谢!
 
jsxjd说得对,该对像为com对像,你应该转换成实际的接口类型。
 
如何换成实际的接口类型??
 
我也想知道如何换成实际的接口类型
 
顶部