| | 117 | |
|---|
| | 118 | '' |
|---|
| | 119 | ' Checks if this is a WOW64 process. |
|---|
| | 120 | function IsWow64() |
|---|
| | 121 | if g_objShell.Environment("PROCESS")("PROCESSOR_ARCHITEW6432") <> "" then |
|---|
| | 122 | IsWow64 = 1 |
|---|
| | 123 | else |
|---|
| | 124 | IsWow64 = 0 |
|---|
| | 125 | end if |
|---|
| | 126 | end function |
|---|
| | 127 | |
|---|
| | 128 | |
|---|
| | 129 | '' |
|---|
| | 130 | ' Translates a register root name to a value |
|---|
| | 131 | function RegTransRoot(strRoot) |
|---|
| | 132 | const HKEY_LOCAL_MACHINE = &H80000002 |
|---|
| | 133 | const HKEY_CURRENT_USER = &H80000001 |
|---|
| | 134 | select case strRoot |
|---|
| | 135 | case "HKLM" |
|---|
| | 136 | RegTransRoot = HKEY_LOCAL_MACHINE |
|---|
| | 137 | case "HKCU" |
|---|
| | 138 | RegTransRoot = HKEY_CURRENT_USER |
|---|
| | 139 | case else |
|---|
| | 140 | MsgFatal "RegEnumSubKeys: Unknown root: " & strRoot |
|---|
| | 141 | RegTransRoot = 0 |
|---|
| | 142 | end select |
|---|
| | 143 | end function |
|---|
| | 144 | |
|---|
| | 145 | |
|---|
| | 146 | '' The registry globals |
|---|
| | 147 | dim g_objReg, g_objRegCtx |
|---|
| | 148 | dim g_blnRegistry |
|---|
| | 149 | g_blnRegistry = false |
|---|
| | 150 | |
|---|
| | 151 | |
|---|
| | 152 | '' |
|---|
| | 153 | ' Init the register provider globals. |
|---|
| | 154 | function RegInit() |
|---|
| | 155 | RegInit = false |
|---|
| | 156 | On Error Resume Next |
|---|
| | 157 | if g_blnRegistry = false then |
|---|
| | 158 | set g_objRegCtx = CreateObject("WbemScripting.SWbemNamedValueSet") |
|---|
| | 159 | ' Comment out the following for lines if the cause trouble on your windows version. |
|---|
| | 160 | if IsWow64() then |
|---|
| | 161 | g_objRegCtx.Add "__ProviderArchitecture", 64 |
|---|
| | 162 | g_objRegCtx.Add "__RequiredArchitecture", true |
|---|
| | 163 | end if |
|---|
| | 164 | set objLocator = CreateObject("Wbemscripting.SWbemLocator") |
|---|
| | 165 | set objServices = objLocator.ConnectServer("", "root\default", "", "", , , , g_objRegCtx) |
|---|
| | 166 | set g_objReg = objServices.Get("StdRegProv") |
|---|
| | 167 | g_blnRegistry = true |
|---|
| | 168 | end if |
|---|
| | 169 | RegInit = true |
|---|
| | 170 | end function |
|---|
| | 171 | |
|---|
| | 172 | |
|---|
| 121 | | On Error Resume Next |
|---|
| 122 | | RegGetString = g_objShell.RegRead(strName) |
|---|
| 123 | | end function |
|---|
| | 177 | if RegInit() then |
|---|
| | 178 | dim strRoot, strKey, strValue |
|---|
| | 179 | dim iRoot |
|---|
| | 180 | |
|---|
| | 181 | ' split up into root, key and value parts. |
|---|
| | 182 | strRoot = left(strName, instr(strName, "\") - 1) |
|---|
| | 183 | strKey = mid(strName, instr(strName, "\") + 1, instrrev(strName, "\") - instr(strName, "\")) |
|---|
| | 184 | strValue = mid(strName, instrrev(strName, "\") + 1) |
|---|
| | 185 | |
|---|
| | 186 | ' Must use ExecMethod to call the GetStringValue method because of the context. |
|---|
| | 187 | Set InParms = g_objReg.Methods_("GetStringValue").Inparameters |
|---|
| | 188 | InParms.hDefKey = RegTransRoot(strRoot) |
|---|
| | 189 | InParms.sSubKeyName = strKey |
|---|
| | 190 | InParms.sValueName = strValue |
|---|
| | 191 | On Error Resume Next |
|---|
| | 192 | set OutParms = g_objReg.ExecMethod_("GetStringValue", InParms, , g_objRegCtx) |
|---|
| | 193 | if OutParms.ReturnValue = 0 then |
|---|
| | 194 | RegGetString = OutParms.sValue |
|---|
| | 195 | end if |
|---|
| | 196 | else |
|---|
| | 197 | ' fallback mode |
|---|
| | 198 | On Error Resume Next |
|---|
| | 199 | RegGetString = g_objShell.RegRead(strName) |
|---|
| | 200 | end if |
|---|
| | 201 | end function |
|---|
| | 202 | |
|---|
| 128 | | const HKEY_LOCAL_MACHINE = &H80000002 |
|---|
| 129 | | const HKEY_CURRENT_USER = &H80000001 |
|---|
| 130 | | dim objReg, iRoot |
|---|
| 131 | | set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") |
|---|
| 132 | | |
|---|
| 133 | | select case strRoot |
|---|
| 134 | | case "HKLM" |
|---|
| 135 | | iRoot = HKEY_LOCAL_MACHINE |
|---|
| 136 | | case "HKCU" |
|---|
| 137 | | iRoot = HKEY_CURRENT_USER |
|---|
| 138 | | case else |
|---|
| 139 | | MsgFatal "RegEnumSubKeys: Unknown root: " & strRoot |
|---|
| 140 | | end select |
|---|
| 141 | | |
|---|
| 142 | | On Error Resume Next |
|---|
| 143 | | rc = objReg.EnumKey(iRoot, strKeyPath, arrSubKeys) |
|---|
| 144 | | if rc = 0 then |
|---|
| 145 | | RegEnumSubKeys = arrSubKeys |
|---|
| | 207 | dim iRoot |
|---|
| | 208 | iRoot = RegTransRoot(strRoot) |
|---|
| | 209 | RegEnumSubKeys = Array() |
|---|
| | 210 | |
|---|
| | 211 | if RegInit() then |
|---|
| | 212 | ' Must use ExecMethod to call the EnumKey method because of the context. |
|---|
| | 213 | Set InParms = g_objReg.Methods_("EnumKey").Inparameters |
|---|
| | 214 | InParms.hDefKey = RegTransRoot(strRoot) |
|---|
| | 215 | InParms.sSubKeyName = strKeyPath |
|---|
| | 216 | On Error Resume Next |
|---|
| | 217 | set OutParms = g_objReg.ExecMethod_("EnumKey", InParms, , g_objRegCtx) |
|---|
| | 218 | if OutParms.ReturnValue = 0 then |
|---|
| | 219 | RegEnumSubKeys = OutParms.sNames |
|---|
| | 220 | end if |
|---|
| 933 | | ' Check the registry next. |
|---|
| | 1039 | ' Check the registry next. (first pair is vista, second is pre-vista) |
|---|
| | 1040 | arrSubKeys = RegEnumSubKeys("HKLM", "SOFTWARE\Microsoft\Microsoft SDKs\Windows") |
|---|
| | 1041 | for Each strSubKey In arrSubKeys |
|---|
| | 1042 | str = RegGetString("HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder") |
|---|
| | 1043 | if (strPathPSDK = "") And (str <> "") then |
|---|
| | 1044 | if CheckForPlatformSDKSub(str) then strPathPSDK = str |
|---|
| | 1045 | end if |
|---|
| | 1046 | Next |
|---|
| | 1047 | arrSubKeys = RegEnumSubKeys("HKCU", "SOFTWARE\Microsoft\Microsoft SDKs\Windows") |
|---|
| | 1048 | for Each strSubKey In arrSubKeys |
|---|
| | 1049 | str = RegGetString("HKCU\SOFTWARE\Microsoft\Microsoft SDKs\Windows\" & strSubKey & "\InstallationFolder") |
|---|
| | 1050 | if (strPathPSDK = "") And (str <> "") then |
|---|
| | 1051 | if CheckForPlatformSDKSub(str) then strPathPSDK = str |
|---|
| | 1052 | end if |
|---|
| | 1053 | Next |
|---|
| | 1054 | |
|---|
| 1025 | | ' Check the registry next. |
|---|
| | 1141 | ' Check the registry next. (the first pair is for vista (WDK), the second for pre-vista (DDK)) |
|---|
| | 1142 | arrSubKeys = RegEnumSubKeys("HKLM", "SOFTWARE\Microsoft\WINDDK") '' @todo Need some sorting stuff here. |
|---|
| | 1143 | for Each strSubKey In arrSubKeys |
|---|
| | 1144 | str = RegGetString("HKLM\SOFTWARE\Microsoft\WINDDK\" & strSubKey & "\Setup\BUILD") |
|---|
| | 1145 | if (strPathDDK = "") And (str <> "") then |
|---|
| | 1146 | if CheckForWin2k3DDKSub(str, False) then strPathDDK = str |
|---|
| | 1147 | end if |
|---|
| | 1148 | Next |
|---|
| | 1149 | arrSubKeys = RegEnumSubKeys("HKCU", "SOFTWARE\Microsoft\WINDDK") '' @todo Need some sorting stuff here. |
|---|
| | 1150 | for Each strSubKey In arrSubKeys |
|---|
| | 1151 | str = RegGetString("HKCU\SOFTWARE\Microsoft\WINDDK\" & strSubKey & "\Setup\BUILD") |
|---|
| | 1152 | if (strPathDDK = "") And (str <> "") then |
|---|
| | 1153 | if CheckForWin2k3DDKSub(str, False) then strPathDDK = str |
|---|
| | 1154 | end if |
|---|
| | 1155 | Next |
|---|
| | 1156 | |
|---|