|
-
Sep 9th, 2000, 02:14 PM
#1
Thread Starter
Member
Although I’m running VB 6.0, I’ve only installed service pack 2 (service pack 4 is downloading as I speak). I’m also still using Windows 95. Are C:\Windows\Temp and C:\Windows\System the usual Temp and System directories for Windows 98, 2000, and ME? Are C:\WinNT\Temp and C:\WinNT\System32 the usual Temp and System directories for NT? Are the following Windows API calls the best way of getting the operating system, system directory path, and temp directory path?
Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" _ (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal _ nBufferLength As Long, ByVal lpBuffer As String) As Long
Declare Function GetVersion Lib "kernel32" Alias "GetVersionExA" (ByRef _ lpVersionInformation As OSVERSIONINFO) As Long
lpVersionInformation.dwPlatformId returns 0 for Windows 3.x, 1 for Windows 95, and for NT. The SysInfo control’s .OSPlatform property appears to return the same values. What do they return for Windows 98, 2000, and ME?
Environ(i) returns strings such as "TEMP=C:\WINDOWS\TEMP" and "windir=C:\WINDOWS” for various values of i in Windows 95. Is the same true in Windows 98, 2000, and ME? Does it return "windir=C:\WINNT” for NT in most cases?
John Fritch
-
Sep 9th, 2000, 02:29 PM
#2
Monday Morning Lunatic
Always use the API calls, because there's always going to be someone (like me), who installs into a different folder (I use c:\win98). Using %WINDIR% is often quite a good solution, though.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 9th, 2000, 03:03 PM
#3
The above APIs are the best way to get the system info.
For extended info about the OS you can use this:
Code:
'Put this in a module
Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Public Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Public Const VER_PLATFORM_WIN32_NT = 2
Public Const VER_PLATFORM_WIN32_WINDOWS = 1
Public Const VER_PLATFORM_WIN32s = 0
'Usage:
Dim OS As OSVERSIONINFO
Dim lResult As Long
Dim sOS As String
Dim sInfo As String
OS.dwOSVersionInfoSize = Len(OS)
lResult = GetVersionEx(OS)
Select Case OS.dwPlatformId
Case VER_PLATFORM_WIN32_NT: sOS = "Windows NT"
Case VER_PLATFORM_WIN32_WINDOWS: sOS = "Windows 95/98"
Case VER_PLATFORM_WIN32s: sOS = "Windows 3.X with Win32"
End Select
sInfo = Replace(OS.szCSDVersion, " ", "")
sInfo = Replace(sInfo, Chr(0), "")
If sInfo = "" Then sInfo = "None"
MsgBox "Operating System: " & sOS & vbCrLf & "Version: " & OS.dwMajorVersion & "." & OS.dwMinorVersion & "." & OS.dwBuildNumber & vbCrLf & "Other Info: " & sInfo
Hope it helps.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|