フォーラム: Forum of Decimal BASIC (スレッド #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
(最終更新: 2019-04-30 05:11 by eros)

メッセージ #82904 への返信×

Wiki文法は使えません
ログインしていません。投稿を区別するために投稿者のニックネームをつけてください(ニックネームの一意性は保証されません。全く別の人も同じ名前を利用することが可能ですので本人であることの特定には利用できません。本人であることを保証したい場合にはログインして投稿を行なってください)。 ログインする

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
#82904 への返信

メッセージ #82905 への返信×

Wiki文法は使えません
ログインしていません。投稿を区別するために投稿者のニックネームをつけてください(ニックネームの一意性は保証されません。全く別の人も同じ名前を利用することが可能ですので本人であることの特定には利用できません。本人であることを保証したい場合にはログインして投稿を行なってください)。 ログインする