Back


Lennie's Weekly Tip : What's the Boot?

07 November 1999 Ref. 03
-------------------------------------------------------

Sometimes you may need to find out how Windows had started. Let's say you write a device-driver, but you don't what it to run when Windows is in "Safe-Mode" (because it may cause problems, etc) then you can use the following function:

function BootMode : integer;

begin
   Result := GetSystemMetrics(SM_CLEANBOOT);
end; {BootMode}
 

Remember : To add the "ShellAPI" unit to your applications' uses-clause.

This function will return an integer-value that determined how Windows has started.

Values Return :
-------------------

0 - Normal boot
1 - Fail-safe boot
2 - Fail-safe with network boot

Fail-safe boot (also called Safe-Boot) bypasses the user's startup files (pressing F5 when Windows is starting).
 

You can use this function in a case..of statement, like this :

case (BootMode) of
0 : ShowMessage('Normal Boot');
1 : ShowMessage('Fail-safe boot (Safe-Mode)');
2 : ShowMessage('Fail-safe with network boot'); // Only if your running
a network.
else
  ShowMessage('ERROR: Unable to retreve Windows'' Boot-Mode');
end; {case}


Back