I know this sounds like a really novice question, but I really don't know the function of the windows registry.
Is this something I should be using in my applications?
Thanks for any direction.
Nick
Printable View
I know this sounds like a really novice question, but I really don't know the function of the windows registry.
Is this something I should be using in my applications?
Thanks for any direction.
Nick
It's the place where applications save different settings. For example when you set the homepage of IE to a specific site it stores it in the registry and when needed it retrieves it.
The registry is a place to save short clippings of information. It takes the place of having ini files. If you have stuff, like registration information that you want to save, you can use the registry. If you want to save the size of the window for your app, you can save that in the registry. You can save default colors for you app. The registry pretty much lets you save anything you need to save for your app. There are a few basic statements built into VB. I think it's only in VB5 and VB6 but I'm not sure. The SaveSetting and the GetSetting statements allow you to save settings.
So, do you guys think you should use an ini file or the registry?
I have always used an ini file.
But I am always wanting to make my apps a little more professional.
I think the registry is the way to go, mostly because I haven't figured out the ini files. The registry is more proffessional, because it doesn't allow the causal user to tamper with the settings.
The registry stores pretty much everything about the system. All your registered fonts, ActiveX controls, COM objects, Outlook Express email addresses, the lot.
I'm still a bit confused on how to read and write to the registry. Ive looked over the API's and some examples but I still couldnt understand how to modify it to my needs, giving it the information on weather the user has registered they're program or not.
All I need is to write a value to a specific key when the user first runs the program (deeming the program as unregistered) and then when the user does register a different value will be set on that key so the next time it will read that value and if the value deeming the program as registered is there i could go from there.
It seems like it would be easy, I just havent had any experience with the registry API's before.
all advice is much appreciated. :wave:
I coded a simple way to do this with an .ini file, but ini files are too easy to find and modify by the user. Here is what I came up with:
VB Code:
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal_ lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String,_ ByVal nSize As Long, ByVal lpFileName As String)As Long Private Declare Function WritePrivateProfileString Lib "kernel32"_ Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any,_ ByVal lpFileName As String) As Long Private Sub Command1_Click() If Text1.Text = "1337" Then WritePrivateProfileString App.Title, "KeyName", "Registered", "c:\test.ini" 'Create a buffer Ret = String(255, 0) 'Retrieve the string NC = GetPrivateProfileString(App.Title, "KeyName", "Default", Ret, 255, "C:\test.ini") 'NC is the number of characters copied to the buffer If NC = 10 Then registered = True End If If registered = True Then Form1.Caption = "Registered!!" End Sub Private Sub Command2_Click() Unload Me End Sub Private Sub Form_Load() Dim Ret As String, NC As Long 'Create a buffer Ret = String(255, 0) 'Retrieve the string NC = GetPrivateProfileString(App.Title, "KeyName", "Default", Ret, 255, "C:\test.ini") 'NC is the number of characters copied to the buffer If NC = 0 Then 'Write the setting to the file (c:\test.ini) under ' Project1 -> Keyname WritePrivateProfileString App.Title, "KeyName", "UnRegistered", "c:\test.ini" End If If NC = 12 Then registered = False If registered = False Then Form1.Caption = "UnRegistered!" If NC = 10 Then registered = True If registered = True Then Form1.Caption = "Registered!!" End Sub
Two reasons I dont want to use this..1. unless I learn how to encrypt what is entered into the file (which would be "registered" or "unregistered") any user who finds the file can easily modify it to what they need. Another reason i dont want to use an ini is, I just merely dissassembled my own program and its by far clear to the eye where the ini file is located..so I couldnt hide it.
You shouldnt 'hijack' someone elses thread. If you have a question, start a new thread.
Anyway, a search would give you the results you need:
http://www.vbforums.com/showthread.p...SetStringValue
lol hijack, dont take it too seriously. They asked a completely general question about the registry so i figured why waste space when i can ask about the registry here too..
As i said, i had already looked at other examples that i found thru my searches..but I couldnt modify any of them to my needs so I was hopeing it wouldnt be too much of a problem for someone to create one.
Also, that link you gave me goes to a topic that is of no help..They link to another site "www.vbworld.com/registry" but that gives me a "file not found" error.
Delphi uses its own TRegistry class, all you have to do is:Quote:
Originally Posted by Resilience
TRegistry.Open.String 'Blah'
:thumb:
sorry i dont know Delphi, im using vb6 not sure if it would work all the same..Anyway, does anybody know how to write what i need to the registry? thanks.
Here you go. Use this module.
does anyone know if the registry is stored in a certain file.and if so where is it
I'm not sure but I think it is the USER.DAT