Microsoft KB Archive/248348: Difference between revisions
(importing KB archive) |
m (Text replacement - "<" to "<") |
||
Line 101: | Line 101: | ||
objWSH.RegWrite "HKEY_LOCAL_MACHINE\Software\MyApplication\strReg\", 1, "REG_DWORD" | objWSH.RegWrite "HKEY_LOCAL_MACHINE\Software\MyApplication\strReg\", 1, "REG_DWORD" | ||
Response.Write objWSH.RegRead("HKEY_LOCAL_MACHINE\Software\MyApplication\strValue") & " | Response.Write objWSH.RegRead("HKEY_LOCAL_MACHINE\Software\MyApplication\strValue") & "<P>" | ||
Response.Write objWSH.RegRead("HKEY_LOCAL_MACHINE\Software\MyApplication\strReg\") & " | Response.Write objWSH.RegRead("HKEY_LOCAL_MACHINE\Software\MyApplication\strReg\") & "<P>" | ||
objWSH.RegDelete "HKEY_LOCAL_MACHINE\Software\MyApplication\strValue" | objWSH.RegDelete "HKEY_LOCAL_MACHINE\Software\MyApplication\strValue" |
Revision as of 09:00, 21 July 2020
Article ID: 248348
Article Last Modified on 8/6/2007
APPLIES TO
- Microsoft Visual Basic 6.0 Learning Edition
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 6.0 Enterprise Edition
This article was previously published under Q248348
SYMPTOMS
Calls to the SaveSetting, GetSetting, DeleteSetting or GetAllSettings methods in a Visual Basic 6.0 WebClass [Internet Information Server (IIS) Application] return the following errors in the Application log of the Windows NT Event Viewer:
-and-
CAUSE
The SaveSetting, GetSetting, DeleteSetting, and GetAllSettings methods in Visual Basic are not available in Visual Basic 6.0 WebClasses (IIS Applications) when running in a compiled state. You should not use these methods in your WebClass applications.
Visual Basic 6.0 WebClasses run under the Internet Information Server service. SaveSetting, GetSetting, DeleteSetting, and GetAllSettings manage registry keys in the HKEY_CURRENT_USER registry hive. The Internet Information Server service does not have an HKEY_CURRENT_USER registry hive available. As a result, the error occurs when calling these methods.
RESOLUTION
If you need to read and write to the registry, you need to write to and read from HKEY_LOCAL_MACHINE or HKEY_USERS, which are available to the Internet Information Server service. You may use the Windows Script Host for this purpose, or another component that provides this functionality.
STATUS
This behavior is by design.
MORE INFORMATION
The following is sample Windows Script Host code to read and write from the registry:
Private Sub WebClass_Start() Dim objWSH As Object Set objWSH = CreateObject("WScript.Shell") objWSH.RegWrite "HKEY_LOCAL_MACHINE\Software\MyApplication\strValue", "Some string value" objWSH.RegWrite "HKEY_LOCAL_MACHINE\Software\MyApplication\strReg\", 1, "REG_DWORD" Response.Write objWSH.RegRead("HKEY_LOCAL_MACHINE\Software\MyApplication\strValue") & "<P>" Response.Write objWSH.RegRead("HKEY_LOCAL_MACHINE\Software\MyApplication\strReg\") & "<P>" objWSH.RegDelete "HKEY_LOCAL_MACHINE\Software\MyApplication\strValue" objWSH.RegDelete "HKEY_LOCAL_MACHINE\Software\MyApplication\strReg\" objWSH.RegDelete "HKEY_LOCAL_MACHINE\Software\MyApplication\" End Sub
REFERENCES
You can download the Windows Script Host from the following location:
Keywords: kbprb kbregistry kbwebclasses KB248348