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程序中去,该怎么办??请指教!

解决方案 »

  1.   

    如果你用显式调用dll试试呢?
      

  2.   

    to juliens(星星球) :怎么用显式调用呢?请指教!
      

  3.   

    type TWindowShow = function():boolean; Stdcall;  //在interface部分定义procedure TForm1.BitBtn1Click(Sender: TObject);
    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;
      

  4.   

    老大,@WindowShow := GetProcAddress(HInst, 'WindowShow');这句编译出错啊!!!
      

  5.   

    不好意思:
    ,@WindowShow := GetProcAddress(LibHandle, 'WindowShow');
      

  6.   

    to juliens(星星球):非常谢谢您,但结果还是和以前不是显式调用dll一样的错误,请老大再想想,帮帮我吧,很急!!
      

  7.   

    那估计就不是你的程序问题了,可能是dll本身的问题,或者提供的头文件有错误!
      

  8.   

    这一句也写错了:
    FreeLibrary(LibHandle);
      

  9.   

    VC的DLL是你写的?还是别人写的
    ?把stdcall换成cedcl safecall等看看
    最好
    把你的Delphi程序给写DLL的人调一下那个DLL看看
      

  10.   

    to ThenLong(完美组合=Delphi/C++): dll是我自己写的,我用VC调没问题
      

  11.   

    另外,我的DLL又另调了好几个其它的DLL,我都把他们放在DELPHI的执行程序目录下,但出口函数只有WindowShow()一个。
      

  12.   

    试了一下,根你出现同样的错误,但是可以肯定的是C++代码中有问题,因为跳出的错误提示窗口不是Delphi的,你是用MFC开发窗体的吧!还是检查一下C++中有哪些代码不符合dll创建规范,我用过其他一下C++ dll,都没有此种情况!
    我检查了afxwin1.inl这个文件也没有看出所以然来,反正根这个文件和声明有关!
    Sorry,没能解决问题,看有没有高手来指导了!