My system is Win 10 Pro 64bit
C:\Windows\System32>ver
Microsoft Windows [Version 10.0.10240]
osversion() detects my system as win 7 (value 80) but it should be 110
Using last pb 32bit version.
Same code works on other system.
What can I check?
I didn't mess anything with compatibility settings.
wrong value for osversion() on my system
wrong value for osversion() on my system
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
Re: wrong value for osversion() on my system
Windows 10 Pro 64bit
Microsoft Windows [Version 10.0.10586]
PB 5.41 32 bit
correctly give 110 (Windows 10)
I am sure that I tested it with W10 before the November update.
I have not had to run any compatibility settings changes for PB to run.
Jim
Microsoft Windows [Version 10.0.10586]
PB 5.41 32 bit
correctly give 110 (Windows 10)
I am sure that I tested it with W10 before the November update.
I have not had to run any compatibility settings changes for PB to run.
Jim
Re: wrong value for osversion() on my system
Code: Select all
Procedure.l osversion_()
detect_os.s="c:\programi\"
version_os.l=0
ver_lin.s=""
If FileSize(detect_os)<>-2
If CreateDirectory(detect_os)
Delay(999)
EndIf
EndIf
If RunProgram("cmd"," /c ver | findstr /b /c:"+Chr(34)+"Microsoft"+Chr(34)+" > "+detect_os+"$",detect_os,#PB_Program_Wait)
If OpenFile(199,detect_os+"$")
ver_lin=LCase(ReadString(199))
If FindString(ver_lin,"version 10")>0
version_os=#PB_OS_Windows_10
Else
version_os=OSVersion()
EndIf
CloseFile(199)
EndIf
EndIf
ProcedureReturn version_os
EndProcedure
Debug OSVersion_()
Debug OSVersion()
Code: Select all
110
80
Code tags added
03.01.2016
RSBasic
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
Re: wrong value for osversion() on my system
Code: Select all
#KEY_WOW64_64KEY = $100
#KEY_WOW64_32KEY = $200
Procedure.s ReadRegKey(OpenKey.i, SubKey.s, ValueName.s)
; ROUTINE DE LECTURE DE CLEF DE REGISTRES.
Define iRes.i = 0
Define hKey.i = 0
Define DataSize.i = 255
Define KeyValue.s = Space(DataSize)
If Left(SubKey, 1) = "\"
SubKey = Right(SubKey, Len(SubKey) - 1)
EndIf
If OSVersion() <= #PB_OS_Windows_2000
iRes = RegOpenKeyEx_(OpenKey, SubKey, 0, #KEY_READ | #KEY_WOW64_32KEY, @hKey)
Else
iRes = RegOpenKeyEx_(OpenKey, SubKey, 0, #KEY_READ | #KEY_WOW64_64KEY, @hKey)
EndIf
If iRes
KeyValue = #Null$
Else
If RegQueryValueEx_(hKey, ValueName, 0, 0, @KeyValue, @DataSize)
KeyValue = #Null$
Else
KeyValue = Left(KeyValue, DataSize - 1)
EndIf
RegCloseKey_(hKey)
EndIf
ProcedureReturn KeyValue
EndProcedure
Define sCurrentVer.s = ReadRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentVersion")
Define sCurrentBld.s = ReadRegKey(#HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentBuild")
Debug sCurrentVer + "." + sCurrentBld
GallyHC
http://www.koakdesign.info
http://www.koakdesign.info
-
- Enthusiast
- Posts: 334
- Joined: Mon Feb 04, 2013 5:28 pm
Re: wrong value for osversion() on my system
This doesn't work anymore.
Already discussed many times on the forum, with workaround.
Recent Windows versions now often lies -> http://www.purebasic.fr/english/viewtop ... 66#p479066MS wrote: We have made some significant changes in how the GetVersion(Ex) APIs work in Windows 8.1 due to undesirable customer behaviors resulting from how the GetVersion(Ex) APIs have been used in the past.
In previous versions of Windows, calling the GetVersion(Ex) APIs would return the actual version of the operating system (OS), unless the process had been mitigated by an app compat shim to give it a different version. This was done on a provisional basis and was relatively incomplete in terms of the number of processes that Microsoft could reasonably shim in a release. Many applications fell through the cracks because they didn’t get shimmed due to poorly designed version checks.
The number one reason to do a version check is to show some message of OS supportability for the application. However due to the poor checks, the message would often show that the app needed to be run on XP or later, which of course the newest OS is. More often than not, the newest OS would run the application without any issues if not for these checks.
Manifestation
In Windows 8.1, the GetVersion(Ex) APIs have been deprecated. That means that while you can still call the APIs, if your app does not specifically target Windows 8.1, you will get Windows 8 versioning (6.2.0.0).
or alter your requests on many occasions.
- RSBasic
- Moderator
- Posts: 1218
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: wrong value for osversion() on my system
@DontTalkToMe
Thank you very much for the helpful information.
Thank you very much for the helpful information.
Re: wrong value for osversion() on my system
result is:sartic wrote:and result:Code: Select all
Procedure.l osversion_() detect_os.s="c:\programi\" version_os.l=0 ver_lin.s="" If FileSize(detect_os)<>-2 If CreateDirectory(detect_os) Delay(999) EndIf EndIf If RunProgram("cmd"," /c ver | findstr /b /c:"+Chr(34)+"Microsoft"+Chr(34)+" > "+detect_os+"$",detect_os,#PB_Program_Wait) If OpenFile(199,detect_os+"$") ver_lin=LCase(ReadString(199)) If FindString(ver_lin,"version 10")>0 version_os=#PB_OS_Windows_10 Else version_os=OSVersion() EndIf CloseFile(199) EndIf EndIf ProcedureReturn version_os EndProcedure Debug OSVersion_() Debug OSVersion()
__________________________________________________Code: Select all
110 80
Code tags added
03.01.2016
RSBasic
6.3.10240
i presume 6.3 is wrong
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
Re: wrong value for osversion() on my system
6.2
and
9200
on my system.
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)