ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Non MSDN online WinAPI reference?

<< < (3/3)

MilesAhead:
I think this is more useful, at least in AutoIt


--- ---;return the Windows version as a number.
;example 6.1 for Windows7, 6 for Vista,
;5.1 for XP etc..
;
; Author MilesAhead
;
Func _WinVersion()
Local $dwVersion = DllCall("kernel32.dll", "dword", "GetVersion")
Local $versionStr = String(BitAND($dwVersion[0], 0x00FF))
$versionStr &= "." & String(BitShift(BitAND($dwVersion[0], 0xFF00), 8))
Return Number($versionStr)
EndFunc   ;==>_WinVersion

MilesAhead:
Or if you prefer ahk


--- ---_LoWord(arg)
{
Return arg & 0xFFFF
}

_HiWord(arg)
{
Return arg >> 16
}

_LoByte(arg)
{
Return arg & 0x00FF
}

_HiByte(arg)
{
Return (arg & 0xFF00) >> 8
}

_WinVersionMajor()
{
Return _LoByte(_LoWord(DllCall("kernel32.dll\GetVersion", "UInt", -1)))
}

_WinVersionMinor()
{
Return _HiByte(_LoWord(DllCall("kernel32.dll\GetVersion", "UInt", -1)))
}

_WinVersion()
{
        dwVersion := DllCall("kernel32.dll\GetVersion", "UInt", -1)
Return _LoByte(_LoWord(dwVersion)) . "."
. _HiByte(_LoWord(dwVersion))
}


I didn't say I can't do it.  I just said it's a pain in the ass! :)

MilesAhead:
With this AutoIt version you can have it both ways. Pass a param of non-zero to return as string, 0 (or leave blank) to return as number


--- ---;return the Windows version as a number or string
;according to $retAsString param.
;example 6.1 for Windows7, 6 for Vista,
;5.1 for XP etc.. as number, as string the
;minor version will be preserved even if .0
;(Vista returns "6.0" etc.)
;
; Author MilesAhead
;
Func _WinVersion($retAsString = 0)
    Local $dwVersion = DllCall("kernel32.dll", "dword", "GetVersion")
    Local $versionStr = String(BitAND($dwVersion[0], 0x00FF))
    $versionStr &= "." & String(BitShift(BitAND($dwVersion[0], 0xFF00), 8))
    If $retAsString Then Return $versionStr
    Return Number($versionStr)
EndFunc  ;==>_WinVersion

Navigation

[0] Message Index

[*] Previous page

Go to full version