convert some code from Delphi
Posted: Fri Jan 20, 2012 10:55 am
Hi, All!
i need to write small plugin for old delphi program.
in the docs i found an example:
i rewrote it so:
I turned this plugin on. and got a message saying that we have found two new functions through loading this plugin.
but the program was unable to find the function names.
I think the problem is that I realized the wrong line for "FunctionNames : Array of Pchar;".
please give me advice - how i can rewrite this code right?
sourcecode for delphi program is unavaible
thank you for your attention.
i need to write small plugin for old delphi program.
in the docs i found an example:
Code: Select all
library Plugin;
uses windows;
type
tInitStruct = packed record
FunctionCount : Cardinal;
FunctionNames : Array of Pchar;
End;
var
InitStruct : tInitStruct; // init by plugin, free on unload
function InitPlugin(App, Scr: integer; Var Version: Real):Pointer ; stdcall;
// App: Application.Handle of UOPilot
// Scr: reserved
begin
// exported function count, For UOPilot
InitStruct.FunctionCount := 2;
setlength (InitStruct.FunctionNames, InitStruct.FunctionCount);
// exported function names
InitStruct.FunctionNames[0] := 'Function1';
InitStruct.FunctionNames[1] := 'Function2';
Result := @InitStruct;
End;
Procedure DonePlugin; stdcall;
begin
// free memory
setlength (InitStruct.FunctionNames, 0);
End;
// exported function example
function Function1(AdressPS: Pointer): boolean ; stdcall;
begin
Result := false;
End;
function Function2(AdressPS: Pointer): boolean ; stdcall;
begin
Result := true;
End;
Exports
InitPlugin,
DonePlugin,
Function1,
Function2;
begin
End.
Code: Select all
Structure tInitStruct
FunctionCount.l
FunctionNames.s[2]
EndStructure
Global InitStruct.tInitStruct
ProcedureDLL.l InitPlugin(App.l, Scr.l, Version.f)
InitStruct\FunctionCount = 2;
InitStruct\FunctionNames[0] = "Function1"
InitStruct\FunctionNames[1] = "Function2"
ProcedureReturn @InitStruct
EndProcedure
ProcedureDLL DonePlugin()
InitStruct\FunctionCount = 0
EndProcedure;
ProcedureDLL.b Function1(AdressPS.l)
ProcedureReturn true
EndProcedure;
ProcedureDLL.b Function2(AdressPS.l)
ProcedureReturn false;
EndProcedure;
but the program was unable to find the function names.
I think the problem is that I realized the wrong line for "FunctionNames : Array of Pchar;".
please give me advice - how i can rewrite this code right?
sourcecode for delphi program is unavaible

thank you for your attention.