|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Wed Jul 04, 2012 6:49 am Post subject: |
|
|
Brilliant! I will see if I can build that into a library function for future use. |
|
Back to top |
|
|
Wilfried Linder
Joined: 14 Nov 2007 Posts: 314 Location: Düsseldorf, Germany
|
Posted: Wed Jul 04, 2012 7:57 am Post subject: |
|
|
Here is some modified code (f95) - see the subroutine get_os_info:
Code: | WINAPP
program test
IMPLICIT NONE
integer*4 bits,err_code
character*256 name,version,build
call get_os_info(name,version,build,bits,err_code)
print*,'Name ',name(1:len_trim(name))
print*,'Version ',version(1:len_trim(version))
print*,'Build ',build(1:len_trim(build))
print*,'Bits ',bits
print*,'err_code ',err_code
end
! ---------------------------------------------------------------------
subroutine get_os_info(name,version,build,bits,err_code)
IMPLICIT NONE
include 'win32api.ins'
integer,parameter::HKEY_LOCAL_MACHINE=Z'80000002'
integer*4 hKey,l,j,bits,err_code
character*256 RegPath,name,version,build
err_code = -1
name = ' '
version = ' '
build = ' '
bits = 32
RegPath = 'Software\Wow6432Node\Microsoft\Windows NT\CurrentVersion'
j = RegOpenKey(HKEY_LOCAL_MACHINE,trim(RegPath),hKey)
if (j /= 0) then
RegPath = 'Software\Microsoft\Windows NT\CurrentVersion'
j = RegOpenKey(HKEY_LOCAL_MACHINE,trim(RegPath),hKey)
else
bits = 64
end if
if (j == 0) then
l = 256
j = RegQueryValueEx(hKey,"ProductName",CCORE1(0),CCORE1(0),name,l)
l = 256
j = RegQueryValueEx(hKey,"CurrentVersion",CCORE1(0),CCORE1(0),version,l)
l = 256
j = RegQueryValueEx(hKey,"CurrentBuildNumber",CCORE1(0),CCORE1(0),build,l)
end if
j = RegCloseKey(hKey)
err_code = 0
return
end |
Regards - Wilfried |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2818 Location: South Pole, Antarctica
|
Posted: Thu Jul 05, 2012 8:40 pm Post subject: |
|
|
Works like charm! Thanks again |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Fri Jul 06, 2012 11:13 am Post subject: |
|
|
I have added a new routine called get_wow_ver@ for the next release.
This provides the machine operating system whilst get_os_ver@ remains unchanged and provides the compatible operating system when the executable runs in compatibility mode. |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2818 Location: South Pole, Antarctica
|
Posted: Sat Jul 07, 2012 6:10 pm Post subject: |
|
|
Thanks, Paul |
|
Back to top |
|
|
Shahram
Joined: 13 May 2013 Posts: 25
|
Posted: Sun Apr 27, 2014 9:28 am Post subject: I incurred the same |
|
|
Yes whenever you call GET_OS_VER@ in a large program, the result is not correct for windows 8. However, with a trick you can avoid such problem,
just write the following program:
winapp
program getver
use mswin
implicit none
INTEGER PLATFORMID, MAJOR, MINOR
OPEN(UNIT=40,FILE='winver.92',FORM='UNFORMATTED')
call GET_OS_VER@( PLATFORMID, MAJOR, MINOR )
write(40)MAJOR, MINOR,PLATFORMID
stop
end
This writes the result in a file and then in your large program read these values, it would be correct. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|