Page 1 of 1

Operating System Name

Posted: Tue Sep 25, 2012 3:57 am
by reganc
Has anyone got a function they can share that returns the correct operating system name.

We use Os() but that is not clever enough to identify Windows 7...

Thanks.

Re: Operating System Name

Posted: Tue Sep 25, 2012 8:30 am
by Leon Berger
reganc wrote:We use Os() but that is not clever enough to identify Windows 7...
What Du you miss? OS() shows (on my PC): Windows 7 06.01 Build 07601 Service Pack 1

Re: Operating System Name

Posted: Tue Sep 25, 2012 8:53 am
by skiman
Hi Regan,

OS() is working here:
Operating system : Windows 7 06.01 Build 07601 Service Pack 1
is the result of:
? EHS_OS_VERSION , Os() in my errorsys.prg.

Re: Operating System Name

Posted: Tue Sep 25, 2012 9:46 am
by reganc
Leon Berger wrote:
reganc wrote:We use Os() but that is not clever enough to identify Windows 7...
What Du you miss? OS() shows (on my PC): Windows 7 06.01 Build 07601 Service Pack 1
Ok. In that case I have something wrong with my installs.

On my Win7 PC I get:

Operating system:Windows Vista 06.01 Build 07601 Service Pack 1

Weird...

Re: Operating System Name

Posted: Tue Sep 25, 2012 9:48 am
by reganc
skiman wrote:Hi Regan,

OS() is working here:
Operating system : Windows 7 06.01 Build 07601 Service Pack 1
is the result of:
? EHS_OS_VERSION , Os() in my errorsys.prg.
I must have something wrong somewhere...

I will investigate...

Thanks.

Re: Operating System Name

Posted: Tue Sep 25, 2012 10:40 am
by rdonnay
This is from the Microsoft documentation. It is possible that Xbase++ calls the GetVersionEx() API function which documents the following caveats:

The following table summarizes the most recent operating system version numbers.

Code: Select all

Operating system	Version number
Windows 7	6.1
Windows Server 2008 R2	6.1
Windows Server 2008	6.0
Windows Vista	6.0
Windows Server 2003 R2	5.2
Windows Server 2003	5.2
Windows XP 64-Bit Edition	5.2
Windows XP	5.1
Windows 2000	5.0
Identifying the current operating system is usually not the best way to determine whether a particular operating system feature is present. This is because the operating system may have had new features added in a redistributable DLL. Rather than using GetVersionEx to determine the operating system platform or version number, test for the presence of the feature itself.

To determine the best way to test for a feature, refer to the documentation for the feature of interest. The following list discusses some common techniques for feature detection:

You can test for the presence of the functions associated with a feature. To test for the presence of a function in a system DLL, call the LoadLibrary function to load the DLL. Then call the GetProcAddress function to determine whether the function of interest is present in the DLL. Use the pointer returned by GetProcAddress to call the function. Note that even if the function is present, it may be a stub that just returns an error code such as ERROR_CALL_NOT_IMPLEMENTED.
You can determine the presence of some features by using the GetSystemMetrics function. For example, you can detect multiple display monitors by calling GetSystemMetrics(SM_CMONITORS).
There are several versions of the redistributable DLLs that implement shell and common control features. For information about determining which versions are present on the system your application is running on, see the topic Shell and Common Controls Versions.

If you must require a particular operating system, be sure to use it as a minimum supported version, rather than design the test for the one operating system. This way, your detection code will continue to work on future versions of Windows.

Note that a 32-bit application can detect whether it is running under WOW64 by calling the IsWow64Process function. It can obtain additional processor information by calling the GetNativeSystemInfo function.

Re: Operating System Name

Posted: Tue Sep 25, 2012 11:53 am
by bwolfsohn
Roger,
For a couple of moments there i had a flashback and thought you were channeling Ira Emus (sp?)

http://www.socallinuxexpo.org/scale9x/s ... -emus.html