Foren: Forum of Decimal BASIC (Thread #40695)

a problems with calling delphi 7 DLL (2019-04-29 16:19 by eros #82904)

Hi
(the examples tested in windows 7 and windows xp)
i have tried to call a DLL made by delphi 7
this is the DLL from page https://hp.vector.co.jp/authors/VA008683/MakeDLL.htm

library Sample4;

uses
Math;

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
(Letztes Update: 2019-04-30 05:11 by eros)

Reply to #82904×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden

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
Reply to #82904

Reply to #82905×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Anmelden