Link to home
Start Free TrialLog in
Avatar of njam_njam
njam_njam

asked on

Visual Basic programming

Is there any way how to write settings in registry, but in other places, not in the " vb and vba programms" group?
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Grab some useful examples at:
http://www.vbcode.com/asp/code.asp?lstCategory=Registry

cheers
Avatar of njam_njam
njam_njam

ASKER

Thanks, man! I'll try it as soon I'll get back home.
yes you can, but u need to know Win32 APIs;
try researching on the APIs:

RegCreateKeyEx
RegOpenKeyEx
RegSetValueEx
RegQueryValueEx
RegDeleteKey
RegCloseKey

with these functions, you could create you own registry keys, delete them, query a value, and set a value at your desired location..

the only problem is it takes time to learn them since there are STRUCTURES involved and there are lots of things to watch out for.... but i know you can do it

also, try this site

http://ltpb.8m.com/tutorial/Registry.html
ASKER CERTIFIED SOLUTION
Avatar of marconovaro
marconovaro

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
To your visual basic project add as reference the OCX wshom.ocx, then for example you can try this :
__________________________________________________________

Option Explicit

Private Sub Command1_Click()
    Dim WshSReg As New WshShell

    WshSReg.RegWrite "HKCU\Software\ACME\FortuneTeller\", 1, "REG_BINARY"
    WshSReg.RegWrite "HKCU\Software\ACME\FortuneTeller\MindReader", "Goocher!", "REG_SZ"
   
    MsgBox WshSReg.RegRead("HKCU\Software\ACME\FortuneTeller\MindReader")
   
    WshSReg.RegDelete "HKCU\Software\ACME\FortuneTeller\MindReader"
    WshSReg.RegDelete "HKCU\Software\ACME\FortuneTeller\"
    WshSReg.RegDelete "HKCU\Software\ACME\"
End Sub

__________________________________________________________

For more infos, just take a look here :
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsMthRegWrite.asp
Try this

SaveSetting(ProgramName as string, FolderName as string, Keyname as string, Value as string)

To read
GetSetting(ProgramName as string, Foldername as string, Keyname as string)

Example

Private sub cmdSaveReg_Click()
   dim a
   a = inputbox("Enter a string")
   savesetting "Test Program", "Settings", "String" _
      , a
end sub

Private sub cmdReadReg_Click()
   dim a as string
   a = getsetting("Test Program", "Settings", "String")
   msgbox a
end sub

This should solve your problem
These functions are all part of visual basic 6.0

Hope this Works.

Aaron.

Thank you !
njam_njam:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?