function Test(p:PChar; m:integer):integer; stdcall;
var
i,n:integer;
s:string;
begin
s:='Hello';
n:=Min(length(s),m);
for i:=1 to n do
p[i-1]:=s[i];
Test:=n;
end;
exports Test;
end.
using decimal basic 7.8.5.3 it is succesfuly calling the dll and displaying 'hello'
OPTION CHARACTER BYTE
FUNCTION TEST(s$, m)
ASSIGN "Sample4.dll", "Test"
END FUNCTION
LET m = 32
LET s$ = REPEAT$("#", m)
LET n = TEST(s$, m)
LET a$ = s$(1: n)
PRINT a$
END
but using decimal basic v8.0.1.6 i get the error msg:
syntax error at line 3
Sample4.dll could not be loaded
but if we call windows api to print the current directory using v8.0.1.6
DECLARE EXTERNAL FUNCTION CurrDir$
PRINT CurrDir$
END
EXTERNAL FUNCTION CurrDir$
OPTION CHARACTER BYTE
FUNCTION GetCurrentDirectory(n,s$)
ASSIGN "kernel32.dll","GetCurrentDirectoryA"
END FUNCTION
LET s$=Repeat$(" ", 200)
LET n=GetCurrentDirectory(200,s$)
LET CurrDir$=s$(1:n)
END FUNCTION
it will work
the strange thing if we keep the decimal basic ide open and opening the first exmple to call delphi dll, now it will work and display 'hello'. it will work until we close the IDE and run it again then calling the delphi dll will fail
Thanks
best regards
Re: a problems with calling delphi 7 DLL (2019-04-30 05:13 by eros #82905)
i have found the solution: for decimal basic v8.0.1.6 we must specify the exact path to the DLL
such as: "c:\test\Sample4.dll"
or better:
ASK DIRECTORY t$
LET t$=t$ & "\" & "Sample4.dll"
FUNCTION TEST (s$, m)
ASSIGN t$, "Test"
END FUNCTION