Author: Jorge Abel Ayala Marentes
Sometimes an application uses resources that doesn´t exist when windows is running
in SafeMode, so how do you detect this situation?
Answer:
Use Windows API GetSystemMetrics with SM_CLEANBOOT parameter, this specifies how
the system was started, in your project´s code use:
1 program Project1;
2 3 uses4 Forms,
5 Windows,
6 Dialogs,
7 Unit1 in 'Unit1.pas' {Form1};
8 9 {$R *.RES}10 11 begin12 Application.Initialize;
13 Application.CreateForm(TForm1, Form1);
14 15 case GetSystemMetrics(SM_CLEANBOOT) of16 1:
17 begin18 ShowMessage('Running in Safe Mode: Fail-Safe Boot');
19 Application.Terminate;
20 end;
21 2:
22 begin23 ShowMessage('Running in Safe Mode: Fail-safe with network boot');
24 Application.Terminate;
25 end;
26 end;
27 28 Application.Run;
29 end.
This way you can prevent the user to use your application and avoid havoc!