I am needing to create a custom DLL in Delphi7 that can be called from within Macro Scheduler using the LibFunc> method.
My first attempt causes LibFunc> to produce an access violation and lock up Macro Scheduler.
Can someone who as done this post the Delphi source code for a very simple example to get me started on the right track?
Marcus?
Thanks.
Creating Delphi 7 DLL callable by LibFunc
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Make sure it is StdCall.
DLLs do not fail gracefully. Any slight error in the way you call it can lead to nasty errors.
Make sure it's stdcall, stick to simple integers and character pointers (NOT strings - use pchar).
Here's a simple Delphi DLL:
And here's the MacroScript code to use it:
This demonstrates passing a string to the DLL, passing an integer, getting back an integer result and also passing back a string via an output buffer.
Hope this helps.
DLLs do not fail gracefully. Any slight error in the way you call it can lead to nasty errors.
Make sure it's stdcall, stick to simple integers and character pointers (NOT strings - use pchar).
Here's a simple Delphi DLL:
Code: Select all
library simple_dll;
uses
SysUtils, dialogs,
Classes;
{$R *.res}
Function MyFunction(somestring: pansichar; anumber: integer; outputbuffer: pansichar): integer; stdcall;
begin
ShowMessage(somestring);
StrPCopy(outputbuffer,'boo');
result := anumber * 5;
end;
exports MyFunction name 'MyFunction';
end.
Code: Select all
Let>dll=C:\...\simple_dll.dll
Let>buffer_SIZE=255
LibFunc>dll,MyFunction,res,Hello World,4,buffer
Hope this helps.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?