请大侠指教调用DLL的步骤极其函数说明的方法,多谢

解决方案 »

  1.   

    的先声明pfunc。stcall ......
      

  2.   

    首先定义函数原形
    type TFunc = function (a :string ;b:integer) :integer ;
    然后
    procedure  TForm1.Button1Click(Sender:  TObject);
      var
        pfunc:TFarProc;
        Moudle:THandle;
        ret1:Integer;
        myfun :TFunc ;
      begin
      Moudle:=loadlibrary('C_COMW.DLL');
      if  moudle<  32  then
                              SHowmessage('Load  DLL  Fail')
                    else
                    begin
                    pfunc:=GetProcaddress(moudle,'InitC_COMW');
                  if  pfunc=nil  then
                              ShowMessage('Get  Function  Address  Fail')
                            else
                              begin
                              myfunc := @pfunc ; 
                              ret1:=0;
            ***            ret1:=myfunc('R  PLU.TXT  4  -lo  -d:c_util.ini  -i  -T',1));
                              ShowMessage(IntToStr(ret1));
                            end;
                    end;
      end;
      

  3.   

    to Liujc(阿聪),按您的解释我编译通过拉,但运行时出现异常,好象是地址访问
    出错的问题。我的DLL是用VC++编写的,用DELPHI调用应该没有什么问题把?
    还有就是感谢大家的回复
      

  4.   

    IDispatch = interface(IUnknown)
        ['{00020400-0000-0000-C000-000000000046}']
        function GetTypeInfoCount(out Count: Integer): HResult; stdcall;
        function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;
        function GetIDsOfNames(const IID: TGUID; Names: Pointer;
          NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; stdcall;
        function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
          Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;
      end;
      

  5.   

    IDispatch = interface(IUnknown)
        ['{00020400-0000-0000-C000-000000000046}']
        function GetTypeInfoCount(out Count: Integer): HResult; stdcall;
        function GetTypeInfo(Index, LocaleID: Integer; out TypeInfo): HResult; stdcall;
        function GetIDsOfNames(const IID: TGUID; Names: Pointer;
          NameCount, LocaleID: Integer; DispIDs: Pointer): HResult; stdcall;
        function Invoke(DispID: Integer; const IID: TGUID; LocaleID: Integer;
          Flags: Word; var Params; VarResult, ExcepInfo, ArgErr: Pointer): HResult; stdcall;
      end;
      

  6.   

    taber,你写的那些能解释一二?
      

  7.   

    我到是遇到过这样的问题,如果是在VC下调用没问题。
    用快速查看看一下你的输出函数名是否正确,如果可能在VC中输出函数用C的格式输出。