AllAPI Network - The KPD-Team

 
Allapi Network
 API-Guide
 ApiViewer

 API List

 
API Resources
 Tips & Tricks
 VB Tutorials
 Error Lookup
 
Misc Stuff
 VB examples
 VB Tools
 VB Links
 Top Downloads
 
This Site
 Search Engine
 Contact Form
 

Donate to AllAPI.net

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.

 

 


Copyright © 1998-2007, The Mentalis.org Team - Privacy statement
Did you find a bug on this page? Tell us!
This site is located at http://allapi.mentalis.org/