Microsoft KB Archive/193465: Difference between revisions

From BetaArchive Wiki
(stage2)
 
m (Text replacement - """ to """)
 
(7 intermediate revisions by the same user not shown)
Line 24: Line 24:
== SYMPTOMS ==
== SYMPTOMS ==


If a Windows 95 or Windows 98 computer is connected to a remote Windows 95 or Windows 98 registry and hKey is a handle to an open key in that remote registry, RegQueryInfoKey( hKey, ..., &cbMaxSubKeyLen, ... ) returns only half the actual length of the longest subkey of hKey.
If a Windows 95 or Windows 98 computer is connected to a remote Windows 95 or Windows 98 registry and hKey is a handle to an open key in that remote registry, RegQueryInfoKey( hKey, ..., &cbMaxSubKeyLen, ... ) returns only half the actual length of the longest subkey of hKey.


<br />
<br />
Line 49: Line 49:
Before reproducing this problem, you must make sure that the Remote Administration Services is installed on both Windows 95 or Windows 98 computers. Verify that Microsoft Remote Registry is installed by selecting Network from the Control Panel and scrolling through the list of installed components. For additional information, please see the following article in the Microsoft Knowledge Base:
Before reproducing this problem, you must make sure that the Remote Administration Services is installed on both Windows 95 or Windows 98 computers. Verify that Microsoft Remote Registry is installed by selecting Network from the Control Panel and scrolling through the list of installed components. For additional information, please see the following article in the Microsoft Knowledge Base:


<blockquote>[[mk:@MSITStore:kbwin98.chm::/Source/win98x/q141460.htm|Q141460]] HOWTO: Install Remote Administration Services</blockquote>
<blockquote>[[../141460|Q141460]] HOWTO: Install Remote Administration Services</blockquote>
Compile and run the following program from a command prompt on a Windows 95 or Windows 98 computer and pass a parameter identifying another Windows 95 or Windows 98 computer. The reported length of the longest subkey will be half the actual length of that subkey.
Compile and run the following program from a command prompt on a Windows 95 or Windows 98 computer and pass a parameter identifying another Windows 95 or Windows 98 computer. The reported length of the longest subkey will be half the actual length of that subkey.


=== Sample Code ===
=== Sample Code ===


