I.T. Discussion Community!
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

August Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingDelphi for W...   Print This     
  From the July 2012 Issue of Prestwood eMag
 
Delphi for Win32:
Detecting Windows SafeMode
 
Posted 12 years ago on 3/8/2008 and updated 1/28/2009
Take Away:

Use Windows API GetSystemMetrics with SM_CLEANBOOT parameter to determine how Windows was started.

KB100928

Version Info: Works with Delphi 2 and higher
Category: Win API

 
Description: When Windows is running in Safe Mode, not all resources are available, which can prevent some applications from executing properly. You can detect
 
Use Windows API GetSystemMetrics with SM_CLEANBOOT parameter to determine how Windows was started.


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;

Comments

0 Comments.
Share a thought or comment...
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1135A1
Enter key:
KB Post Contributed By Larry J. Rutledge :
I worked for Prestwood Software as a Delphi developer from 1997 through 2002. During that time I enjoyed working with Mike Prestwood and the other developers at Prestwood.
Visit Profile

 KB Article #100928 Counter
6027
Since 4/2/2008

Follow PrestwoodBoards on: 


©1995-2020 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech