Results 1 to 8 of 8

Thread: Laptops and PC's

  1. #1

    Thread Starter
    Addicted Member Mandelbrot's Avatar
    Join Date
    Aug 2001
    Location
    Work, as usual!!
    Posts
    241

    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,

  2. #2
    Lively Member sandin's Avatar
    Join Date
    Nov 2001
    Location
    From Your Heart!!!!
    Posts
    68
    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

  3. #3
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810
    Add a SysInfo control to your form:
    VB Code:
    1. Select Case SysInfo1.BatteryStatus
    2.       Case 1
    3.          Msgbox "Battery OK"
    4.       Case 2
    5.          Msgbox "Battery Low"
    6.       Case 4
    7.          Msgbox "Battery Critical"
    8.       Case 8
    9.          Msgbox "Battery Charging"
    10.       Case 128, 255
    11.          '=== NOT A NOTEBOOK!
    12.          Msgbox  "No Battery Status - Desktop?"
    13.    End Select
    Or - late bind with CreateObject if you don't want to add a form control!
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  4. #4

    Thread Starter
    Addicted Member Mandelbrot's Avatar
    Join Date
    Aug 2001
    Location
    Work, as usual!!
    Posts
    241

    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,

  5. #5
    sunnyl
    Guest
    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

  6. #6

    Thread Starter
    Addicted Member Mandelbrot's Avatar
    Join Date
    Aug 2001
    Location
    Work, as usual!!
    Posts
    241

    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.

  7. #7
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    I believe that GetSystemPowerStatus is Win2000/WinXP only?

    For WinNT4 you can use GetCurrentHardwareprofile from th eApiHardwareProfile class
    VB Code:
    1. Option Explicit
    2.  
    3. '\\ --[ ApiHardwareProfile ] - - - - - - - - - - - - - - - - - - - - - - -
    4. '\\ Code for reading the current hardware profile (plug and play info)
    5. '\\ from the Api - Requires NT4 or Win95
    6. '\\ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    7.  
    8. Private Const HW_PROFILE_GUIDLEN = 39
    9. Private Const MAX_HW_PROFILE_LEN = 80
    10.  
    11. Public Enum DOCKINFO_DOCKSTATUS
    12.     DOCKSTATE_NODOCKING = &H0
    13.     DOCKSTATE_UNDOCKED = &H1
    14.     DOCKSTATE_DOCKED = &H2
    15.     DOCKSTATE_USER_SUPPLIED = &H4
    16.     DOCKSTATE_USER_UNDOCKED = &H5 '&H4 | &H1
    17.     DOCKSTATE_USER_DOCKED = &H6 '&H4 | &H2
    18. End Enum
    19.  
    20. Private Type HARDWARE_PROFILE
    21.     DockState As DOCKINFO_DOCKSTATUS
    22.     ProfileGuid As String * HW_PROFILE_GUIDLEN
    23.     ProfileName As String * MAX_HW_PROFILE_LEN
    24. End Type
    25.  
    26. Private Declare Function GetCurrentHardwareProfile Lib "advapi32.dll" Alias "GetCurrentHwProfileA" (hwProfile As HARDWARE_PROFILE) As Long

    HTH,
    Duncan
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  8. #8
    sunnyl
    Guest
    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
  •  



Click Here to Expand Forum to Full Width