Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Delphi]Some Snippets

Featured Replies

Posted

returns a process base (CSTR) priority by a process ID, takes care of the low-level part

function GetProcessPri(PID: DWORD): String;
var
hSnap: THandle;
lppe: TProcessEntry32A;
szPri: String;
begin
lppe.dwSize := sizeof(lppe);
hSnap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);if Process32FirstA(hSnap, lppe) <> False then
With lppe Do begin
if PID = lppe.th32ProcessID then
case lppe.pcPriClassBase of
13:szPri := 'High';
8,9, 11:szPri := 'Normal';
6:szPri := 'Below Normal';
4:szPri := 'Low';
end;
while Process32NextA(hSnap, lppe) do
if PID = lppe.th32ProcessID then
case lppe.pcPriClassBase of
13:szPri := 'High';
8,9, 11:szPri := 'Normal';
6:szPri := 'Below Normal';
4:szPri := 'Low';
end;
end;
CloseHandle(hSnap);
Result := szPri;
end;

Returns process name by process ID

function GetPNameByPid(PID: DWORD): String;
var
hSnap: THandle;
lppe: TProcessEntry32A;
szPName: String;
begin
lppe.dwSize := sizeof(lppe);
hSnap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);if Process32FirstA(hSnap, lppe) <> False then
With lppe Do begin
if th32ProcessID = PID then szPName := szExeFile;
while Process32NextA(hSnap, lppe) do
if th32ProcessID = PID then szPName := szExeFile;
end;
CloseHandle(hSnap);
Result := szPName;
end;

Gets a process ID by the ID of the process (useful to return parent process)

function TForm1.GetPidByPid(PID: DWORD): DWORD;
var
hSnap: THandle;
lppe: TProcessEntry32A;
dwPID: DWORD;
begin
dwPID := 0; //initializing the variable
lppe.dwSize := sizeof(lppe);
hSnap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);if Process32FirstA(hSnap, lppe) <> False then
With lppe Do begin
if th32ProcessID = PID then dwPID := th32ProcessID;
while Process32NextA(hSnap, lppe) do
if th32ProcessID = PID then dwPID := th32ProcessID;
end;
Result := dwPID;
end;

Returns process ID by process name (CSTR)

function TForm1.GetPidByPName(Selected_Process: String): DWORD;
var
hSnap: THandle;
lppe: TProcessEntry32A;
dwPID: DWORD;
begin
dwPID := 0; //initializing the variable
lppe.dwSize := sizeof(lppe);
hSnap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);if Process32FirstA(hSnap, lppe) <> False then
begin
if lppe.szExeFile = Selected_Process then dwPID := lppe.th32ProcessID;
while Process32NextA(hSnap, lppe) do
if lppe.szExeFile = Selected_Process then dwPID := lppe.th32ProcessID;
end;
Result := dwPID;
end;

thanks rot1, always nice to see someone contribute delphi snippets...

Im still waiting to see your search and replacee snippets in delphi :)

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.