Hi everyone,
Does anyone know of an API to detect whether the user is using Laptop or desktop?
Thanks in advance,
Printable View
Hi everyone,
Does anyone know of an API to detect whether the user is using Laptop or desktop?
Thanks in advance,
i know only the API that 's chcek the version of the current system....
API is here...
Private Declare Function GetVersion Lib "kernel32" () As Long
Public Function GetWinVersion() As String
Dim Ver As Long, WinVer As Long
Ver = GetVersion()
WinVer = Ver And &HFFFF&
'retrieve the windows version
GetWinVersion = Format((WinVer Mod 256) + ((WinVer \ 256) / 100), "Fixed")
End Function
Private Sub Form_Load()
MsgBox "Windows version: " + GetWinVersion
End Sub
----
sandin
Add a SysInfo control to your form:
Or - late bind with CreateObject if you don't want to add a form control!VB Code:
Select Case SysInfo1.BatteryStatus Case 1 Msgbox "Battery OK" Case 2 Msgbox "Battery Low" Case 4 Msgbox "Battery Critical" Case 8 Msgbox "Battery Charging" Case 128, 255 '=== NOT A NOTEBOOK! Msgbox "No Battery Status - Desktop?" End Select
Jerry,
Do you know if the is an API to do the same thing, or do I specifically need to use the control (the problem is that I'm detecting using an Access database!).
Thanks in advance,
Theres the GetSystemPowerStatus API and the SYSTEM_POWER_STATUS structure.
Declare Function GetSystemPowerStatus Lib "kernel32" Alias "GetSystemPowerStatus" (lpSystemPowerStatus As SYSTEM_POWER_STATUS) As Long
Private Type SYSTEM_POWER_STATUS
ACLineStatus As Byte
BatteryFlag As Byte
BatteryLifePercent As Byte
Reserved1 As Byte
BatteryLifeTime As Long
BatteryFullLifeTime As Long
End Type
Jerry and Sunny,
Thanks for your help - that's cracked it. You're both stars!!
Regards,
PS: Thanks to you also, Sandin, but not what I'm looking for.
I believe that GetSystemPowerStatus is Win2000/WinXP only?
For WinNT4 you can use GetCurrentHardwareprofile from th eApiHardwareProfile class
VB Code:
Option Explicit '\\ --[ ApiHardwareProfile ] - - - - - - - - - - - - - - - - - - - - - - - '\\ Code for reading the current hardware profile (plug and play info) '\\ from the Api - Requires NT4 or Win95 '\\ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Private Const HW_PROFILE_GUIDLEN = 39 Private Const MAX_HW_PROFILE_LEN = 80 Public Enum DOCKINFO_DOCKSTATUS DOCKSTATE_NODOCKING = &H0 DOCKSTATE_UNDOCKED = &H1 DOCKSTATE_DOCKED = &H2 DOCKSTATE_USER_SUPPLIED = &H4 DOCKSTATE_USER_UNDOCKED = &H5 '&H4 | &H1 DOCKSTATE_USER_DOCKED = &H6 '&H4 | &H2 End Enum Private Type HARDWARE_PROFILE DockState As DOCKINFO_DOCKSTATUS ProfileGuid As String * HW_PROFILE_GUIDLEN ProfileName As String * MAX_HW_PROFILE_LEN End Type Private Declare Function GetCurrentHardwareProfile Lib "advapi32.dll" Alias "GetCurrentHwProfileA" (hwProfile As HARDWARE_PROFILE) As Long
HTH,
Duncan
Actually its 95/98/ME, 2000/XP.
Just doesn't work on NT.