We don't display ads so we rely on your Bitcoin donations to 1KWEk9QaiJb2NwP5YFmR24LyUBa4JyuKqZ
Post date: Mar 16, 2010 2:58:22 PM
Overview:
Uses
tlhelp32
var
lclCurrProc: TProcessEntry32;
lclPrntProc: TProcessEntry32;
lclSnapHndl: THandle;
lclEXEName: String;
lclPrntName: String;
begin
// Grab the snap shot of the current Process List
lclSnapHndl := CreateToolHelp32SnapShot(TH32CS_SNAPALL, 0);
// Save the name of your executable
lclEXEName := ExtractFileName(Application.ExeName);
// you must define the size of these structures.
lclCurrProc.dwSize := SizeOf(TProcessEntry32);
lclPrntProc.dwSize := SizeOf(TProcessEntry32);
// find current process
Process32First(lclSnapHndl, lclCurrProc);
repeat
if lclCurrProc.szExeFile = lclEXEName then
Break;
until (not Process32Next(lclSnapHndl, lclCurrProc));
// find parent process
Process32First(lclSnapHndl, lclPrntProc);
repeat
if lclPrntProc.th32ProcessID = lclCurrProc.th32ParentProcessID then
Break;
until (not Process32Next(lclSnapHndl, lclPrntProc));
lclPrntName := lclPrntProc.szExeFile;
if AnsiCompareText(lclPrntName, 'Delphi32.exe') = 0 then
ShowMessage('Inside Delphi')
else
ShowMessage('NOT Inside Delphi');
end;