procedure Tfrmstationbm.Button1Click(Sender: TObject);
var
  pfunc:tfarproc;
  Moudle:Thandle;
  stmn:string;
begin
  moudle:=loadlibrary('c:\catvtogggl\dll\DBFile.dll');
  if moudle>32 then
  begin
     pfunc:=getprocaddress(moudle,'GetAttachFile');
     pfunc(...//这样试试
  end;
  freelibrary(moudle);
end;

解决方案 »

  1.   

    加入GetAttachFile(con, TableName, ID ,imageLB_path);应该就可以.
      

  2.   

    不行,提示出错!指到pfunc(....
    [Error] stationbm.pas(654): Missing operator or semicolon
      

  3.   

    还是不行
    [Error] stationbm.pas(656): Undeclared identifier: 'GetAttachFile'
      

  4.   

    更正:是pfunc( );还有,你确定是调用有问题,会不会是你的函数内部出错。
      

  5.   

    上面的错误是没有uses相应的单元的原因
      

  6.   

    我的dll文件是用VB写的,在asp中调用,dll应该没问题。请各位帮我想想,我急用!!!谢谢!
      

  7.   

    可以这样嘛:type
       youfunc = function GetAttachFile(con, TableName, ID ,imageLB_path):boolean;stdcall;....
    ....
    procedure Tfrmstationbm.Button1Click(Sender: TObject);
    var
      pfunc:youfunc;
      Moudle:Thandle;
      stmn:string;
    begin
      moudle:=loadlibrary('c:\catvtogggl\dll\DBFile.dll');
      if moudle>32 then
      begin
         pfunc:=getprocaddress(moudle,'GetAttachFile');
         pfunc(...//这样试试
      end;
      freelibrary(moudle);
    end;
      

  8.   

    请问上面这位朋友,按照你的方法,编译已经通过,但是执行时出错,如下:
    Project gggl.exe raised exception class EAccessViolation with message 
    'Access violation at address 00000000.Read of address 00000000',process
    stopped.Use Step or Run to continue.
     
     是不是没有分配内存空间,如何分配呢?
    还是其他的原因,麻烦帮我看看!谢谢!!!
      

  9.   

    可以这样嘛:type
       youfunc = function GetAttachFile(con, TableName, ID ,imageLB_path):boolean;stdcall;....
    ....
    procedure Tfrmstationbm.Button1Click(Sender: TObject);
    var
      pfunc:youfunc;
      Moudle:Thandle;
      stmn:string;
    begin
      moudle:=loadlibrary('c:\catvtogggl\dll\DBFile.dll');
      if moudle>32 then
      begin
         pfunc:=getprocaddress(moudle,'GetAttachFile');
         pfunc(...//这样试试
      end;
      freelibrary(moudle);
    end;
    按照这种方法,编译已经通过,但是执行时出错,如下:
    Project gggl.exe raised exception class EAccessViolation with message 
    'Access violation at address 00000000.Read of address 00000000',process
    stopped.Use Step or Run to continue.
     
     是不是没有分配内存空间,如何分配呢?
    还是其他的原因,麻烦帮我看看!谢谢!!!
      

  10.   

    type
       youfunc = function GetAttachFile(con, TableName, ID ,imageLB_path):boolean;stdcall;....
    ....
    procedure Tfrmstationbm.Button1Click(Sender: TObject);
    var
      pfunc:youfunc;
      Moudle:Thandle;
      stmn:string;
    begin
      moudle:=loadlibrary('c:\catvtogggl\dll\DBFile.dll');
      if moudle>32 then
      begin
         @pfunc:=getprocaddress(moudle,'GetAttachFile');//这里少了一个@
         pfunc(...//这样试试
      end;
      freelibrary(moudle);
    end;
      

  11.   

    兄弟是不是在delphi里面调用呀?
      

  12.   

    还是提示这个错误啊!
    Project gggl.exe raised exception class EAccessViolation with message 
    'Access violation at address 00000000.Read of address 00000000',process
    stopped.Use Step or Run to continue.  这个dll(DBFile.dll)文件是用vb写的。是不是delphi写的dll与vb写的dll不同的调用吗?
      

  13.   

    帮帮我!
    这个是vb源程序Public Function GetAttachFile(ConnectionStr As String, TableSource As String, RecID As String, AttachDir As String) As String
    Dim Con As New ADODB.Connection
    Dim Rec As New ADODB.Recordset
    Dim PAttachDir As String
    Dim FileNameSize As Integer
    Dim FileSize As Long
    Dim FileName As String
    Dim ExSize As Long, AcSize As Long
    Dim Buffer() As Byte
    Dim TableName As String
         
         Con.Open ConnectionStr
         PAttachDir = Trim(AttachDir)
         If Right(PAttachDir, 1) = "\" Then PAttachDir = Mid(PAttachDir, 1, Len(PAttachDir) - 1)
         TableName = GetFrom(TableSource)
         On Error Resume Next
           MkDir PAttachDir
           DelDir PAttachDir
           MkDir PAttachDir
         On Error GoTo 0     Rec.Open "Select f_Attach From " & TableName & " Where ID=" & RecID, Con
         If Rec.EOF Then Rec.Close: Set Rec = Nothing: Exit Function
      
         ExSize = 0
         AcSize = Rec("f_Attach").ActualSize
         
         Do While ExSize < AcSize
           FileNameSize = Val(Rec("f_Attach").GetChunk(8) & "")
           Debug.Assert FileNameSize <> 0
           FileName = Rec("f_Attach").GetChunk(FileNameSize)
           FileSize = Val(Rec("f_Attach").GetChunk(32))
           ReDim Buffer(FileSize - 1)
           Buffer = Rec("f_Attach").GetChunk(FileSize)
           ExSize = ExSize + 8 + 32 + FileNameSize + FileSize
           m_Files.Add FileName
           
           On Error GoTo ERR1
           Open PAttachDir & "\" & FileName For Binary Access Write As #1
           On Error GoTo 0
           
           Put 1, 1, Buffer
           Close 1
      
         Loop
         Set Rec = Nothing
         Set Con = Nothing
        GetAttachFile = ConnectionStr
        Exit Function
    ERR1:
       GetAttachFile = Err.Description & "Path:" & PAttachDir & "\" & FileName
    End Function做成dll文件在delphi中如何调用啊!
      
    那位朋友能帮我把它用delphi写这个函数呢?(字段里的内容是长二进制数据)
      

  14.   

    请问
      type
       youfunc = function GetAttachFile(con, TableName, ID ,imageLB_path):boolean;stdcall;....
    ....
    procedure Tfrmstationbm.Button1Click(Sender: TObject);
    var
      pfunc:youfunc;
      Moudle:Thandle;
      stmn:string;
    begin
      moudle:=loadlibrary('c:\catvtogggl\dll\DBFile.dll');
      if moudle>32 then
      begin
         @pfunc:=getprocaddress(moudle,'GetAttachFile');//这里少了一个@
         pfunc(...//这样试试
      end;
      freelibrary(moudle);
    end;
      我发现moudle=nil 但是c:\catvtogggl\dll\DBFile.dll 文件存在啊!这是什么原因呢?