Writing a DLL with delphi
Hello,
I need help for writing a DLL, which checks, if a Process is running. Actually I have the following source, but it is wrong! I hope anyone of you can tell me where the mistake is!?
library Process;
uses
nsis,
Windows,
SysUtils,
Classes,
TLHelp32;
{$R *.RES}
function CheckProcess(const hwndParent: HWND; const string_size: integer;
const variables: PChar; const stacktop: pointer):Integer; cdecl;
var
hSnap: THandle;
ProcEntry: TProcessEntry32;
s,erg: String;
sl : TStringList;
i : Integer;
begin
// set up global variables
Init(hwndParent, string_size, variables, stacktop);
GetUserVariable(INST_0);
hSnap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnap <> INVALID_HANDLE_VALUE) then
begin
sl := TStringList.Create;
ProcEntry.dwSize := SizeOf(ProcessEntry32);
if (Process32First(hSnap, ProcEntry)) then
begin
s := ProcEntry.szExeFile;
sl.Add(UPPERCASE(ExtractFileName(s)));
while Process32Next(hSnap, ProcEntry) do
begin
s := ProcEntry.szExeFile;
sl.Add(UPPERCASE(ExtractFileName(s)));
end;
end;
end;
for i:=0 to sl.Count-1 do
if UPPERCASE(INST_0) = UPPERCASE(sl.Strings[i]) then
//--> at this comparison is one of the mistakes,
//becuase INST_0 is not a String
erg := '1'
else
erg := '0';
CloseHandle(hSnap);
sl.free;
PushString(erg);
SetUserVariable(INST_0, erg);
end;
exports
CheckProcess;
begin
end.
I hope you can help me! Please do not say, that I should use the Plugin, which is posted here in the forum, because I tried it and it doesn't function. Thats why I decided to wrote my own Plug-In!
Thank you!
raveolution
P.S.: I am sorry, if my english is not the best!
:rolleyes: