Visual Basic Screen & System Metrics
GetSystemMetrics: Determine Windows Start-up Mode
     
Posted:   Sunday February 16, 1998
Updated:   Monday December 26, 2011
     
Applies to:   VB4-32, VB5, VB6
Developed with:   VB5, Windows 95
OS restrictions:   None
Author:   VBnet - Randy Birch
     
 Prerequisites
None.

A simple API call to determine if Windows is currently running in Normal mode, Safe Mode, or Safe Mode with Network Support.
 BAS Module Code
None.

 Form Code
Add the following code to the form containing a label and a command button:

Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce 
'               or publish this code on any web site,
'               online service, or distribute as source 
'               on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Declare Function GetSystemMetrics Lib "user32" _
     (ByVal nIndex As Long) As Long

Private Const SM_CLEANBOOT = 67


Private Sub Command1_Click()

  Select Case GetSystemMetrics(SM_CLEANBOOT)
     Case 1: Label1.Caption = "System started in Safe Mode."
     Case 2: Label1.Caption = "System started in Safe Mode with network support."
     Case Else: Label1.Caption = "Windows is running normally."
  End Select

End Sub
 Comments
The constant SM_CLEANBOOT is not documented in the API viewers. Valid return values for SM_CLEANBOOT are 0 (normal), 1 (Fail-safe boot), and 2 (Fail-safe with net support).

 
 

PayPal Link
Make payments with PayPal - it's fast, free and secure!

 
 
 
 

Copyright ©1996-2011 VBnet and Randy Birch. All Rights Reserved.
Terms of Use  |  Your Privacy

 

Hit Counter