procedure TForm1.BitBtn5Click(Sender: TObject);
var
     iret:boolean;
     libhandle:thandle;
begin
     libhandle:=loadlibrary('smeidll.dll');
     iret:=ifinitinterface(3,1,'ip,port,5000');
     if iret then
          messagedlg('系统初始化成功!',mtInformation,[mbOK],0)
     else messagedlg('系统初始化失败!请再试!',mtWarning,[mbCancel],0);

解决方案 »

  1.   


      ifinitinterface 是你的DLL里的函数吗?  动态调用DLL函数不是这样用的!  要先定义:Type
      Tifinitinterface=function(A:integer;B:integer;C:string);var
      Myifinitinterface:Tifinitinterface;//Function
    var
        iret:boolean;
        libhandle:thandle;
    begin
      libhandle:= LoadLibrary('smeidll.dll');
      if libhandle>= 32 then
      Begin
        @Myifinitinterface:= GetProcAddress( libhandle, 'ifinitinterface');
        If @Myifinitinterface<> nil Then {or If Assigned(Myifinitinterface) then }
        Begin
          Myifinitinterface(3,1,'ip,port,5000');
          FreeLibrary(libhandle);
        end;
      end;
    end;
      

  2.   


      如果解决了,就加点分,把帖子结了吧!  若还有能帮忙的问题,可以 Email:  [email protected].
      

  3.   

    Type
      Tifinitinterface=function(A:integer;B:integer;C:string);阿明大哥,程序提示以上这句有问题,你看看吧!
      

  4.   


      上面好象有点小错!Type
      Tifinitinterface=function(A:integer;B:integer;C:string):Boolean; //少返回值  //具体的形式要看你原来函数的定义
      

  5.   


      实际情况我看不到!  找段文章给你!10.DLL (动态库}
       10.1 DLL 特徵
         project 使用之单元是采静态连结(Statically Linked),而DLLs 采动态连结
                 (Dynamically Linked),故Projectl 中并包含DDLs之拷贝
         DLLs 可用任何遵守windows DLL 之开发工具来开发或使用,适合多种开发工具
         同时开发环境
       10.2 DLL 使用
          (1) 藉由名称(循序寻找)
              Procedure ImportByName; External 'TestLib.dll';
          (2) 藉由重新名称
              Procedure ImportByNewName;
                        External 'TestLib.dll' name 'ImportByName';
          (3) 藉由序号(找到程式的最快方法)
              Procedure ImportByOrdName;
                        External 'TestLib.dll' Index 1;
          (4) Windows Api 之呼叫
              Function MessageBox( Hwnd: Integer ; Text,Caption:Pchr
                                   Flags:Integer):Integer;Stdcall;
                                   External 'User32.dll' Name 'MessageBox';
          (5)动态库之输入程式单元
             (例-1):Delphi 之开发环境中之 uses windows
             (例-2):
                 unit DateTime;{动态库之输入程式单元}
                 interface
                 type
                  TTimeRec = Record
                     ss : integer;
                     mi : Integer;
                     hh : Integer;
                  end;
                 type
                  TDateRec = Record
                     yy:Integer;
                     mm:Integer;
                     dd:Integer;
                  end;
                 Procedure SetTime(Var Time:TTimeRec);
                 Procedure GetTime(Var Time:TTimeRec);
                 Procedure SetDate(Var Date:TDateRec);
                 Procedure GetDate(Var Date:TDateRec);
                 Implementation
                 Procedure SetTime; External 'DATETIME' index 1;
                 Procedure GetTime; External 'DATETIME' index 2;
                 Procedure SetDate; External 'DATETIME' index 3;
                 Procedure GetDate; External 'DATETIME' index 4;
                 end;
                 ------------------------------------------------------
                 program ShowTime; {呼叫程式}
                 uses WinCrt , DateTime;
                 var
                   Time : TtimeRec;
                 begin
                   GetTime(Time);
                   With Time Do
                     WriteLn( 'Time is',hh,':',mi,':',ss);
                 end;
                 -----------------------------------------------------
          (6)DDLs 之动态使用
             program ShowTime;
             uses WinProcs , WinTypesWinCrt;
             type
              TTimeRec = Record
                 ss : integer;
                 mi : Integer;
                 hh : Integer;
              end;
             TGETTime = Procedure( var Time : TTimeRec );
             Var
               Time : TTimeRec;
               Handle : THandle;
               GetTime : TGetTime;
             Begin
               Handle := LoadLibrary('DATETIME.DLL');
               if Handle >= 32 then
                  Begin
                  @GetTime := GetProcAddress( Handle , 'GETTIME' );
                  If @GetTime <> nil Then {or If Assigned(GetTime) then }
                     Begin
                     GetTime(Time)
                     With Time do
                          WriteLn('Time is ',hh,':',mi,':',ss);
                     end;
                  FreeLibrary(handle);
                  end;
             end.
       10.3 DDLs 之撰写
          10.3.1 例子
             library minmax;
             function Min( X , Y : Integer ) : Integer;
                                               StdCall;
               {避免非Delphi之程式呼叫,没有支援 register 呼叫惯例(内定值)}
             Begin
               If X < Y Then Min := X
               else Min := Y;
             end;
             function Max( X , Y : Integer ) : Integer;StdCall;
             Begin
               If X > Y Then Max := X
               else Max := Y;
             end;
             exports
               Min index 1 name Min Resident;
               Max index 2 name Max Resident;
             Begin
             end.
      

  6.   


      我这样都能编译通过,你比较比较(就一个Form,一个Button):unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
      Tifinitinterface=function(A:integer;B:integer;C:string):Boolean;var
      Form1: TForm1;
      Myifinitinterface:Tifinitinterface;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    //Function
    var
        iret:boolean;
        libhandle:thandle;
    begin
      libhandle:= LoadLibrary('smeidll.dll');
      if libhandle>= 32 then
      Begin
        @Myifinitinterface:= GetProcAddress( libhandle, 'ifinitinterface');
        If @Myifinitinterface<> nil Then {or If Assigned(Myifinitinterface) then }
        Begin
          Myifinitinterface(3,1,'ip,port,5000');
          FreeLibrary(libhandle);
        end;
      end;
    end;
    end.
      

  7.   

    谢谢了,阿明大哥,是我将位置放错了,再问你一下,对于由C++开发的DLL中的函数,用你的方法调用是不是也是一样的啊?我现在要做的就是要调人别人提供给我的DLL中的二十多个函数的,
      

  8.   


      只要是标准的DLL输出,应该没问题,要注意的是数据类型的匹配问题。比如,使用这些DLL的字符串参数时应使用widestring、Pchar、PwideChar、OleString等类型。直接用string类型会带来许多麻烦。又如,在标准的自动化对象使用longint参数时,Delphi中应使用const i:integer,而当其使用*longint时,Delphi中使用var i:integer等等。
      

  9.   

    是吗!谢谢了!
    还有你对于用DELPHI编通信程序,有什么好的建议吗,能告诉我吗
      

  10.   

    阿明大哥,用你的
    libhandle:= LoadLibrary('smeidll.dll');
         if libhandle>= 32 then
         Begin
           @Myifinitinterface:= GetProcAddress( libhandle, 'ifinitinterface');
           addr:=@myifinitinterface;
           If addr<> nil Then
    后,addr总是为nil啊,能告诉我这其中的原因吗?
      

  11.   


      能不能把你手头的东西都发过来?DLL文件(若有源码也附上吧)及说明文档、你的调用程序代码,我调一调试试。
      

  12.   

    在DELPHI中用QUERY1。SQL.Add('select send_rate,message_state FROM tab_message where message_state=0 group by send_rate order by send_rate desc,mes_id asc');执行这个SQL语句时,提示‘TABLE IS READ ONLY’请问是怎么回事啊,我用的是MYSQL数据库,该语句在MYSQL中执行没问题的啊
      

  13.   

    用静态调用吧,Delphi调用VC写的Dll动态调用时会有问题,用静态调用就好了。如果是Delphi写的Dll用Delphi的exe动态调用的话就没问题。可能是内部Dll的声明方式不同。比如function dllfunc() : boolStdCall; External 'your.dll';