📄 getsys.dpr
字号:
Writeline('DHCP IP : ',FOREGROUND_SILVER,StringReplace(Adapter[i].DHCP_IPAddress.CommaText,'"','',[rfReplaceAll,rfIgnoreCase]),FOREGROUND_OLIVE);
Writeline('Primary WINS server : ',FOREGROUND_SILVER,StringReplace(Adapter[i].PrimaryWINS_IPAddress.CommaText,'"','',[rfReplaceAll,rfIgnoreCase]),FOREGROUND_OLIVE);
Writeline('Secondary WINS server: ',FOREGROUND_SILVER,StringReplace(Adapter[i].SecondaryWINS_IPAddress.CommaText,'"','',[rfReplaceAll,rfIgnoreCase]),FOREGROUND_OLIVE);
separator;
end;
end;
except
on e: exception do begin
SetConsoleTextAttribute(hConsole, FOREGROUND_RED or FOREGROUND_INTENSITY);
writeln(e.message);
SetConsoleTextAttribute(hConsole, FOREGROUND_SILVER);
end;
end;
finally
end;
end;
procedure ListProc;
var
i: Integer;
begin
try
try
SetConsoleTextAttribute(hConsole, FOREGROUND_WHITE or BACKGROUND_INTENSITY);
Write('PROCESSES...');
with TMiTeC_ProcessList.Create(nil) do begin
DetectionRange:=[dtProcesses];
RefreshData;
Write(Format('%d items',[ProcessCount]));
GetConsoleScreenBufferInfo(hConsole,ScreenBuffer);
Write(StringOfChar(#32,ScreenBuffer.dwSize.X-ScreenBuffer.dwCursorPosition.X-1));
SetConsoleTextAttribute(hConsole, FOREGROUND_SILVER);
writeln;
if IsNT then begin
SetConsoleTextAttribute(hConsole, FOREGROUND_YELLOW);
Writeln(Format('%-45s %-4s %-9s %9s %8s',['Image name','PID','CPU time','Mem usage','Priority']));
SetConsoleTextAttribute(hConsole, FOREGROUND_SILVER);
Separator;
for i:=0 to ProcessCount-1 do
with Processes[i] do
Writeln(Format('%-45.45s %4d %9s %8dK %8d',[Name,
PID,
FormatSeconds((UserTime.QuadPart+KernelTime.QuadPart)/10000000,True,False,True),
VMCounters.WorkingSetSize div 1024,
Priority]));
end else begin
SetConsoleTextAttribute(hConsole, FOREGROUND_YELLOW);
Writeln(Format('%49s %10s %9s %8s',['Image name','PID','Usage','Priority']));
SetConsoleTextAttribute(hConsole, FOREGROUND_SILVER);
Separator;
for i:=0 to ProcessCount-1 do
with Processes[i] do
Writeln(Format('%49.49s 0x%8x %9d %8d',[Name,
PID,
Usage,
Priority]));
end;
Free;
end;
except
on e: exception do begin
SetConsoleTextAttribute(hConsole, FOREGROUND_RED or FOREGROUND_INTENSITY);
writeln(e.message);
SetConsoleTextAttribute(hConsole, FOREGROUND_SILVER);
end;
end;
finally
Separator;
end;
end;
procedure ListDevs;
var
i: Integer;
s: string;
begin
try
try
SetConsoleTextAttribute(hConsole, FOREGROUND_WHITE or BACKGROUND_INTENSITY);
Write('DEVICES...');
with TMSIC_Console.Create([soDevices]) do begin
RefreshData;
Write(Format('%d items',[Devices.DeviceCount]));
GetConsoleScreenBufferInfo(hConsole,ScreenBuffer);
Write(StringOfChar(#32,ScreenBuffer.dwSize.X-ScreenBuffer.dwCursorPosition.X-1));
SetConsoleTextAttribute(hConsole, FOREGROUND_SILVER);
writeln;
SetConsoleTextAttribute(hConsole, FOREGROUND_YELLOW);
Writeln(Format('%-14.14s %-63.63s',['Class name','Device Name']));
Separator;
for i:=0 to Devices.DeviceCount-1 do
with Devices.Devices[i] do begin
if Trim(FriendlyName)='' then
s:=Description
else
s:=FriendlyName;
Writeln(Format('%-14.14s %-63.63s',[ClassName,s]));
end;
Free;
end;
except
on e: exception do begin
SetConsoleTextAttribute(hConsole, FOREGROUND_RED or FOREGROUND_INTENSITY);
writeln(e.message);
SetConsoleTextAttribute(hConsole, FOREGROUND_SILVER);
end;
end;
finally
Separator;
end;
end;
procedure ListAccs;
var
i: Integer;
sl: TStringList;
begin
sl:=TStringList.Create;
try
try
SetConsoleTextAttribute(hConsole, FOREGROUND_WHITE or BACKGROUND_INTENSITY);
Write('LOCAL ACCOUNTS...');
with TAccounts.Create do begin
Machine:=MachineName;
RefreshUsers;
RefreshLocalGroups;
Write(Format('%d+%d=%d items',[UserCount,LocalGroupCount,UserCount+LocalGroupCount]));
GetConsoleScreenBufferInfo(hConsole,ScreenBuffer);
Write(StringOfChar(#32,ScreenBuffer.dwSize.X-ScreenBuffer.dwCursorPosition.X-1));
SetConsoleTextAttribute(hConsole, FOREGROUND_SILVER);
writeln;
for i:=0 to UserCount-1 do
with Users[i]^ do begin
WriteLine ('Name : ',FOREGROUND_SILVER,Name,FOREGROUND_YELLOW);
Writeln(Format('Comment : %s',[Comment]));
Writeln(Format('Domain : %s',[Domain]));
Writeln(Format('SID type : %s',[GetNameUseStr(SidType)]));
Writeln(Format('SID : %s',[SID]));
Writeln(Format('Last logon: %s',[DateTimeToStr(LastLogon)]));
Writeln(Format('Last logoff: %s',[DateTimeToStr(LastLogoff)]));
Separator;
end;
for i:=0 to LocalGroupCount-1 do
with LocalGroups[i]^ do begin
GetLocalGroupUsers(MachineName,Name,sl);
WriteLine ('Name : ',FOREGROUND_SILVER,Name,FOREGROUND_GREEN or FOREGROUND_INTENSITY);
Writeln(Format('Comment : %s',[Comment]));
Writeln(Format('Domain : %s',[Domain]));
Writeln(Format('SID type: %s',[GetNameUseStr(SidType)]));
Writeln(Format('SID : %s',[SID]));
Writeln(Format('Members : %s',[sl.CommaText]));
Separator;
end;
Free;
end;
except
on e: exception do begin
SetConsoleTextAttribute(hConsole, FOREGROUND_RED or FOREGROUND_INTENSITY);
writeln(e.message);
SetConsoleTextAttribute(hConsole, FOREGROUND_SILVER);
end;
end;
finally
sl.Free;
end;
end;
procedure SaveXML;
var
sl: TStringList;
s: string;
MSIC: TMSIC_Console;
begin
MSIC:=TMSIC_Console.Create(soAll);
try
with MSIC do begin
sl:=TStringList.Create;
try
try
if not Switch('sm') then
Write('GENERATING XML REPORT...');
RefreshData;
Console_XML_Report(MSIC,sl);
s:=SavePath+MachineName+'.xml';
sl.SaveToFile(s);
SaveXSLTemplate(SavePath+XSLName);
if not Switch('sm') then begin
Writeln('OK');
Writeln;
Writeln('XML report saved to '+s);
end;
except
on e: exception do begin
SetConsoleTextAttribute(hConsole, FOREGROUND_RED or FOREGROUND_INTENSITY);
if not Switch('sm') then
writeln(e.message);
SetConsoleTextAttribute(hConsole, FOREGROUND_SILVER);
end;
end;
finally
sl.Free;
end;
end;
finally
MSIC.Free;
end;
Writeln;
end;
procedure SaveData;
var
s: string;
MSIC: TMSIC_Console;
begin
MSIC:=TMSIC_Console.Create(soAll);
try
with MSIC do begin
try
try
if not Switch('sm') then
Write('SAVING DATA...');
ProcessList.DetectionRange:=[dtProcesses, dtServices, dtDrivers];
RefreshData;
s:=SavePath+MachineName+'.sis';
SaveToStorage(s,'');
if not Switch('sm') then begin
Writeln('OK');
Writeln;
Writeln('Data saved to '+s);
end;
except
on e: exception do begin
SetConsoleTextAttribute(hConsole, FOREGROUND_RED or FOREGROUND_INTENSITY);
if not Switch('sm') then
writeln(e.message);
SetConsoleTextAttribute(hConsole, FOREGROUND_SILVER);
end;
end;
finally
end;
end;
finally
MSIC.Free;
end;
Writeln;
end;
procedure ConvertSIS2XML(AFilename: string);
var
sl: TStringList;
s: string;
MSIC: TMSIC_Console;
begin
MSIC:=TMSIC_Console.Create(soAll);
try
with MSIC do begin
sl:=TStringList.Create;
try
try
Write('CONVERTING FILE...');
LoadFromStorage(AFilename);
Console_XML_Report(MSIC,sl);
s:=ChangeFileExt(AFilename,'.xml');
sl.SaveToFile(s);
Writeln('OK');
Writeln;
Writeln('Report saved to '+s);
except
on e: exception do begin
SetConsoleTextAttribute(hConsole, FOREGROUND_RED or FOREGROUND_INTENSITY);
writeln(e.message);
SetConsoleTextAttribute(hConsole, FOREGROUND_SILVER);
end;
end;
finally
sl.Free;
end;
end;
finally
MSIC.Free;
end;
Writeln;
end;
procedure Help;
begin
Writeln;
Writeln('Usage: GetSys [/?][/so][/lp][/ls][/ld][/lt][/xml][/sis][/w][/s][/p:path]');
Writeln;
Writeln('Parameters: /? ......... ..this screen');
Writeln(' /so .......... system overview');
Writeln(' /lp .......... list running processes');
Writeln(' /la .......... list local accounts (NT only)');
Writeln(' /ld .......... list installed devices');
Writeln(' /lt .......... list TCP/IP configuration');
Writeln(' /xml.......... save data to XML file');
Writeln(' /sis.......... save data to storage file');
Writeln(' /s2x:file .... load storage file and save it as XML');
Writeln(' /p:path....... set path for file saving');
Writeln(' /w .......... wait for key press before exit');
Writeln(' /sm .......... silent mode for /sis or /xml switch');
Writeln;
Writeln('Example: getsysinfo /sis /sm /p:c:\0 ... saves SIS file to c:\0 with no message');
end;
var
i,p: Integer;
s: string;
begin
SavePath:=ExtractFilePath(ParamStr(0));
hConsole:=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_CYAN);
if not Switch('sm') then
Writeln(Format('MiTeC System Information Utility %s - %s',[cVersion,cCopyright]));
SetConsoleTextAttribute(hConsole, FOREGROUND_SILVER);
if not Switch('?') then begin
if not Switch('sm') then begin
Writeln('Type /? for options');
writeln;
end;
for i:=1 to ParamCount do begin
s:=LowerCase(ParamStr(i));
p:=Pos('-p:',s);
if p=0 then
p:=Pos('/p:',s);
if p>0 then
SavePath:=IncludeTrailingPathDelimiter(Copy(ParamStr(i),p+3,255));
end;
for i:=1 to ParamCount do begin
s:=LowerCase(ParamStr(i));
p:=Pos('-s2x:',s);
if p=0 then
p:=Pos('/s2x:',s);
if p>0 then
ConvertSIS2XML(Copy(ParamStr(i),p+5,255));
end;
if (ParamCount=0) or Switch('so') or ((ParamCount=1) and Switch('w')) then
SystemOverview;
if Switch('lp') then
ListProc;
if Switch('la') and IsNT then
ListAccs;
if Switch('ld') then
ListDevs;
if Switch('lt') then
ListTCPIP;
if Switch('xml') then
SaveXML;
if Switch('sis') then
SaveData;
if Switch('w') then begin
if not Switch('sm') then begin
Writeln('');
WriteLn('Press [Enter] to exit...');
end;
ReadLn;
end;
end else
Help;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -