EP_MiscGetWatermark
The EP_MiscGetWatermark function returns watermarks contents. To learn more about watermarks, refer to Miscellaneous - Watermark.
Parameters
- ID - the number of the watermark to return;
- WM - a pointer to TWMContent struct. If this parameter is NULL, the function returns the count of watermarks;
- WM.WMType - returns the watermark type;
- WM.Name - a pointer to the buffer to return Name of the watermark to. If it is NULL, NameLen returns the required buffer length;
- WM.NameLen - the size of the buffer for the watermark Name;
- WM.Text - a pointer to the buffer to return Text of the watermark to. If it is NULL, TextLen returns the required buffer length;
- WM.TextLen - the size of the buffer for the watermark Text;
- WM.FileName - a pointer to the buffer to return FileName of the watermark to. If it is NULL, FileNameLen returns the required buffer length;
- WM.FileNameLen - the size of the buffer for the watermark FileName;
- WM.AFile - a pointer to the buffer to return File of the watermark to. If it is NULL, AFileLen returns the required buffer length;
- WM.AFileLen - the size of the buffer for the watermark File;
Return Value
If the function succeeds, the return value is the count of watermarks.
If Name parameter of TWMContent is NULL or the length of the buffer that is placed into NameLen variable is less than required, the function returns the necessary buffer length in the NameLen variable.
If Text parameter of TWMContent is NULL or the length of the buffer that is placed into TextLen variable is less than required, the function returns the necessary buffer length in the TextLen variable.
If FileName parameter of TWMContent is NULL or the length of the buffer that is placed into FileNameLen variable is less than required, the function returns the necessary buffer length in the FileNameLen variable.
If AFile parameter of TWMContent is NULL or the length of the buffer that is placed into AFileLen variable is less than required, the function returns the necessary buffer length in the AFileLen variable.
If the function fails, the return value is 0.
Remark
The function fails in the following cases:
- no watermarks in the protected file;
- the application is not protected.
Definition
Show/Hide C++ function definition
extern "C" __declspec( dllexport ) __stdcall int EP_MiscGetWatermark( int ID, PWMContent WM );
Show/Hide Delphi function definition
function EP_MiscGetWatermark(ID : integer; WM : PWMContent) : integer; stdcall;
Show/Hide Visual Basic function definition
Public Declare Function EP_MiscGetWatermark Lib "enigma_ide.dll" (ByVal ID As Long, ByVal WM As TWMContent) As Long
Show/Hide C# (.NET) function definition
public class Enigma_IDE
{
[DllImport("enigma_ide.dll", CallingConvention = CallingConvention.StdCall)]
public static extern Int32 EP_MiscGetWatermark(Int32 ID, TWMContent WM);
}
Examples
Show/Hide Delphi function example
uses
enigma_ide;
procedure TForm1.FormShow(Sender: TObject);
var
i : integer;
wmc : TWMContent;
begin
for i := 0 to EP_MiscGetWatermark(0, nil) - 1 do
begin
ZeroMemory(@wmc, sizeof(wmc));
EP_MiscGetWatermark(i, @wmc);
GetMem(wmc.Name, wmc.NameLen + 1);
ZeroMemory(wmc.Name, wmc.NameLen + 1);
GetMem(wmc.Text, wmc.TextLen + 1);
ZeroMemory(wmc.Text, wmc.TextLen + 1);
GetMem(wmc.FileName, wmc.FileNameLen + 1);
ZeroMemory(wmc.FileName, wmc.FileNameLen + 1);
wmc.AFileLen := 0;
EP_MiscGetWatermark(i, @wmc);
with ListView1.Items.Add do
begin
Indent := i;
Caption := IntToStr(i);
if wmc.WMType = WM_PUBLIC then
SubItems.Add('PUBLIC')
else
SubItems.Add('PRIVATE');
if strlen(wmc.Name) > 0 then
SubItems.Add(wmc.Name)
else
SubItems.Add('');
if strlen(wmc.Text) > 0 then
SubItems.Add(wmc.Text)
else
SubItems.Add('');
if strlen(wmc.FileName) > 0 then
SubItems.Add(wmc.FileName)
else
SubItems.Add('');
end;
FreeMem(wmc.FileName);
FreeMem(wmc.Text);
FreeMem(wmc.Name);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
fs : TFileStream;
wmc : TWMContent;
begin
if ListView1.Selected = nil then Exit;
if ListView1.Selected.Indent >= EP_MiscGetWatermark(0, nil) then Exit;
ZeroMemory(@wmc, sizeof(wmc));
EP_MiscGetWatermark(ListView1.Selected.Indent, @wmc);
wmc.NameLen := 0;
wmc.Text := 0;
GetMem(wmc.FileName, wmc.FileNameLen + 1);
ZeroMemory(wmc.FileName, wmc.FileNameLen + 1);
GetMem(wmc.AFile, wmc.AFileLen);
EP_MiscGetWatermark(ListView1.Selected.Indent, @wmc);
SaveDialog1.FileName := wmc.FileName;
SaveDialog1.DefaultExt := ExtractFileExt(wmc.FileName);
if SaveDialog1.Execute then
begin
try
fs := TFileStream.Create(SaveDialog1.FileName, fmCreate);
fs.Write(wmc.AFile^, wmc.AFileLen);
finally
fs.Free;
end;
end;
FreeMem(wmc.AFile);
FreeMem(wmc.FileName);
end;
See function examples in the installation folder, Examples\Watermarks subfolder.