Hello,
Version 6.5.2
I want customers to be able to call a DLL from a script.
Reading the user manual, including the current version user manual, I am confused.
The goal is to allow the user to place all the DLL function defines in one script, execute the script once, on program start and now the DLL defines are in the scripter engine for all other scripts to access. That does not seem to work.
It appears every script must include the DLL defines that the script needs.
Am I missing something?
Regards,
Mark
Thanks
I will give the SelfRegisterAsLibrary a go.
Using the example from the user manual:
function MessageBox(hwnd: pointer; text, caption: string; msgtype: integer): integer; stdcall; external 'User32.dll' name 'MessageBoxA';
in a script.
I tried SelfRegisterAsLibrary(engine) and it complied without error.
In another script:
MessageBox(null,'text','caption',0); <-OK
MessageBoxA(null,'text','caption',0); <-Failed compile
I used SelfRegisterAsLibrary(engine, 'CustomDLL') and it complied without error.
In another script:
CustomDLL.MessageBox(null,'text','caption',0); <-Failed compile
CustomDLL.MessageBoxA(null,'text','caption',0); <-Failed compile
All is expect. MessageBoxA would never be found because it's not a function in script. You just declared MessageBox.
function _MessageBox(hwnd: pointer; text, caption: AnsiString; msgtype: integer): integer;
stdcall; external 'User32.dll' name 'MessageBoxA';
function MessageBox(hwnd: pointer; text, caption: AnsiString; msgtype: integer): integer;
begin
Result := _MessageBox(hwnd, text, caption, msgtype);
end;
OK.
The user manual and the source comments are cloudy on both issues.
function SelfRegisterAsLibrary(AScripter: TatCustomScripter; AName: string = '')
: TatScripterLibrary; overload;
...
///...automatically compiled. If AName is not empty, the methods and variables can also be accessible prefixed with the AName, for example: MyLibrary.MyMethod;
CustomDLL.MessageBox should work according to the above comment.
Ok, we will make it clearer in the manual.