home *** CD-ROM | disk | FTP | other *** search
- // WINDOWS.SCP - Sample Script function to return the Control's Windows directory
- // Copyright (c) 2000, Vector Networks Limited
- // All Rights Reserved
- //
- // Revision History:
- // 6.0 01-Nov-00 DB - Created, using GTCTLDIR.SCP
-
- // GetWindowsDir returns the path to the Windows directory by looking
- // up the SystemRoot value in the Registry. This is stored under
- // HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion on NT
- // and HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion on 9x
-
- Function GetWindowsDir () as String
- Dim RegName, RegKey, RegValue, Result
- Dim DType as Integer
-
- // Initialise an error result
-
- Result = ""
-
- // Work out the Registry Key name and open it
- // This is different for Windows 9x and NT. Try NT first...
-
- RegName = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
- RegKey = RegOpenKey (HKEY_LOCAL_MACHINE, RegName)
-
- If RegKey then
- RegValue = RegGetValue (RegKey, "SystemRoot", DType)
- RegCloseKey (RegKey)
-
- If (DType = REG_SZ) AND IsString (RegValue) then
- Result = RegValue
- Else
- // Print "Unable to obtain Registry Value:"
- // Print RegName, "\", "SystemRoot=", RegValue, ", Type=", DType
- Endif
- Endif
-
- If Result = "" Then
-
- // Maybe we are running on 9x. Try that next...
-
- RegName = "SOFTWARE\Microsoft\Windows\CurrentVersion"
- RegKey = RegOpenKey (HKEY_LOCAL_MACHINE, RegName)
-
- If RegKey then
- RegValue = RegGetValue (RegKey, "SystemRoot", DType)
- RegCloseKey (RegKey)
-
- If (DType = REG_SZ) AND IsString (RegValue) then
- Result = RegValue
- Else
- // Print "Unable to open the required registry value:"
- // Print RegName, "\SystemRoot=", RegValue
- Endif
- EndIf
- EndIf
-
- If Result = "" Then
- Print "Unable to open required Registry Key:"
- Print RegName, "\SystemRoot=", RegValue
- Endif
-
- // Return the result
-
- GetWindowsDir = Result
- End Function
-
- // GetWinSysDir returns the path to the Windows System directory using
- // the same mechanism as GetWindowsDir, above. It can tell by the result
- // whether it is running on Windows NT or 9x.
-
- Function GetWinSysDir () as String
- Dim RegName, RegKey, RegValue, Result
- Dim DType as Integer
-
- // Initialise an error result
-
- Result = ""
-
- // Work out the Registry Key name and open it
- // This is different for Windows 9x and NT. Try NT first...
-
- RegName = "SOFTWARE\Microsoft\Windows NT\CurrentVersion"
- RegKey = RegOpenKey (HKEY_LOCAL_MACHINE, RegName)
-
- If RegKey then
- RegValue = RegGetValue (RegKey, "SystemRoot", DType)
- RegCloseKey (RegKey)
-
- If (DType = REG_SZ) AND IsString (RegValue) then
- Result = RegValue + "\SYSTEM32"
- Else
- // Print "Unable to obtain Registry Value:"
- // Print RegName, "\", "SystemRoot=", RegValue, ", Type=", DType
- Endif
- Endif
-
- If Result = "" Then
-
- // Maybe we are running on 9x. Try that next...
-
- RegName = "SOFTWARE\Microsoft\Windows\CurrentVersion"
- RegKey = RegOpenKey (HKEY_LOCAL_MACHINE, RegName)
-
- If RegKey then
- RegValue = RegGetValue (RegKey, "SystemRoot", DType)
- RegCloseKey (RegKey)
-
- If (DType = REG_SZ) AND IsString (RegValue) then
- Result = RegValue + "\SYSTEM"
- Else
- // Print "Unable to open the required registry value:"
- // Print RegName, "\SystemRoot=", RegValue
- Endif
- EndIf
- EndIf
-
- If Result = "" Then
- Print "Unable to open required Registry Key:"
- Print RegName, "\SystemRoot=", RegValue
- Endif
-
- // Return the result
-
- GetWinSysDir = Result
- End Function
-