|
Please note that I assume you know how to create Dynamic Link Libraries (DLLs) and you have a basic knowledge of programming.
How to create a TPPS file?
Actually, creating a TPPS file isn't that hard to do. I will explain it in general and then specific for the programming language called Delphi. If you can translate it to any other language, please Mail the developer!
- Create a DLL.
- Place a function called RegisterFunctions in that DLL. This function has a struct called PFunctionPluginInfo as return value.
- Place a procedure called SetProcedure. This procedure should have one parameter: PProc = Pointer.
Please note that the name Pointer can differ in another language. In some languages, Pointers cannot easily be handled.
The contents of these procedures are very short and you'll find an example lateron. The first one: RegisterFunctions will give DirMonitor some information about the Plugin. SetProcedure will make it possible for DirMonitor to pass the necessary information to the Plugin.
Please make sure that you EXPORT these both functions. If you fail to do so, DirMonitor will NOT be able to recognize the Plugin.
Example in Delphi (Pascal)
Here is an example Plugin, written in Delphi.
library FileFunc;
{$E dpf}
uses
DMTPPSTypes,
DMProcInfo;
type
PFunctionPluginInfo = ^TFunctionPluginInfo;
TFunctionPluginInfo = record
Name: string[100];
DescriptionLength: integer;
Description: pChar;
end;
var
Proc: TDMProcInfo;
function RegisterFunctions: PFunctionPluginInfo;
begin
new(Result);
Result^.Name :='File Functions';
Result^.Description :='Functions to manipulate files';
Result^.DescriptionLength :=length(Result^.Description)+1;
end;
procedure SetProcedure( const PProc: Pointer );
begin
Proc :=TDMProcInfo(PProc);
end;
exports
RegisterFunctions,
SetProcedure;
begin
Proc :=nil;
end.
TDMProcInfo is a class, which is declared in the unit called DMProcInfo. This unit needs 3 other units to compile. All these units can be downloaded freely.
In the code you see the line {$E dpf}. This will force the compiler to compile a file with extension dpf instead of dll. Again, this is necessary for DirMonitor!
Not necessary, but safer, please set the Proc variable to nil (deallocate) when the DLL is initiated.
You can now add as many procedures to this DPF File. All procedures you export, apart from RegisterFunctions and SetProcedure will automatically be recognized by DirMonitor. You will even see that the Script Editor will color that new procedure.
How to use TDMProcInfo?
As said, TDMProcInfo is a class. This class is necessary to communicate between your Plugin and DirMonitor and contains all necessary information for that Plugin.
A TDMProcInfo class contains parameters, just like a real procedure. These parameters can be read in the procedures you include in your Plugin.
To get a parameter, all you need to know is the name of that parameter. This way you can get the value stored in that parameter.
For example:
procedure WipeFile;
var
FilePath: string;
begin
FilePath :=Proc.GetParamValue('Path');
WipeFileA( FilePath );
MessageBox( 0,
pChar('File "'+FilePath+'" wiped'),
'Information',
MB_ICONINFORMATION or MB_OK );
end;
This will wipe the file which path was stored in the parameter called Path. A Message Box will be shown after the file's been wiped out.
Thus the only line of code you really need to know about is Proc.GetParamValue('Path');. This will extract the necessary information from that parameter.
More information
I can imagine that it's more difficult for an outsider to understand the way TPPS works. If you like to know more, or you don't understand something on this page, feel free to drop me a line!
Click on one of the chapters to the left of this screen.
|