Link to home
Start Free TrialLog in
Avatar of tomlinsorm
tomlinsorm

asked on

Visual Basic question

How can I use the RegLoadKey API call in a Visual Basic 4.0 to load a Windows NT 4.0 user profile hive?  If possible, please give a detailed example.
Avatar of Chizl
Chizl
Flag of United States of America image

I have all the code you need for accessing registries using VB5..   I'm sure that the code is easlily converted to VB4 since it is all 32bit API calls anyway..  I put in on http://www.karland.com/registry/ 

L8r,
Chizl
Avatar of tomlinsorm
tomlinsorm

ASKER

On going to http://www.karland.com/registry, I found no mention whatsoever that mentioned RegLoadKey or anything else to load an NT 4.0 user profile hive.
32bit call to a registry is a 32bit call.  I'm not using RegLoadKey, but there are other 32bit registry calls there that do the exact same thing..

L8r,
Chizl
What exactly is it that you want to do? Will it be enough if I write you a sample on how to load it and how to remove it from memory when done with it?
My apologies if I wasn't specific enough.  I would like to write a VB4 program that will load and unload an abitrary user's profile hive (c:\winnt\profiles\username\ntuser.dat)into the registry under the HKEY_USERS\username key.  In addition, I hope to be able to do this from the command line.  All I need to know are the command(s) to load the hive.  It's similiar to what can be accomplished by going to regedt32, selecting HKEY_USERS, going to File and clicking "Load Hive", giving it the path c:\winnt\profiles\username\ntuser.dat and telling WinNT it's arbitrary name under the KEY_USERS key (ie. the username).  Any and all help has been and is appreciated.  

ASKER CERTIFIED SOLUTION
Avatar of y96andha
y96andha

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you, y96andha, for your answer.  It went above and beyond the required.
y96andha...
Is this also possible in Win95?

L8r,
Chizl
The docs say that the RegLoadKey function is supported in Windows 95. So it should be possible. The other functions are not supported though, so I guess that just
 Debug.Print "RegLoadKey "; RegLoadKey(HKEY_USERS, "tobias" & Chr(0), "f:\winnt\profiles\Tobias\ntuser.dat" & Chr(0))
should be enough on Win95. I haven't tested it though.
FYI, I was not able to get it to work under Win95, even when I renamed the "ntuser.dat" file to "ntuser.".  I may have been going about it the wrong way, though.
I don't think you can load an NT profile under Win95, but a Win95 profile should be fine. NT has security settings for the registry hives, Win95 has not, so the file formats are probably different between them.