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;
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;
[Error] stationbm.pas(654): Missing operator or semicolon
[Error] stationbm.pas(656): Undeclared identifier: 'GetAttachFile'
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.
是不是没有分配内存空间,如何分配呢?
还是其他的原因,麻烦帮我看看!谢谢!!!
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.
是不是没有分配内存空间,如何分配呢?
还是其他的原因,麻烦帮我看看!谢谢!!!
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. 这个dll(DBFile.dll)文件是用vb写的。是不是delphi写的dll与vb写的dll不同的调用吗?
这个是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写这个函数呢?(字段里的内容是长二进制数据)
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 文件存在啊!这是什么原因呢?