<pre class="CODESAMP">  #include &lt;windows.h&gt;
<pre class="CODESAMP">  #include <windows.h>
   #include &lt;stdio.h&gt;
   #include <stdio.h>


   void main( int argc, char* argv[] ) {
   void main( int argc, char* argv[] ) {


       if (argc &lt; 2) {
       if (argc < 2) {
           printf(&quot;Usage: RegConnectRegistry \\\\server&quot;);
           printf("Usage: RegConnectRegistry \\\\server");
       } else {
       } else {


Line 67: Line 67:


           LONG lResult = RegConnectRegistryA( argv[1], HKEY_LOCAL_MACHINE,
           LONG lResult = RegConnectRegistryA( argv[1], HKEY_LOCAL_MACHINE,
               &amp;hRemoteKey);
               &hRemoteKey);


           if (lResult == ERROR_SUCCESS) {
           if (lResult == ERROR_SUCCESS) {


               printf( &quot;Connected to remote %s registry.\n&quot;, argv[1] );
               printf( "Connected to remote %s registry.\n", argv[1] );


               lResult = RegOpenKeyEx( hRemoteKey, &quot;SOFTWARE&quot;, 0,
               lResult = RegOpenKeyEx( hRemoteKey, "SOFTWARE", 0,
                   KEY_ALL_ACCESS, &amp;hKey);
                   KEY_ALL_ACCESS, &hKey);


               if (lResult == ERROR_SUCCESS) {
               if (lResult == ERROR_SUCCESS) {
Line 80: Line 80:
                   DWORD cbMaxSubKeyLen;
                   DWORD cbMaxSubKeyLen;


                   printf( &quot;Key opened.\n&quot; );
                   printf( "Key opened.\n" );


                   lResult = RegQueryInfoKey( hKey, NULL, NULL, NULL,
                   lResult = RegQueryInfoKey( hKey, NULL, NULL, NULL,
                       NULL, &amp;cbMaxSubKeyLen, NULL, NULL, NULL, NULL, NULL,
                       NULL, &cbMaxSubKeyLen, NULL, NULL, NULL, NULL, NULL,
                       NULL );
                       NULL );


                   if (lResult == ERROR_SUCCESS) {
                   if (lResult == ERROR_SUCCESS) {
                       printf( &quot;The max subkey length of %s is %d.\n&quot;,
                       printf( "The max subkey length of %s is %d.\n",
                           &quot;HKEY_LOCAL_MACHINE\\SOFTWARE&quot;, cbMaxSubKeyLen );
                           "HKEY_LOCAL_MACHINE\\SOFTWARE", cbMaxSubKeyLen );
                   }
                   }


Line 94: Line 94:


               } else {
               } else {
                   printf( &quot;RegOpenKey() failed.\nError: %d\n&quot;, lResult );
                   printf( "RegOpenKey() failed.\nError: %d\n", lResult );
               }
               }


Line 100: Line 100:


           } else {
           } else {
               printf( &quot;RegConnectRegistry( %s ) failed.\nError: %d\n&quot;,
               printf( "RegConnectRegistry( %s ) failed.\nError: %d\n",
                   argv[1], lResult );
                   argv[1], lResult );
           }
           }
Line 112: Line 112:
For additional information, please see the following article in the Microsoft Knowledge Base:
For additional information, please see the following article in the Microsoft Knowledge Base:


<blockquote>[[../win32sdk/q193463.htm|Q193463]] HOWTO: Troubleshoot Remote Registry Access on Windows 95/98</blockquote>
<blockquote>[[../193463|Q193463]] HOWTO: Troubleshoot Remote Registry Access on Windows 95/98</blockquote>
Additional query words:
Additional query words:



Latest revision as of 12:43, 21 July 2020

BUG: RegQueryInfoKey Returns Length Div 2 for cbMaxSubKeyLen

Q193465



The information in this article applies to:


  • Microsoft Win32 Application Programming Interface (API), included with:
    • Microsoft Windows 95
    • Microsoft Windows 98





SYMPTOMS

If a Windows 95 or Windows 98 computer is connected to a remote Windows 95 or Windows 98 registry and hKey is a handle to an open key in that remote registry, RegQueryInfoKey( hKey, ..., &cbMaxSubKeyLen, ... ) returns only half the actual length of the longest subkey of hKey.



RESOLUTION

Until this bug is fixed, it is best to allocate a buffer twice as large as cbMaxSubKeyLen.



STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION

Steps to Reproduce Behavior

Before reproducing this problem, you must make sure that the Remote Administration Services is installed on both Windows 95 or Windows 98 computers. Verify that Microsoft Remote Registry is installed by selecting Network from the Control Panel and scrolling through the list of installed components. For additional information, please see the following article in the Microsoft Knowledge Base:

Q141460 HOWTO: Install Remote Administration Services

Compile and run the following program from a command prompt on a Windows 95 or Windows 98 computer and pass a parameter identifying another Windows 95 or Windows 98 computer. The reported length of the longest subkey will be half the actual length of that subkey.

Sample Code

   #include <windows.h>
   #include <stdio.h>

   void main( int argc, char* argv[] ) {

       if (argc < 2) {
           printf("Usage: RegConnectRegistry \\\\server");
       } else {

           HKEY hRemoteKey = NULL;
           HKEY hKey = NULL;

           LONG lResult = RegConnectRegistryA( argv[1], HKEY_LOCAL_MACHINE,
               &hRemoteKey);

           if (lResult == ERROR_SUCCESS) {

               printf( "Connected to remote %s registry.\n", argv[1] );

               lResult = RegOpenKeyEx( hRemoteKey, "SOFTWARE", 0,
                   KEY_ALL_ACCESS, &hKey);

               if (lResult == ERROR_SUCCESS) {

                   DWORD cbMaxSubKeyLen;

                   printf( "Key opened.\n" );

                   lResult = RegQueryInfoKey( hKey, NULL, NULL, NULL,
                      NULL, &cbMaxSubKeyLen, NULL, NULL, NULL, NULL, NULL,
                      NULL );

                   if (lResult == ERROR_SUCCESS) {
                       printf( "The max subkey length of %s is %d.\n",
                          "HKEY_LOCAL_MACHINE\\SOFTWARE", cbMaxSubKeyLen );
                   }

                   RegCloseKey( hKey );

               } else {
                   printf( "RegOpenKey() failed.\nError: %d\n", lResult );
               }

               RegCloseKey( hRemoteKey );

           } else {
               printf( "RegConnectRegistry( %s ) failed.\nError: %d\n",
                  argv[1], lResult );
           }
       }
   } 



REFERENCES

For additional information, please see the following article in the Microsoft Knowledge Base:

Q193463 HOWTO: Troubleshoot Remote Registry Access on Windows 95/98

Additional query words:

Keywords : kbKernBase kbRegistry kbOSWin95bug kbOSWin98bug
Issue type : kbbug
Technology : kbAudDeveloper kbWin32sSearch kbWin32API


Last Reviewed: December 16, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.