Use Windows API GetSystemMetrics with SM_CLEANBOOT parameter, this specifies how the system was started, in your project´s code use:
program Project1;
uses
Forms,
Windows,
Dialogs,
Unit1 in 'Unit1.pas' {Form1};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
case GetSystemMetrics(SM_CLEANBOOT) of
1: begin
ShowMessage('Running in Safe Mode: Fail-Safe Boot');
Application.Terminate;
end;
2: begin
ShowMessage('Running in Safe Mode: Fail-safe with network boot');
Application.Terminate;
end;
end;
Application.Run;
end.
program Project1;
uses
Forms,
Windows,
Dialogs,
Unit1 in 'Unit1.pas' {Form1};
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
case GetSystemMetrics(SM_CLEANBOOT) of
1: begin
ShowMessage('Running in Safe Mode: Fail-Safe Boot');
Application.Terminate;
end;
2: begin
ShowMessage('Running in Safe Mode: Fail-safe with network boot');
Application.Terminate;
end;
end;
Application.Run;
end.
博客介绍了在项目代码中使用Windows API的GetSystemMetrics函数和SM_CLEANBOOT参数来检测系统启动模式。通过该函数返回值判断系统是否以安全模式启动,若为特定安全模式则终止应用程序运行。

被折叠的 条评论
为什么被折叠?



