Re:MS Access calling a Delphi DLL function
In article <3413DC4E.7...@beca.co.nz>, marchb...@beca.co.nz says...
Quote
>I am trying to call a FileOpenDialog in the Delphi 2 DLL by clicking on
>a Command button in Access 7. I am paaing one parameter, the initial
>directory, and return the filename, both as strings. The FileOpenDialog
>appears okay but the parameter values are not passing correctly even
>though I use the PChar type in the Delphi DLL.Are there any
>freeware/shareware code examples of MS Access 7 sending and receiving
>strings variables to a Delphi DLL?
>Thank you
>Malcolm Archbold, Auckland,NZ (first newsgroup posting)
First excuse me for my poor english.
I have found an inelegant way to pass and get string parameters between VB
and Delphi 2 DLL's.
Here is the Dll's function :
Function Traitestring(A:Pchar;B:Pchar):Pchar;
(*
VB declaration:
Declare function Traitestring Lib "Test" (Byval A as string,Byval B as
string) as string
*)
(*
VB Use:
Dim A As String
Dim B As String
Dim C As String
A = Trim$(Forms![Form1]![StrA])
B = Trim$(Forms![Form1]![StrB])
C = Trim$(Traitestring(A, B))
C = Mid$(C, 1, Len(C) - 5)
'The last fifth caracters returned are unusable !
Forms![Form1]![StrB] = C
*)
var
tmp1,tmp2,tmp3,tmp4:string;
l:integer;
p,q:Pchar;
begin
tmp1:=StrPas(A);
tmp2:=StrPas(B);
tmp3:=tmp1+tmp2;
l:=length(tmp3);
Result:=StrAlloc(l+1);
p:=StrAlloc(l+1);
strPcopy(Result,tmp3);
(*
This function returns the concatenation of A and B
*)
end;
Think to declare your function in the beginning of your delphi unit :
function Traitestring(A:Pchar;B:Pchar):Pchar;export;stdcall;
Finally, I also want to write a Delphi Dll wich would give to my Excel
programs a FileOpenDialog form.
I'd like to get your project code !
Thank's