Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to determine OS?
Message
De
28/05/2002 06:04:31
 
 
À
27/05/2002 09:04:23
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00661640
Message ID:
00661895
Vues:
25
>>>Hi,
>>>
>>>I want to write a function that gives me the OS of the computer ie Windows 98 / Windows NT etc.
>>>
>>>OS(1) function returns Win version number as 4 for Win 98, 4.9 for Win Me, 5 for Win 2000 and so on. Is there any way I can map the return value of OS(1) to the correct equivalent Windows OS version?
>>
>>A DO CASE, that returns exactly the value you want. Or, define constants for each version of Windows.
>>
>>The main problem is to get the complete list of OS.
>
>Another option would be to implement the Win32 API GetVersionEx() API call; at a minimum, it will return an OSVERSIONINFO structure that contains the major and minor OS versions, build number and may contain a CSD string providing further differentiation; WinNT 4.0 SP6 and later can provide an extended version of the structure OSVERSIONINFOEX which contains service pack detail as well. Both structures are relatively simple, and well-documented in the MSDN documentation; the call to GetVersionEx() is pretty straightforward - create a big buffer in a VFP memory variable and pass it by reference, and then parse the return value:
>
>
DECLARE SHORT GetVersionEx IN WIN32API STRING @ lpBuffer
>cOSVERSIONINFOBuffer = CHR(147) + REPL(CHR(0),147) && get an OSVERSIONINFO
>IF GetVersionEx(@cOSVERSIONINFOBuffer) # 0
>   *  It worked
>ELSE
>   * it failed - call GetLastError() to find out why
>ENDIF
>
>If you discover that a compatible OS is present, you can repeat the call with a buffer of 156 bytes in length to retrieve the OSVERSIONINFOEX structure. The OSVERSIONINFO strucutre is simple - 5 DWORDs, representing the structure size, major version, minor version, build number, and platform ID respectively, followed by 128 bytes of CSD data treated as a CString. You'll need a UDF to convert 4 byte strings to numeric values (you can use DWORDToNum() from CLSHeap, which can be downloaded from the Files section, or any of a number of other published UDFs to do this) and will need to use the reference data from the OSVERSIONINFO structure documentation in the MSDN Library (if you don't have it on CD, it's available online via msdn.microsoft.com in the documentation on the Platform SDK.)
>
>VFP's OS(1) should be able to be used to get a simple differentiation of OS version if build issues are not important.

Ed,
Yes, your suggestion about using GetVersionEx() was very good. I combined the information found in the following pages

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q188987

http://fox.wikis.com/wc.dll?Wiki~VFPFunctionOS~VFP.

and now have OS details as well as Build and Service Pack details.
Thanx a lot.
Hitendra
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform