How to call IsWindowsVersionOrGreater function?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
expert_vision
Posts: 21
Joined: 13 Jan 2014, 10:47

How to call IsWindowsVersionOrGreater function?

22 Apr 2014, 09:14

How can you call this function ?

None of this works.

Code: Select all

hModuleNtdll := DllCall("LoadLibrary", "str", "ntdll.dll")
hModuleKernel32 := DllCall("LoadLibrary", "str", "kernel32.dll")
MsgBox % DllCall("ntdll.dll\IsWindowsXPSP3OrGreater")
MsgBox % DllCall("Kernel32.dll\IsWindowsXPSP3OrGreater")
DllCall("FreeLibrary", "uint", hModuleKernel32)
DllCall("FreeLibrary", "uint", hModuleNtdll)
expert_vision
Posts: 21
Joined: 13 Jan 2014, 10:47

Re: How to call IsWindowsVersionOrGreater function?

22 Apr 2014, 10:28

Ok. I ended up using GetVersionEx WinAPI function. Much better.

Code: Select all

MsgBox % GetOSVersion()
MsgBox % CompareVersion(GetOSVersion(), "5.1.2600.3.0") ; check if XP SP3 or grater

GetOSVersion()
{
  hModuleKernel32 := DllCall("LoadLibrary", "str", "kernel32.dll")
  VarSetCapacity(OSVERSIONINFOEX, 156, 0)
  NumPut(156, &OSVERSIONINFOEX, 0)
  DllCall("Kernel32.dll\GetVersionEx", "Uint", &OSVERSIONINFOEX)
  MajorVersion := NumGet(&OSVERSIONINFOEX, 4)
  MinorVersion := NumGet(&OSVERSIONINFOEX, 8)
  BuildNumber := NumGet(&OSVERSIONINFOEX, 12)
  ServicePackMajor := NumGet(&OSVERSIONINFOEX, 148)
  ServicePackMinor := NumGet(&OSVERSIONINFOEX, 150) & 0xff
  DllCall("FreeLibrary", "uint", hModuleKernel32)
  return MajorVersion . "." . MinorVersion . "." . BuildNumber . "." . ServicePackMajor . "." . ServicePackMinor
}

CompareVersion(current, min, max := 0)
{
  If (max)
    checkMax := 1
  RegExReplace(current, "\.", "", currSize)
  RegExReplace(min, "\.", "", minSize)
  RegExReplace(max, "\.", "", maxSize)
  size := currSize > maxSize ? currSize : maxSize
  size := size > minSize ? size : minSize
  Loop % size - currSize
    current .= ".0"
  Loop % size - minSize
    min .= ".0"
  Loop % size - maxSize
    max .= ".0"
  size++
  Loop % size-1
    pattern .= "([0-9]+)\."
  Loop % size
  {
    currentSection := RegExReplace(current, "^" . pattern . "([0-9]+)(\.[0-9]+)*$", "$" . A_Index)
    minSection := RegExReplace(min, "^" . pattern . "([0-9]+)(\.[0-9]+)*$", "$" . A_Index)
    If (currentSection < minSection)
      return 0
    If (currentSection > minSection)
      break
  }
  If (checkMax)
  {
    Loop % size
    {
      currentSection := RegExReplace(current, "^" . pattern . "([0-9]+)(\.[0-9]+)*$", "$" . A_Index)
      maxSection := RegExReplace(max, "^" . pattern . "([0-9]+)(\.[0-9]+)*$", "$" . A_Index)
      If (currentSection > maxSection)
        return 0
      If (currentSection < maxSection)
        return 1
    }
  }
  return 1
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Marium0505 and 353 guests