Click to See Complete Forum and Search --> : Registry Question


Mongoose
May 14th, 2001, 02:28 PM
All I want to do is grab the string value at the following registry path:

HKEY_LOCAL_MACHINE/SOFTWARE/JJIS/OLE_COMREG

I guess there is no way to use VB's GetSetting Method and that you must use the methods provided by a VB Module that comes with VB.

My problem is that I cannot add the module to my project. I need to get this key within a class. This class cannot use any other DLL's, Modules, Forms, etc.

The reason for this is because the class is used as an MTS object and I do not want it to use anthing else but itself.

Is there any way I could just define the 1 function I need to use and use it within my class? And if so which function, etc would I need to put in it?

Thankx,

coolbiz
May 14th, 2001, 03:32 PM
Import the RegQueryValue() as below:
Private Declare Function RegQueryValue Lib "advapi32.dll" Alias "RegQueryValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal lpValue As String, lpcbValue As Long) As Long

and note on the common KEYs:
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const HKEY_CURRENT_CONFIG = &H80000005
Private Const HKEY_CURRENT_USER = &H80000001
Private Const HKEY_DYN_DATA = &H80000006
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const HKEY_PERFORMANCE_DATA = &H80000004
Private Const HKEY_USERS = &H80000003


-Cool Bizs

Mongoose
May 14th, 2001, 03:51 PM
This sounds good. Could you show me an example as to how I can call this function to get the string value back from this location.

HKEY_LOCAL_MACHINE/SOFTWARE/JJIS/OLE_COMREG

Thankx,

coolbiz
May 14th, 2001, 06:01 PM
Well I did more searching on the function. The RegQueryValue() will only return you the DEFAULT value of a key and not the others. I've found a post on this forum that might help you. I've experimented with it and it worked but need a little tweaking to what you want. Anyway, check it out:
http://www.codeguru.com/cgi-bin/bbs/wt/showpost.pl?Board=vb&Number=19523&Search=true&Forum=vb&Words=regenumvalue&Match=Whole&Topic=&Searchpage=0&Limit=25

-Cool Bizs