Microsoft KB Archive/99322

= ACC: Calling RegQueryValue to Get an OLE Object Class Name =

Article ID: 99322

Article Last Modified on 5/9/2003

-

APPLIES TO


 * Microsoft Access 1.0 Standard Edition
 * Microsoft Access 1.1 Standard Edition
 * Microsoft Access 2.0 Standard Edition

-



This article was previously published under Q99322



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  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 &quot;shell&quot; (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:  ControlSource: =GetObjectName (&quot;PBRUSH&quot;)

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

