View previous topic :: View next topic |
Author |
Message |
DanRRight
Joined: 10 Mar 2008 Posts: 2818 Location: South Pole, Antarctica
|
Posted: Mon Jun 18, 2012 6:11 pm Post subject: |
|
|
Thanks Detlef and Paul
Summary so far under Win7 64bit is
1) the code above as is gives me right major, minor=6, 1
2) when run it via debugger i gets wrong result = 5, 1
3) being placed in the large code i get always only wrong 5, 1
4) /win key gives me no difference |
|
Back to top |
|
|
dpannhorst
Joined: 29 Aug 2005 Posts: 165 Location: Berlin, Germany
|
Posted: Mon Jun 18, 2012 6:45 pm Post subject: |
|
|
Hi Dan,
I have no problem when I run it via debugger.
I am still getting major, minor = 6, 1
I have made a screenshot in the debug mode, but I don't know how to upload it to the forum here.
Detlef |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2818 Location: South Pole, Antarctica
|
Posted: Mon Jun 18, 2012 8:51 pm Post subject: |
|
|
There is nothing wrong with your code. Both methods give the same result means something behind exists.
I suggest to try running it in the XP compatibility mode (Properties/Compatibility/Run this program in XP compatibility mode for/ Windows XP(Service Pack 3) ). This and future EXE versions as a result should give you 5, 1. So these two methods detect not the OS on your computer but something different.
But is there a way to get the ***OS on this computer*** instead of lowest OS the code is compatible running with ? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2818 Location: South Pole, Antarctica
|
Posted: Sun Jun 24, 2012 4:22 am Post subject: |
|
|
It will be fine for me with the uncertainty between Win7 and Server 2012 (where both Major/Minor are equal to 6/1) but it will be not if my Win7 computer (Major 6) tells me that this is XP (Major 5)...
Things are that I've made the code compatible with XP by the following reason. This code is actually using another code as an interface between my program and the stock data source of electronic trading broker (Ameritrade or whatever, it is compatible to all of them). They communicate in a client - server manner, thanks to FTN95/CWP function allowing us to get the data from the internet (please make much more such functions ! Intel VF has 20+ more of them but they are not as user-friendly as in FTN95). This interface program when running opening internal server and my program pings its port, port responds accordingly to the protocol, and my code gets the responded data. Very easy.
The problem is that this interface program written by other authors under XP is not working flawlessly when it is moved to Win7. So i have set both mine and interface codes while working under Win7 to be compatible with XP using compatibility option of Win7 (which is also as easy as just couple clicks like i showed above).
The result is that now GetVersionEx is reporting the current Windows version on the computer as if it is XP. So when i move back to real XP sometimes i need to change all the disk names in my code manually because Win7 messed up all the disk partition letters on the computer which is not possible to rename (i have too many partitions from C to Z). If some function detected OS computer is running correctly i'd programmed that and all would work automatically. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Sun Jun 24, 2012 5:55 pm Post subject: |
|
|
There appears to be nothing wrong with the code for get_os_ver@. Just a straight call to GetVersionEx.
The problem is probably revealed by the following comment copied from the MSDN topic on GetVersionEx....
Quote: | If compatibility mode is in effect, the GetVersionEx function reports the operating system as it identifies itself, which may not be the operating system that is installed. For example, if compatibility mode is in effect, GetVersionEx reports the operating system that is selected for application compatibility. |
If all else fails there will be a registry setting somewhere that will identify the root operating system. |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2818 Location: South Pole, Antarctica
|
Posted: Mon Jun 25, 2012 10:58 pm Post subject: |
|
|
Yes, thanks that you have confirmed my feelings about the whole situation and for good suggestion. As to WinAPI - do you or anyone here remember any functions which expose the core operating system ? ....i think i have met something like this before |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Tue Jun 26, 2012 7:50 am Post subject: |
|
|
You can find the information in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion but there ought to be a simpler way.
If no one can suggest a better way then I will add a new routine to the library that will extract the relevant information (or maybe change get_os_ver@). |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2818 Location: South Pole, Antarctica
|
Posted: Thu Jun 28, 2012 12:59 am Post subject: |
|
|
Still searching for simple way...May be John Horspool will remind us which WinAPI function reported Windows OS ? I think i played with one of his suggestions and have seen along the other things as a side effect some function told about Windows version. Or may be it was even some of Clearwin ?! |
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: Düsseldorf, Germany
|
Posted: Thu Jun 28, 2012 9:11 am Post subject: |
|
|
I don't know if this can help, but according to Paul's remark I wrote a little test:
Code: | WINAPP
program test
IMPLICIT NONE
include 'win32api.ins'
INTEGER,PARAMETER::HKEY_LOCAL_MACHINE=Z'80000002'
integer*4 hKey,l,j
character*256 RegPath,version,string
RegPath = 'Software\Microsoft\Windows NT\CurrentVersion'
j = RegOpenKey(HKEY_LOCAL_MACHINE,trim(RegPath),hKey)
if (j .eq. 0) then
version = ' '
l = 256
j = RegQueryValueEx(hKey,"ProductName",
* CCORE1(0),CCORE1(0),version,l)
string = 'OS '//trim(version)
print*,string(1:len_trim(string))
version = ' '
l = 256
j = RegQueryValueEx(hKey,"CurrentVersion",
* CCORE1(0),CCORE1(0),version,l)
string = 'Version '//trim(version)//', build'
version = ' '
l = 256
j = RegQueryValueEx(hKey,"CurrentBuildNumber",
* CCORE1(0),CCORE1(0),version,l)
string = trim(string)//' '//trim(version)
print*,string(1:len_trim(string))
end if
j = RegCloseKey(hKey)
RegPath = 'SYSTEM\CurrentControlSet\Control\ProductOptions'
j = RegOpenKey(HKEY_LOCAL_MACHINE,trim(RegPath),hKey)
if (j .eq. 0) then
version = ' '
l = 256
j = RegQueryValueEx(hKey,"ProductSuite",
* CCORE1(0),CCORE1(0),version,l)
print*,version(1:len_trim(version))
end if
j = RegCloseKey(hKey)
end |
You may compare the results with those from winver.exe. Surely there are more parameters of interest in the registry database.
Regards - Wilfried |
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: Düsseldorf, Germany
|
Posted: Thu Jun 28, 2012 3:28 pm Post subject: |
|
|
Addition to see whether Windows7 is installed as 32- or 64-bit version:
Code: | integer*2 dummy
j = 64
call attach@('c:\windows\syswow64',dummy)
if (dummy .ne. 0) j = 32
print*,j |
Regards - Wilfried |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2818 Location: South Pole, Antarctica
|
Posted: Fri Jun 29, 2012 4:30 am Post subject: |
|
|
Thanks Wilfried for the shot. Well, seems this task is harder then it looks. Getting with this method the same story as with previous method. As soon as EXE is in compatibility mode with XP, it detects XP not Win7.
It was interesting though how you have detected 32 vs 64 bit OS....May be meantime i will use it as a temporal indirect solution, because my real XP was 32 bit and Win7 is 64bit . By the way will it work with the 32bit Win7 ? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: Düsseldorf, Germany
|
Posted: Tue Jul 03, 2012 3:55 pm Post subject: |
|
|
If I change the first RegPath line in my example above from
Code: | RegPath = 'Software\Microsoft\Windows NT\CurrentVersion' |
to
Code: | RegPath =
* 'Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion' |
then I get the message "Windows 7" even if I run the programme in compatibility mode (XP). May be this helps?
If yes, then to prevent problems on PCs with "real" XP operation system I would replace the first line by
Code: | RegPath =
* 'Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion'
j = RegOpenKey(HKEY_LOCAL_MACHINE,trim(RegPath),hKey)
if (j .ne. 0) then
RegPath = 'Software\Microsoft\Windows NT\CurrentVersion'
j = RegOpenKey(HKEY_LOCAL_MACHINE,trim(RegPath),hKey)
end if |
Regards - Wilfried |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2818 Location: South Pole, Antarctica
|
Posted: Tue Jul 03, 2012 7:15 pm Post subject: |
|
|
Holly...that works...wow people started doing real wizardry here...i even still not get what and how . Nice to see the little miracle done. Kudos and big thanks, Wilfried!!! Thanks all for the efforts. |
|
Back to top |
|
|
|