How to detect OS version in HB3.2

291 views
Skip to first unread message

Michael

unread,
Jun 21, 2021, 11:53:06 AM6/21/21
to Harbour Users

Hello,
I searh example how to detect OS version ? XP , 7 , 8 or 10 ?

Best Regards

Maurizio la Cecilia

unread,
Jun 21, 2021, 12:16:06 PM6/21/21
to Harbour User Group
  • hb_osIs64bit()  .T.|.F.

  • hb_osIsWin2K()  .T.|.F.

  • hb_osIsWin9x()  .T.|.F.

  • hb_osIsWinCE()  .T.|.F.

  • hb_osIsWinNT()  .T.|.F.

  • hb_osIsWinVista()  .T.|.F.

  • hb_osIsWin7()  .T.|.F.

  • hb_osIsWin8()  .T.|.F.

  • hb_osIsWin81()  .T.|.F.

  • hb_osIsWin10()  .T.|.F.

    NOTE 1: all the above hb_osIsWinXXX() (with the exception of hb_osIsWinCE()) will actually return .T. when the Windows version is equal to or upper than the queried one. For example: hb_osIsWin2K() returns .T. on a machine running Win2k or any later version (e.g.: WinXP, Vista or Win7). Likewise, hb_osIsWinNT() returns .T. for all windows versions from Win2K and following


Info from:


Best regards.
--
Maurizio

--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-users/010d6f46-4e89-4409-bd11-d0695fb97378n%40googlegroups.com.

Maurizio la Cecilia

unread,
Jun 21, 2021, 12:29:53 PM6/21/21
to Harbour User Group
Another simpler way is:

  • OS()  cOSName
    returns the operating system name as a character string.

If you need also know the CPU architecture you could use 
hb_osIs64bit() 

Best regards.
--
Maurizio



Il lun 21 giu 2021, 17:53 Michael <michael2...@gmail.com> ha scritto:
--

Bernard Mouille

unread,
Jun 21, 2021, 1:39:19 PM6/21/21
to Harbour Users
That I use for windows version infos is attached.
Regards,
Bernard.
Test.txt

Auge & Ohr

unread,
Jun 21, 2021, 8:38:11 PM6/21/21
to Harbour Users
hi,

for Windows 10 i need Build Number UBR too

? a := RegistryRead( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProductName" )
? b := RegistryRead( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentBuild" )
? c := LTRIM(STR(RegistryRead( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\UBR" )))  
? d := RegistryRead( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\DisplayVersion" )

MsgInfo (a+" "+b+"."+c)

greetings Jimmy

Michael

unread,
Aug 19, 2021, 5:30:47 PM8/19/21
to Harbour Users
Thanks for all answer

Best Regards

Zastava EFI

unread,
Mar 11, 2025, 8:41:38 AM3/11/25
to Harbour Users
Hello,

I have Win10 64 bit
but harbour answer is Windows 8 6.2 64 bit

Why ?

Best Regards

bernardm...@gmail.com

unread,
Mar 11, 2025, 9:09:32 AM3/11/25
to Harbour Users
Try this with -hbwin :

? bh_WindowsVersion()

// Get the Windows version.
function bh_WindowsVersion()

   local oLocator       // Objet WbemScripting.SWbemLocator.
   local oWMI           // Objet ConnectServer.
   local oItem          // Objet processeur.
   local aSys           // Tableau des processeurs : 1 normalement.
   local cReturn := ""  // Valeur retournée par la fonction.

   oLocator := win_OleCreateObject( "WbemScripting.SWbemLocator" )
   oWMI     := oLocator:ConnectServer( ".", "root\cimv2" )
   aSys     := oWMI:ExecQuery( 'Select * from Win32_OperatingSystem' )

   for each oItem in aSys // Il n'y en a qu'1 normalement.
      cReturn += oItem:Caption + " "
      cReturn += oItem:OSArchitecture // pas en XP 32 bits.
      cReturn += " build " + oItem:BuildNumber
   endfor

   // Libère la mémoire.
   oItem    := nil
   aSys     := nil
   oWMI     := nil
   oLocator := nil

   return strtran( cReturn, space( 2 ), space( 1 ) )

Zastava EFI

unread,
Mar 12, 2025, 10:11:07 AM3/12/25
to Harbour Users
Thank You :)

Best Regards
Reply all
Reply to author
Forward
0 new messages