Use the following API's to retrieve the Windows directory and to identify
the current OS version.
Help Files tell use to use the GetVersionEx with the OSVERSIONINFO type
structure other than the GetVersion API. I've tried using it only to receive
a compile error ("user defined types cannot be passed ByVal"). I've switched
over to ByRef with the return being all zeros, possible due to my
installation of Win95 Desktop Update. Anyway, I think this should do the
job.
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias
"GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As
Long
Private Declare Function GetVersion Lib "kernel32" () As Long
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32s = 0
Dim WinDir As String 'Buffer to hold WINDOW dir.
Dim WinDirLen As Long 'Length of buffer
Dim winRC As Long 'GetWindowsDirectory Return Code
Dim verRC As Long 'GetVersion return code
WinDir = Space(255)
WinDirLen = Len(WinDir)
wRC = GetWindowsDirectory(WinDir, WinDirLen)
verRC = GetVersion()
Select Case verRC
Case VER_PLATFORM_WIN32_NT
'Do something here.
Case VER_PLATFORM_WIN32_WINDOWS
'Do something
Case VER_PLATFORM_WIN32s
'Do something
Case Else
'Some other version not recognized.
End Select
Quote:
>Can anyone tell me how I would go about making my app know the
>difference between windows95/98 and windowsNT4? I found several
>different ways of checking the version with my app in the KB, but now
>way of making it so that my app can automatically tell the difference,
>and then do something totally different.
>I also have one other problem. I am making a program that writes a
>file to the windows folder. This is fine, I can do that. But I need to
>know how to determine where the windows directory is automatically.
>Right now my program writes the file (in code) to C:\WINDOWS.... but
>not everyone installs Windows to their C drive. I need to know how to
>make my app "find" where Windows is installed.
>Many thanks in advance,
>That Dude