program CrtApp;
uses
SysUtils, WinTypes, WinProcs, WinCrt;
var
NumInstances, SavePrevInst: word;
procedure GetInstanceData(hInst, Offset, Size: Word); far; external 'KERNEL';
begin
SavePrevInst := hPrevInst;
NumInstances := 0;
while hPrevInst <> 0 do
begin
GetInstanceData(hPrevInst, Ofs(hPrevInst), SizeOf(hPrevInst));
Inc(NumInstances);
end;
Writeln('Уже запущено ', NumInstances, ' копий программы');
hPrevInst := SavePrevInst;
end.
|