|
-
Apr 29th, 2002, 06:28 AM
#1
Thread Starter
Addicted Member
Laptops and PC's
Hi everyone,
Does anyone know of an API to detect whether the user is using Laptop or desktop?
Thanks in advance,
-
Apr 29th, 2002, 06:50 AM
#2
Lively Member
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
-
Apr 29th, 2002, 06:54 AM
#3
Fanatic Member
Add a SysInfo control to your form:
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
Or - late bind with CreateObject if you don't want to add a form control!
-
Apr 29th, 2002, 07:38 AM
#4
Thread Starter
Addicted Member
Good idea!
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,
-
Apr 29th, 2002, 07:42 AM
#5
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
-
Apr 29th, 2002, 07:46 AM
#6
Thread Starter
Addicted Member
Thank-you
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.
-
Apr 29th, 2002, 07:54 AM
#7
Frenzied Member
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
-
Apr 29th, 2002, 07:56 AM
#8
Actually its 95/98/ME, 2000/XP.
Just doesn't work on NT.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|