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

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:

Q99319 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 : kbole kbprg IntpOle
Version : WINDOWS:1.0,1.1,2.0
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: October 21, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.