VC头文及输出函数如下:
#ifndef _CTSDLL_H
#define _CTSDLL_H
extern "C" __declspec(dllexport) BOOL WindowShow();#endif其中输出函数extern "C" __declspec(dllexport) BOOL WindowShow();
的功能是显示一个VC的界面(窗体),该界面中用到了线程、Socket等一些知识。用VC调用没问题,可是我在DELPHI中调用就出问题。我在DELPHI中调用如下:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, StdCtrls, Buttons, DB, DBTables;type
TForm1 = class(TForm)
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
function WindowShow():boolean; Stdcall;external 'ctsdll.dll';
implementation{$R *.dfm}procedure TForm1.BitBtn1Click(Sender: TObject);
begin
windowshow();
end;end.
我的目的是想通过DELPHI程序调用CTSDLL.DLL来显示VC做好的界面。可是却出错,错误信息如下:
弹出个对话框,内容是:Debug Assertion Failed!
program:"c:\project1.exe"
file:afxwin1.inl
line:22 for information on how you program can cause an
assertion failure, see the visual c++ documentation on asserts. (press retry to debug the application)
下面是三个"终止"、“重试”、“忽略”。按键后进入了读地址错误。我在DELEPHI里跟踪不到VC程序中去,该怎么办??请指教!
#ifndef _CTSDLL_H
#define _CTSDLL_H
extern "C" __declspec(dllexport) BOOL WindowShow();#endif其中输出函数extern "C" __declspec(dllexport) BOOL WindowShow();
的功能是显示一个VC的界面(窗体),该界面中用到了线程、Socket等一些知识。用VC调用没问题,可是我在DELPHI中调用就出问题。我在DELPHI中调用如下:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, ComCtrls, StdCtrls, Buttons, DB, DBTables;type
TForm1 = class(TForm)
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
function WindowShow():boolean; Stdcall;external 'ctsdll.dll';
implementation{$R *.dfm}procedure TForm1.BitBtn1Click(Sender: TObject);
begin
windowshow();
end;end.
我的目的是想通过DELPHI程序调用CTSDLL.DLL来显示VC做好的界面。可是却出错,错误信息如下:
弹出个对话框,内容是:Debug Assertion Failed!
program:"c:\project1.exe"
file:afxwin1.inl
line:22 for information on how you program can cause an
assertion failure, see the visual c++ documentation on asserts. (press retry to debug the application)
下面是三个"终止"、“重试”、“忽略”。按键后进入了读地址错误。我在DELEPHI里跟踪不到VC程序中去,该怎么办??请指教!
var LibHandle: THandle;
WindowShow: TWindowShow;
begin
LibHandle := SafeLoadLibrary('ctsdll.dll');
if LibHandle > 0 then
try
@WindowShow := GetProcAddress(HInst, 'WindowShow');
if Assigned(@WindowShow) then
WindowShow();
finally
FreeLibrary('ctsdll.dll');
end;
end;
,@WindowShow := GetProcAddress(LibHandle, 'WindowShow');
FreeLibrary(LibHandle);
?把stdcall换成cedcl safecall等看看
最好
把你的Delphi程序给写DLL的人调一下那个DLL看看
我检查了afxwin1.inl这个文件也没有看出所以然来,反正根这个文件和声明有关!
Sorry,没能解决问题,看有没有高手来指导了!