|
|
Title | Serialize and deserialize objects in VB6 |
Keywords | serialize, deserialize, XML, typelib, type information |
Categories | Tips and Tricks |
|
|
Ariel Canievsky has this tip:
There's some API functions that let you to modify the Registry, like
RegOpenKeyEx, RegQueryValueEx, RegCloseKey and RegEnumValue.
What I need was to access to the HKEY_CLASSES_ROOT, where you find the
file types. I couldn't access to this part of the Registry through these
API, even using the constant HKEY_CLASSES_ROOT = &H80000000.
So, I have to think another way of adding data to the Registry.
When you
want to export some data from the Registry, the application Registry Editor
have an option that makes a file with the extension .REG, and saves all the
tree you want to a text file.
My program creates a .REG file, and then executes it with the Registry
Editor to add the information.
|
|
Open App.Path & "\RG.reg" For Output As #1
Print #1, "REGEDIT4"
Print #1, ""
'tExt is the variable extension, like .VBH
Print #1, "[HKEY_CLASSES_ROOT\." & tExt & "]"
'@ means the default data for the Registry Editor
Print #1, "@=" & Chr(34) & tExt & "file" & Chr(34)
Print #1, ""
'an extension in the Registry is divided in 2 keys
Print #1, "[HKEY_CLASSES_ROOT\" & tExt & "file]"
'Chr(34)=quotation marks, because it's String data
Print #1, "@=" & Chr(34) & T & Chr(34)
|
|
Then, if you want to assign an icon to your file type,
|
|
Print #1, ""
Print #1, "[HKEY_CLASSES_ROOT\" & tExt & "file\DefaultIcon]"
Print #1, "@=" & Chr(34) & _
"C:\\Windows\\System\\Shell32.dll,1" & Chr(34)
Close#1
|
|
Shell "RegEdit " & App.Path & "\RG.reg", vbNormalFocus 'Execute the file
with the Registry
Note: You can use this technique, not only for HKEY_CLASSES_ROOT, and
not only for String data. If you have questions, you can extract from the
Registry some information to a file, and then see the file to know how is
this "language".
|
|
-->
|
|