PRB: SaveSetting and GetSetting Not Available in Visual Basic 6.0 Webclass (IIS Application)

ID: Q248348


The information in this article applies to:
  • Microsoft Visual Basic Learning, Professional, and Enterprise Editions for Windows, version 6.0


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:

Application-defined or object-defined error
-and-
The VB Application identified by the event source logged this Application Project1: Thread ID: 317 ,Logged: MsgBox , Run-time error '5': Invalid procedure call or argument


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 Scripting Host for this purpose, or another component that provides this functionality.


STATUS

This behavior is by design.


MORE INFORMATION

The following is sample Windows Scripting Host code to read and write from the registry:


Private Sub WebClass_Start()
    Dim objWSH As Object
    
    Set objWSH = CreateObject("WScript.Shell")
    
    objWSH.RegWrite "HKLM\Software\MyApplication\strValue", "Some string value"
    objWSH.RegWrite "HKLM\Software\MyApplication\strReg\", 1, "REG_DWORD"

    Response.Write objWSH.RegRead("HKLM\Software\MyApplication\strValue") & "<P>"
    Response.Write objWSH.RegRead("HKLM\Software\MyApplication\strReg\") & "<P>"
    
    objWSH.RegDelete "HKLM\Software\MyApplication\strValue"
    objWSH.RegDelete "HKLM\Software\MyApplication\strReg\"
    objWSH.RegDelete "HKLM\Software\MyApplication\"
End Sub 


REFERENCES

You can download the Windows Scripting Host from the following location:

http://www.microsoft.com/msdownload/vbscript/scripting.asp

Additional query words:

Keywords : kbRegistry kbVBp600 kbWebClasses kbGrpASP kbDSupport
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbprb


Last Reviewed: January 13, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.