
| Subject: | Delphi 2009 & C Dll |
| Posted by: | execretor execretor |
| Date: | Mon, 27 Apr 2009 |
I have a dll with this function
extern "C"{
__declspec(dllexport)double GetValue(char *funzione, double incognita);
}
This is my delphi code
procedure TfrmMain.TracciaAssi();
var
str: string;
addr: Pointer;
res: Double;
val: Double;
proc: function(funzione: Pointer; incognita: Double):
Double cdecl {$IFDEF WIN32} stdcall {$ENDIF};
DLLHandle: THandle;
begin
with desktop do
begin
Canvas.MoveTo(0, round(frmMain.Height/ 2) - 25);
Canvas.LineTo(frmMain.Width, round(frmMain.Height/ 2) - 25);
Canvas.MoveTo(round(frmMain.Width/ 2), 0);
Canvas.LineTo(round(frmMain.Width/ 2), frmMain.Height);
str:= 'sinx';
val:= 1;
res:=0;
addr:= @str;
DLLHandle:= LoadLibrary('RpNotation.dll');
if DLLHandle <> 0 then
begin
@proc:= GetProcAddress(DLLHandle, 'GetValue');
if Assigned(proc) then
begin
res:= proc(addr,val);
end
else
MessageBox(0,'Errore','Errore',0);
end;
end;
end;
In this way I have an access error
I see that 'funzione' get a "s" value instead "sinx"
How can I do?