有个dll(应该是用vc做的),我要在delphi 6调用,但始终出错,请各位看看毛病在哪?
函数说明(vc调用例程里的)
extern "C" __declspec(dllexport) bool _stdcall OpenDataBase(HWND hMainWnd); //打开数据源 返回true 成功 返回false 失败我的调用程序如下:
type
TFunc =function(hMainWnd:hwnd):boolean;Cdecl;
var
th:Thandle;
Tf:TFunc;
Tp:TFarProc;
begin
th:=LoadLibrary('CXK.dll'); {load dll}
if(th>0) then
try
Tp :=GetProcAddress(th,PChar('OpenDataBase'));
if(Tp <>nil) then
begin
Tf :=TFunc(Tp);
if Tf(th) then
ShowMessage('ok.');
end
else
ShowMessage('function not found.');
finally
FreeLibrary(th);
end;
函数打开了,但程序运行完毕后弹出一个消息框:access violation at 0x00d537ff:write of address 0x0000001c.哪的问题????
函数说明(vc调用例程里的)
extern "C" __declspec(dllexport) bool _stdcall OpenDataBase(HWND hMainWnd); //打开数据源 返回true 成功 返回false 失败我的调用程序如下:
type
TFunc =function(hMainWnd:hwnd):boolean;Cdecl;
var
th:Thandle;
Tf:TFunc;
Tp:TFarProc;
begin
th:=LoadLibrary('CXK.dll'); {load dll}
if(th>0) then
try
Tp :=GetProcAddress(th,PChar('OpenDataBase'));
if(Tp <>nil) then
begin
Tf :=TFunc(Tp);
if Tf(th) then
ShowMessage('ok.');
end
else
ShowMessage('function not found.');
finally
FreeLibrary(th);
end;
函数打开了,但程序运行完毕后弹出一个消息框:access violation at 0x00d537ff:write of address 0x0000001c.哪的问题????
解决方案 »
- TreeView1.Selected.Delete 后 PopupMenu弹不出来 有点好几次右键才出来 这是啥回事?
- 希望大家推进一到两个有良好编程风格的C/S代码来学习一下.
- 新手求助:关于webservices的问题(就剩20分了,全给了)
- 急~!提示Undeclared identifier: 'loPartialKey'这是为什么呀?
- 那位高手讲讲CGI????
- TQery.open之后,如果知道是否查到符合条件的记录?
- 200分求InstallShield的注册码(急!!!!!!!1)
- 在两个不同代理服务器后面的局域网机器之间传递文件--有哪位朋友愿意试一下
- 请问Form运行时各事件的执行顺序是怎样的啊?
- 如何在运行时动态生成一个可见的控件?
- CHART控件,高手请进!~~ 急~
- 没分了,帮个忙吧,小问题
TFunc =function(hMainWnd:hwnd):boolean;stdcall;var
th:Thandle;
Tf:TFunc;
begin
th:=LoadLibrary('CXK.dll'); {load dll}
if(th>0) then
try
@Tf :=GetProcAddress(th,PChar('OpenDataBase'));
if Assigned(@tf) then
begin
if Tf(th) then
ShowMessage('ok.');
end
else
ShowMessage('function not found.');
finally
FreeLibrary(th);
end;
TFunc =function(hMainWnd:hwnd):boolean;stdcall;var
th:Thandle;
Tf:TFunc;
begin
th:=LoadLibrary('CXK.dll'); {load dll}
if(th>0) then
try
@Tf :=GetProcAddress(th,PChar('OpenDataBase'));
if Assigned(@tf) then
begin
if Tf(^^^^^^^^) then //这里应该给hMainWnd赋值,直接赋值th是不是不合适?
ShowMessage('ok.');
end
else
ShowMessage('function not found.');
finally
FreeLibrary(th);
end;