How to determine Windows startup mode
A simple API call to determine if Windows is currently running in Normal mode, Safe
Mode, or Safe Mode with Network Support.
Declarations
Add the following code to the delarations section of a module Option
Explicit
Public Declare Function GetSystemMetrics Lib "user32" _
(ByVal nIndex As Long) As Long
Public Const SM_CLEANBOOT = 67
Code
Add the
following code to the form containing a label and a command
button: Private Sub
Command1_Click()
Select Case GetSystemMetrics(SM_CLEANBOOT)
Case 1: Label1 = "Safe Mode."
Case 2: Label1 = "Safe Mode with Network support."
Case Else: Label1 = "Windows is running normally."
End Select
End Sub
The constant SM_CLEANBOOT is not documented in the VB4 or VB5 API viewers. Valid return
values for SM_CLEANBOOT are 0 (normal), 1 and 2.
|