Microsoft KB Archive/250673

From BetaArchive Wiki

Article ID: 250673

Article Last Modified on 7/16/2004


  • Microsoft Internet Information Server 4.0
  • Microsoft Internet Information Services 5.0
  • Microsoft Visual Basic 5.0 Learning Edition
  • Microsoft Visual Basic 6.0 Learning Edition
  • Microsoft Visual Basic 5.0 Professional Edition
  • Microsoft Visual Basic 6.0 Professional Edition
  • Microsoft Visual Basic 5.0 Enterprise Edition
  • Microsoft Visual Basic 6.0 Enterprise Edition
  • Microsoft Windows NT 4.0
  • Microsoft Windows 2000 Standard Edition

This article was previously published under Q250673

IMPORTANT: This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base:

256986 Description of the Microsoft Windows Registry


If you create an ActiveX .dll file in Visual Basic that uses the GetSetting or SaveSetting functions, you may get an error message when you use these functions from an Active Server Page running under Internet Information Server (IIS) on Windows NT 4.0 or Windows 2000. The error that occurs will be "Invalid Procedure Call or Argument" (Error 5) from within the component, or "error '800a0005' Invalid procedure call or argument" from the ASP page that calls the component.


When GetSetting or SaveSetting are called, the information that they read or write is usually stored at HKEY_CURRENT_USER\Software\VB and VBA Program Settings. Components that run under an account that is a member of the "guests" group do not have an HKEY_CURRENT_USER hive loaded, so they attempt to write to HKEY_USERS\.DEFAULT\Software\VB and VBA Program Settings. Members of the guests group do not have permission to write to this registry key.


WARNING: If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.

To successfully write to the registry, you must ensure that the IUSR_MACHINENAME account has the proper permissions to the registry location in question.

On Windows NT version 4.0, you can use the standard Win32 registry APIs to write information to an area in the registry where the guests group has access (for example, HKEY_LOCAL_MACHINE, by default, allows everyone to read/write it). You cannot use the GetSetting/SaveSettings Visual Basic API to accomplish this.

To provide greater security, Windows 2000 limits the default access to registry to members of the guests group. Therefore, on Windows 2000, you must ensure that any area of the registry that you want to write to allows the IUSR_MACHINENAME the proper access.


This behavior is by design.


Steps to Reproduce Behavior

  1. Create a new ASP page with the following code:

            dim obj
            set obj = Server.CreateObject("SaveSettingTest.cSaveSetting")
            set obj = nothing
            response.write "Test has been performed.  Check your Registry to see if changes have been made."
  2. Save the page as Test.asp in your Inetpub\Wwwroot folder.
  3. With Visual Basic 6.0, create an ActiveX .dll file.
  4. From the Project menu, click Properties, and then select Unattended Execution and retained in memory.
  5. Rename Class1 as cSaveSetting.
  6. Rename the project from project1 to SaveSettingTest.
  7. Paste the following code into cSaveSetting:

    Public Sub Save()
        SaveSetting "MyApp", "MySection", "MyKey", "MyValue"
    End Sub
  8. Compile the .dll file.
  9. Using your browser, navigate to http://localhost/Test.asp.
  10. Under IIS 5, a message appears that is similar to:

    Error Type:
    SaveSettingTest (0x800A0005)
    Invalid procedure call or argument
    /test.asp, line 4

    Under IIS 4, the message is similar to:

    SaveSettingTest error '800a0005'

    Invalid procedure call or argument

    /test.asp, line 4


For additional information, click the article number below to view the article in the Microsoft Knowledge Base:

145679 HOWTO: Use the Registry API to Save and Retrieve Setting

Keywords: kbprb KB250673