|
-
Jul 4th, 2001, 10:20 AM
#1
Thread Starter
Addicted Member
Registry (This is one for the Guru's)
Does anyone know how to rename a registry key using API's?
-
Jul 4th, 2001, 11:04 AM
#2
Guru
Unfortunately, this is harder than it looks 
I can think of two solutions:
First Solution I Could Think Of
Use RegEnumKeyEx and RegEnumValue to enumerate all the subkeys and values. Then, delete the key using RegDeleteKey. Finally, use RegCreateKeyEx to recreate the key with another name, and RegSetValueEx to set all the values back where they were. 
Second Solution I Could Think Of
Use GetTempPath and GetTempFileName to get a temporary file name. Then, use RegSaveKey to save your key and all its subkeys in the temporary file. Delete the key from the registry using RegDeleteKey. Load the temporary file into a string buffer, and use the Replace function to replaces all instances of "OldKeyName" with "NewKeyName", and save the result back into the temporary file. Then, call RegRestoreKey to load the temporary file back into the registry, and finally, delete the temporary file. 
You'll get over it
-
Jul 4th, 2001, 11:31 AM
#3
-
Jul 5th, 2001, 04:15 AM
#4
Thread Starter
Addicted Member
I've just search the Web, looking for the SHCopyKey declare statement and I can't find it anywhere.
Has anyone got any details on how to declare the SHCopyKey and SHDeleteKey API's, and how to use them.
-
Jul 5th, 2001, 09:05 AM
#5
Guru
First, you can't ignore the "Reserved" parameter in SHCopyKey.
Second, these function have an ANSI version (which you want) and a Unicode version (which you don't want), so you should add an Alias to the ANSI version.
Oh well 
VB Code:
Option Explicit
Private Declare Function SHCopyKey Lib "shlwapi" Alias "SHCopyKeyA" (ByVal hkeySrc As Long, ByVal szSrcSubKey As String, ByVal hkeyDest As Long, ByVal fReserved As Long) As Long
Private Declare Function SHDeleteKey Lib "shlwapi" Alias "SHDeleteKeyA" (ByVal hkey As Long, ByVal pszSubKey As String) As Long
-
Jul 6th, 2001, 04:00 AM
#6
Thread Starter
Addicted Member
-
Jul 6th, 2001, 01:07 PM
#7
Monday Morning Lunatic
Why wouldn't you want the Unicode version? It's better to use the Unicode version if your program is run on NT.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jul 6th, 2001, 03:09 PM
#8
Guru
Because the Unicode version of the function is not even implemented on Win9x, so if you use the Unicode version then your app would be limited to WinNT only.
It'll get over it
-
Jul 6th, 2001, 03:14 PM
#9
Monday Morning Lunatic
I didn't mean *just* Unicode...it's better practice to call the Unicode versions if you're running on NT because it saves an extra thunk call.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jul 7th, 2001, 07:42 AM
#10
Registered User
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|