Is there a compiler constant for Windows 10 (32 or 64) ? It’s not listed in the documentation
I know I could solve it using SystemInformationMBS , but still curious if this can be done native Xojo.
Is there a compiler constant for Windows 10 (32 or 64) ? It’s not listed in the documentation
I know I could solve it using SystemInformationMBS , but still curious if this can be done native Xojo.
You can detect Windows version via compiler constants.
Which constants?
This link was already in the OP. The question is how to detect Windows 10 only. As far as I can see there is no constant for that.
You can detect ‘Windows or not’ and ‘32 or 64 bit’
You need API calls , shell statements etc to determine the version of Windows.
There should be an API call IsWindows10OrGreater(); although I dont have a working declare to hand
Maybe this will help with a bit of twiddling to make it compatible with Xojo
Private Declare Function RtlGetVersion Lib "NTDLL" (ByRef lpVersionInformation As Long) As Long
Public Sub NativeGetVersion(ByRef plMajorVer As Long, ByRef plMinorVer As Long)
Dim tOSVw(&H54) As Long
tOSVw(0) = &H54 * &H4
RtlGetVersion tOSVw(0)
plMajorVer = tOSVw(1)
plMinorVer = tOSVw(2)
End Sub
Dim lOSMajorVer As Long
Dim lOSMinorVer As Long
NativeGetVersion lOSMajorVer, lOSMinorVer
bIsWin10 = (lOSMajorVer >= 10)
I also have this code in one of my apps to check for ‘at least Windows 7’… not sure of the original author…
[code]
#if targetwin32 then
Soft Declare Function GetVersionExA Lib “kernel32” (lpVersionInformation As ptr) As integer
Soft Declare Function GetVersionExW Lib “kernel32” (lpVersionInformation As ptr) As integer
soft Declare Function DwmIsCompositionEnabled Lib “dwmapi.dll” (pfEnabled As integer) As integer
soft Declare Function DwmEnableComposition Lib “dwmapi.dll” (CompositionAction As integer) As integer
Dim m As MemoryBlock
dim dwOSVersionInfoSize,wsuitemask,ret,i as integer
dim szCSDVersion as string
dim mMajorVersion as integer
dim mplatformId as integer
dim bUsingUnicode as Boolean = false
if System.IsFunctionAvailable( "GetVersionExW", "Kernel32" ) then
bUsingUnicode = true
m = newMemoryBlock(284) ''use this for osversioninfoex structure (2000+ only)
m.long(0) = m.size 'must set size before calling getversionex
ret = GetVersionExW(m) 'if not 2000+, will return 0
if ret = 0 then
m = newMemoryBlock(276)
m.long(0) = m.size 'must set size before calling getversionex
ret = GetVersionExW(m)
if ret = 0 then
// Something really strange has happened, so use the A version
// instead
bUsingUnicode = false
goto AVersion
return
end
end
else
AVersion:
m = newMemoryBlock(156) ''use this for osversioninfoex structure (2000+ only)
m.long(0) = m.size 'must set size before calling getversionex
ret = GetVersionExA(m) 'if not 2000+, will return 0
if ret = 0 then
m = newMemoryBlock(148) ' 148 sum of the bytes included in the structure (long = 4bytes, etc.)
m.long(0) = m.size 'must set size before calling getversionex
ret = GetVersionExA(m)
if ret = 0 then
return
end
end
end if
mmajorVersion = m.long(4)
mplatformId = m.long(16)
//mextraInfo = szCSDVersion
if mplatformId = 2 then 'NT
if mMajorVersion >=6 then ' Vista or Windows 7 or above
//do what you want to do here
end if
end if
#endif[/code]
[quote=347606:@Joost Rongen]Is there a compiler constant for Windows 10 (32 or 64) ? It’s not listed in the documentation
I know I could solve it using SystemInformationMBS , but still curious if this can be done native Xojo.[/quote]
What good would a compiler constant do anyway? Theyre interpreted at compile time… and all the compiler knows at that time is that youre building a Windows application and whether its 32 or 64 bit.
Correct. Nothing.
I am lazy this time. Will use SystemInformationMBS , it returns “Windows 10 (Build 10586)”
That’s been my go-to for quite a few years (thanks, Christian).
… or is that GOTO: ???
No, stay with!
dons flame retardant suit
Do you really want to go there? How many electrons must die in the holy war?