Issue #140: Store application process id in each tabs.ini section, and don't restore tabs from other running processes. If the process no longer runs, restore such tab sections again, so nothing gets lost with multiple running application instances.

This commit is contained in:
Ansgar Becker
2019-04-13 10:43:52 +02:00
parent e9cc528632
commit a2ef1aeccd
2 changed files with 39 additions and 3 deletions

View File

@ -359,6 +359,7 @@ type
function DpiScaleFactor(Form: TForm): Double;
function GetThemeColor(Color: TColor): TColor;
function ThemeIsDark(ThemeName: String): Boolean;
function ProcessExists(pid: Cardinal): Boolean;
var
AppSettings: TAppSettings;
@ -3010,6 +3011,26 @@ begin
end;
function ProcessExists(pid: Cardinal): Boolean;
var
Proc: TProcessEntry32;
SnapShot: THandle;
ContinueLoop: Boolean;
begin
// Check if a given process id exists
SnapShot := CreateToolhelp32Snapshot(TH32CS_SnapProcess, 0);
Proc.dwSize := Sizeof(Proc);
Result := False;
ContinueLoop := Process32First(SnapShot, Proc);
while ContinueLoop do begin
Result := Proc.th32ProcessID = pid;
if Result then
Break;
ContinueLoop := Process32Next(SnapShot, Proc);
end;
CloseHandle(Snapshot);
end;
{ Threading stuff }