ACC: Calling RegQueryValue() to Get an OLE Object Class Name

Last reviewed: June 6, 1997
Article ID: Q99322
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0

SUMMARY

Advanced: Requires expert coding, interoperability, and multiuser skills.

The RegQueryValue() function, found in the Microsoft Windows SHELL.DLL file, uses an OLE ClassKey (such as PBRUSH or MSGRAPH) to obtain the information about that class from the REG.DAT file.

This article describes the way the RegQueryValue() function obtains the Object Class Name from the OLE Registration Database REG.DAT file.

Although only the procedure to obtain the Object Class Name is described here, other information, including the current location of the OLE server and the types of <Primary VERBS> available to the object, is also available.

MORE INFORMATION

NOTE: In the following sample code, an underscore (_) is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code in Access Basic.

   Declare Function RegQueryValue Lib "shell" (ByVal hkey&, _
      ByVal SubKeyStr$, ByVal QueryStr$, Buffsize&) As Long

   Function GetObjectName$ (TheClassKey$)
      Dim ClassName$
      ClassName$ = Space$(255)
      X& = CLng(Len(ClassName$))
      cb = RegQueryValue(1, TheClassKey$, ClassName$, X&)
      GetObjectName$ = ClassName$
   End Function

The sample function above declares a string to pass as a parameter for a return value in the RegQueryValue() function. RegQueryValue() has the following four parameters:

   HKEY:        The handle to a key that defines what type of
                information you want to retrieve

   lpszSubKey:  A string that contains the OLE ClassKey that you want
                to look up

   lpszValue:   A string in which to place the resulting value

   lpcb:        The maximum length of the resulting string

To use the sample function GetObjectName(), create a control on a form with the following properties:

   ControlName: <ObjName>
   ControlSource: =GetObjectName ("PBRUSH")

Any appropriate OLE ClassKey in the REG.DAT OLE database can be passed to the function.

REFERENCES

For more information about finding the ClassKey of an embedded object, please see the following article here in the Microsoft Knowledge Base:

    ARTICLE-ID: Q99319
    TITLE:      ACC: Finding the OLE ClassKey of an Embedded Object (1.x,
                2.0)

Microsoft Windows "Programmer's Reference," version 3.1, Volume 2, page 282


Additional query words: classname class key
Keywords : IntpOle kbole kbprg PgmApi
Technology : kbole
Version : 1.0 1.1 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 6, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.