advapi32.dll - win95/98/NT - writing to registry

Hey guys.  I am writing to the registry using advapi32.dll.  These are the functions I've been using.
------------------
Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData As Long) As Long
Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) As Long

Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long
Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal reserved As Long, ByVal dwType As Long, lpData As Byte, ByVal cbData As Long) As Long
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
--------------------

Using these functions work great in win95 and 98 but I just found out that they do not work in Win NT.  Can someone give me some information on this?  I need the program to write in NT registry as well.  

I need to be able to create my own header and keys.  These are the only functions I know that allow me to do this.  Thanks!
LVL 3
grooneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

srirambmCommented:
I also use the same thing in win95 and NT. Maybe you need a service pack for NT
if u dont have atleast SP4.
0
AnswerTheManCommented:
using the registry class you can easily do anything woth registry :


If you use vb6, then add 'registry access functions' into your reference.

add the following code into your form

Option Explicit

Private Sub Command1_Click()
Dim x As New Registry

x.UpdateKey HKEY_CURRENT_USER, "Control panel\desktop", "SCRNSAVE.EXE", "your screensaver path"
Set x = Nothing
End Sub
0
AnswerTheManCommented:
PS : that was just an example of replacing the desktop.
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

grooneAuthor Commented:
Sorry ATM was away.  Will check it out pronto.
0
grooneAuthor Commented:
Hey AnswerTheMan, I've been trying to use this references but for some reason I cant seem to get it to work properly.  Could you give me an example of creating a registry root key, key and value OR give me a location that explains this procedure?
0
grooneAuthor Commented:
Ack!  I just found out my computer here at home does not have "Registry Access Functions" what is the dll or OCX for that?
0
AnswerTheManCommented:
1. in you VisualStudio6.0 CD1 :
   the dll is in :
   COMMON\TOOLS\APE\Regtool5.dll

2. Copy it to your win\sys dir

3. my code in last comment had a mistake

4. here is the right one :

Option Explicit

Private Sub Form_Load()
    Dim x As New Registry
    x.UpdateKey HKEY_CURRENT_USER, "Control panel\desktop", "Wallpaper", "i:\winnt\winnt256.bmp"
    Set x = Nothing
End Sub

5. of course - you should enter your OWN path to the bmp you want.

6. run the prog. you can check and find that the above key was cahnged by this code.

7. good luck

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AnswerTheManCommented:
PS :
 ADD a refernce to this DLL in your project !!!
(project->refrences... browse for it)
0
grooneAuthor Commented:
Ack!  I don't have visual studio, I simply have the visual studio component visual basic 6.0.  Where can I locate Regtool5.dll at other then on the visual studio cd?
0
AnswerTheManCommented:
post you email - i'll send it within 24 hours
0
grooneAuthor Commented:
rbennett@zebra.net





thanks
0
AnswerTheManCommented:
have just send it.
0
grooneAuthor Commented:
This only allows for the update and delete of already exisitng keys.  I need to create roots and the structure inside them.
0
grooneAuthor Commented:
ATM, this works.  I can work with this.  Thanks for your help, but if you know a way I can create hkey roots in nt please let me know.  It just makes it easier to clean the registry and search the registry if you create your own hkey.  
0
AnswerTheManCommented:
sure.

http://msdn.microsoft.com/vstudio/downloads/vsi/download.asp

using this tool to package and deploy applications - you can VISUALLY using only mouse clicks create whatever you want on TARGET MACHINE registry, just as you create folders and files in WinddowsExplorer.
0
PatTheRouckyCommented:

I have the same problem then you.  I'm also interested in your dll Regtool5.dll because it is not include on the Visual Basic professional CD.

Can you send it to me please ?

hanp01@gel.usherb.ca

Thanks in advance ...                Patrick Hanchay




0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.