Save To Registry
I'm trying to save a Combo Box List in the Registry. My code creates the place in the Registry, but under Data, in the Registry there is nothing. Also I'm not sure if my code is right to load the list with Form Load. This is what I have so far. Thanks for any help.
_____________________________________________________________ Private Sub OKButton_Click()
Form1.combo.AddItem AddExercisedlg.Addtxt, AddExercisedlg.ListIndex SaveSetting "Max Workout Program", "Exercise", "List", Form1.combo.List(Form1.combo.ListIndex) Unload Me
End Sub _____________________________________________________________
Sub LoadList()
GetSetting "Max Workout Program", "Exercise", "List", combo.List(combo.ListIndex) End Sub
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Save To Registry Or Save To .txt Or .ini File?
Perhaps I should have posted this as a poll, but hey-ho...
Right, following on from a few points made (see thread http://www.codeguru.com/forum/showt...threadid=236942 if you are wondering where these points were made) I was wondering whether it is better to save settings such as window positions and size, and other settings specific to your application to the registry, or in a .txt or .ini file.
Personally, I have always saved all window positions and size settings (and sometimes a few other things) to the registry, and then for applications where I need a lot of settings saved I have used .txt files (provided no database is involved).
Where do you draw the line in saving information to the registry and start saving to another file? Or, do you do just one and not the other? And, are there any speed advantages in either, or is it much the same?
Thanks for any input.
Save In Registry As A Name
I have been using this code from the API-Guide. I am new to API's in general.
It creates a REG_DWORD in the directory I want.
How do I name the entry, for example I would like to store the position of the form when it is closed, with Left, Top, Height, Width?
vb Code:
Dim Result As Long'Check if the specified key existsRegOpenKeyEx HKEY_LOCAL_MACHINE, vSubKey, 0, KEY_ALL_ACCESS, Ret'If the key doesn't exist, we create itIf Result = 0 Then 'Create a new key RegCreateKeyEx HKEY_LOCAL_MACHINE, vSubKey, 0, "REG_DWORD", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, ByVal 0&, Result, Ret If Result = 0 Then MsgBox "Error while creating the Key!!" Exit Sub End IfEnd If
This runs and creates the entry, but when I run the app a second time, it doesn't create another entry, so I guess I have to insert a name, or text somewhere.
Save To Registry
I need code that will save information to registry. For example, if the user clicks a check box everytime the application is loaded then the check box is ticked, however if they untick the check box it will load with the check boxes unticked.
I also need this for Option boxes, Text boxes.
Please help
Save In Registry
Here is what I have
It's should be simple
Private Sub cmdOutput_Click()
GetSetting App.Title, "FMC", "Output", Default
dlgSelectOutput.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*"
dlgSelectOutput.ShowOpen
lblOutput = dlgSelectOutput.FileName
SaveSetting App.Title, "FMC", "Output", strOutputFile
End Sub
I'm trying to make it so that the dialogue box always heads to the same path even after the program has been exited.
So if I'm using the program, select a file from the desktop, and shut down my computer, the next time I come back on the dialogue box goes for the desktop instead of VB98....
Save To Registry
I need to save data to the registry. I know about the SaveSetting command but it only saves under the "VB and VBA Program Settings".
I need to save under undet this key.
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun]
I'm making a system service app and thats why i want it to load at start up.
/Anders
Save To Registry
I have some options I'd like the user to be able to set and make default for future uses of the software. I would like the settings to save to the registry when the user clicks a checkbox. Here are the vlaues I need:
Which of 2 option buttons is checked (radMale or radFemale) , the value of a combobox called 'delay', and the value of a combobox called 'scan'
please help.
Save A RECT In Registry
Is it possible to save a RECT structure in the Registry. I thought I could save my form's location this way instead of calling in each position property
In a module:
Code:
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
'Delclare Functions.....
' Write / Create a Registry value.
' Use KeyName = "" for the default value.
' Supports only DWORD, SZ, and BINARY value types.
Sub SetRegistryValue(ByVal hKey As Long, ByVal KeyName As String, ByVal ValueName As String, _
ByVal KeyType As Integer, ByRef value As Variant)
Dim handle As Long, lngValue As Long
Dim strValue As String
Dim binValue() As Byte, length As Long
' Open the key, exit if not found.
If RegOpenKeyEx(hKey, KeyName, 0, KEY_WRITE, handle) Then Exit Sub
Select Case KeyType
Case REG_DWORD
lngValue = value
RegSetValueEx handle, ValueName, 0, KeyType, lngValue, 4
Case REG_SZ
strValue = value
RegSetValueEx handle, ValueName, 0, KeyType, ByVal strValue, Len(strValue)
Case REG_BINARY
binValue = value
length = UBound(binValue) - LBound(binValue) + 1
RegSetValueEx handle, ValueName, 0, KeyType, binValue(LBound(binValue)), length
End Select
' Close the key.
RegCloseKey handle
End Sub
In my Form:
Code:
Private Sub Form_Unload(Cancel As Integer)
'Keep the values of the Form size and location for use on startup.
'Store the Form size and location in a RECT.
Dim fRect As RECT
With fRect
.Left = Me.Left
.Top = Me.Top
.Right = Me.Width
.Bottom = Me.Height
End With
'Create a Registry Key for storing the information.
CreateRegistryKey HKEY_CURRENT_USER, "Software" & App.ProductName & "" & App.Major & "." _
& App.Minor & "Two Union Square"
'Store the value in a SubKey.
SetRegistryValue HKEY_CURRENT_USER, "Software" & App.ProductName & "" & App.Major & "." _
& App.Minor & "Two Union Square", "LastPosition", REG_BINARY, fRect
End Sub
I get an error and I don't understand how to correct it. Thanks for the help.
Quote:
Compile Error:
You attempted to use a public user defined type as a parameter or return type for a public procedure of a class module, or as a field of a public user defined type. Only public user defined types that are defined in a public object module can be used in this manner.
Quickest Way To Save Registry
Hi, im new to vb programming and wanted to know the easiest / quickest way to save a specific line from the registry to a text box. Thanks
Save Setting To Registry
I'm trying to save some settings to Windows Registry. I'm trying to save whether or not a menu item was checked or not. This is what I have so far. This is not working and I'm not sure what to put to test whether the item is checked.
Private Sub mnuClose_Click()
SaveSetting "Max Workout Program", "Startup", "Form1", mnuIntro.Checked = Not mnuIntro.Checked_
SaveSetting "Max Workout Program", "Startup", "Form1", mnuWeek1.Checked = Not mnuWeek1.Checked_
SaveSetting "Max Workout Program", "Startup", "Form1", mnuWeek2.Checked = Not mnuWeek2.Checked_
SaveSetting "Max Workout Program", "Startup", "Form1", mnuWeek3.Checked = Not mnuWeek3.Checked_
SaveSetting "Max Workout Program", "Startup", "Form1", mnuWeek4.Checked = Not mnuWeek4.Checked_
SaveSetting "Max Workout Program", "Startup", "Form1", mnuWeek5.Checked = Not mnuWeek5.Checked_
SaveSetting "Max Workout Program", "Startup", "Form1", mnuWeek6.Checked = Not mnuWeek6.Checked_
SaveSetting "Max Workout Program", "Startup", "Form1", mnuWeek7.Checked = Not mnuWeek7.Checked_
End Sub
Using The Registry To Save Options
Hi-
I have (2) options in my setup menuList. If the user selects option1, it becomes 'checked' and loads the sub accordingly. If the user selects option2, the same thing.
I don't want the user to have to set this every single time they run the application. A friend told me to use the registry and set a key. I've looked it up in this article
http://216.26.168.92/articles/registry1/
but I don't fully understand what to set and how.
Registry Use - Save/Getsetting()
I have a small app, and I want the user to be able to set (save)
default settings.
I know I can achieve this by using an .ini/txt file, however I'd thought I'd give the registry a ago.
I have 8 .text (numbers) to save.
ie: 60,10,2185,2143,2045,3000,3627,0
all from the same 'form'.
I havn't accessed the registry before and I am
a little concerned.
I have searched vb2 and looked in my ref manuals, however
I can't seem to find what I want to do.
Can someone please provide an example!
Cheers,
Bruce.
Write And Save In Registry
Hi, prf.
How to write and save string : "connenctionstring" ..... in the registry using udl file to connect dbase with my exe program ? ( Other meaning : How do to get this string "connenctionstring" and write it and save in my registry as example : "BB" by udl file to connect my exe program ).
thankyou very much
Ashraf
Registry Save(RESOLVED)
Hi,
Does anyone know how to save information in the registry or what i need to research to do such ?
Any help would be greatly appreciated.
Thanks
Edited by - KAB on 12/14/2004 1:25:10 AM
Registry Wont Save Values
Hi All
I have written an app with sql server and i use the registry to point to a server and a database, it works great on my laptop and office p.c but on my home p.c it wont save the values in the registry. I don't have code to save the values i enter it manually, but when i close the registry and reopen it the values are gone, this only happens on my home p.c and can't figure out why. Please could someone shed some lite on this for me.
Many thanks in advance
Registry Wont Save Values
Hi All
I have written a small app, where i manually add the "server name" and "Database Name" to the registry, this works fine on my laptop and office p.c but when i do the same on my home p.c and close the regedit and go back in it is gone and can't figure out why, could someone please give me some advice.
Many thanks in advance
Save Setting To Registry (resolved - Thanks)
Senario: Splash screen loads. After 6 seconds, it unloads and checks the registry to see if it should load the Introduction form or the EnterData form. On the Introduction form is a checkbox saying don't show this screen next time the program runs. On the EnterData form is a checkbox saying to show the Introduction screen the next time.
Questions: 1] Is there a "standard" time length for splash screens? 2] Do all or most splash screens offer the esc key? 3] How do I handle the registry key initially? Should I create it the first time the program runs and default the value? If so, how do I keep it from recreating it every time the program runs? Should I check to see if it exists and then skip the saving code if it does and just get the setting instead? If so, what is the code to check for the key?
Thanks for any help,
Cat
Save In Variable And Write To Registry
Can this be done??
I am using this to write "ASYNC - Default 1"
regCreate_Key_Value lngRootKey, "SoftwareRemoteWareClient 00", _
"DefaultDirectoryEntry", "ASYNC - Default 1"
It works great, but I have one problem < Client 00", >
is machine specific. It is '000' at location 000
and is '001' at location 001 on and on we go for
130 locations.
Can I get 000 from a variable?
How Can I Save A Listboxes List In The Registry?
I have a program and while the program is running the user inserts items into a listbox. When the program starts there is nothing in the listbox, the user enters it all. So how can I save this in the registry, and then after you close the program and open it again, how can I make the list that I saved come up again by the click of a button?
Thanks
Eric
Save Binaryb Registry Setting
Hi.
I want to change keys in the registry... but not string keys .. i want to change binary keys. How do I change binary keys in the registry? I have tried with the SaveString function it that didn't work (obviosly).
Plz help
How To Save Into Registry In Binary Format?
I have a group of datas (20,00,12,31) & will like to save it to registry as binary value.
The value of binary will shown in this format (15 00 0C 1F).
I manage to read/write the binary from the registry using regedit. & know how to read the binary using getregvalue (api function) but don't know how to write back to the registry.
Can someone pls help me on this.
All examples are welcome. Thanks all.
Save Listview Settings To Registry
I have checked Microsofts Site up and down to find the answer to this. Mucho kudos to anyone who can give me some code to help. I want to do the following:
Write code that will save the way I display data in a listview ( report view only ). I need to be able to:
1. Save Column order.
2. Save Column width.
I am retrieving the data a database using ADO. I have a location table, and an equipment table. A treeview is loaded with all locations from the location table, then the listview shows all equipment at a given location when selected on the treeview. (each piece of equipment has a location id in the equipment table.) The listview should display equipment information such as equipment name, bay, and unit. As I click on each location, I want to save listview settings at each location.
To simulate the desired result, go to Windows Explorer, and change the view to report view. ie detail view, then drag the columns into different order. Go to another directory and then return to your original directory that you changed. Notice the changes were saved. This is exactly what I want to achieve.
-Elias
What's The Best Way To Save Optionbutton Array In Registry
My form contains six groups of optionbutton controls. Each group is a control array
Group 1: Option1(0), Option1(1) Option1(2), Option1(3)
Now I want to savesetting the choosen optionbutton of the specific group to the registry.
For varCount = 0 To Form1.Option1.Count - 1
If Form1.Option1(varCount).Value = True Then
SaveSetting "MyProggie", "MySettings", "My1stGroup", varCount
End If
Next varCount
Having six of these groups with different number of controls in the array seems like newbe code to me.
Is there a different (shorter) way to do this?
Reading back the settings is soo much easier
Form1.Option1(GetSetting("MyProggie", "MySettings", "My1stGroup", 2)).Value = True
Cheers
vbACME
[RESOLVED By Schoolbusdrive]Save To Registry, But It Doesn't!
I have the following code to save the forms position when it is closed, but when it runs through the Reg.bas if errors out on this line:
Code:
If rv <> REGISTRY_SUCCESS Then GoTo ErrorHandler
Code:
Dim vSubKey As String
vSubKey = "SoftwareDeftechCodeLibrary2.0Config"
SaveRegistryValue regLong, hkeyLOCAL_MACHINE, vSubKey, "Left", Me.Left
SaveRegistryValue regLong, hkeyLOCAL_MACHINE, vSubKey, "Top", Me.Top
SaveRegistryValue regLong, hkeyLOCAL_MACHINE, vSubKey, "Height", Me.Height
SaveRegistryValue regLong, hkeyLOCAL_MACHINE, vSubKey, "Width", Me.Width
Is there something else I should be doing to make a new entry in the registry.
The app is just for me, so I could manually enter the new keys, but I would like to know how to create them properly.
How To Save Keys In Registry Under HKEY_USERS.DEFAULT?
Hi!
How can I write keys to/and read from the registry under:
HKEY_USERS.DEFAULT?
By using the Windows API, I can save the keys under: HKEY_USERS (which can only be read by the logon user). I need to save it under HKEY_USERS.DEFAULT so that everyone logon can still read the keys from it.
Many thanks in advance for the help!
Puffy
Please Help.. How Can You Save Values Of All Checkboxes To Registry, && Retrieve Them?
Heres the code im using to save values of all checkboxes into the registry..
VB Code:
Dim x As ObjectFor Each x In Form1 If TypeOf x Is CheckBox Then SaveSetting "ProjTest", "Settings", x.Name, x.Value End IfNext x
and heres the code to retrieve the values
VB Code:
For Each x In Form1 If TypeOf x Is CheckBox Then x.Value = GetSetting("ProjTest", "Settings", x.Name, 0) End IfNext x
however, if the checkbox is an array, then the code will not work, because the naems of Check(1), Check(2) and Check(3) are all "Check"..
anyone have a method of saving and retreiving the values that will work with arrays too?
I guess what you can do is save the index as well (ie save x.Name & "," & x.Index") and then when retreiving values use split to apply the settings... but im not sure how to do that part
anyone know?
How To Use The Registry To Save/load Simple Data?
hey all wasup
i need help!
how can i save and load simple data like names, paths etc. into the registry?
the data placed in several labels + textboxes.
i want it to save the data in the labels/textboxes into the registry. than under some function (button click or something, i'll think about it later ) i want it to load the data back into the same labels/textboxes.
for ex. if "Eric" is placed in txtName.text and "Dan" is in txtEnemy.text i want it to load "Eric" into txtName.text and "Dan" into txtEnemy.text. (may b needed to load in a diffrent form). Tnx guys
Laterz
Save To .ini File Or Registry? Which Do You Prefer And Suggest?
Ok, I have been wondering this for quite some times. Which is better when saving settings for your program: a ini file or the registry? Which is better? Which one do you use? Is there any particular reason why you use one method over the other?
I was also wondering if the administrator has restricted programs from accessin the registry, then how will my program remember the user's settings? It seems kind of stupid that an admin can restrict programs from writing and reading the registry.
Need Help Converting Write/read Text File To Save/get From The Registry.
For my testing purposes, I kept things simple and used basic text files. Now that I'm about to release a Beta test, I need to convert all of it to save/get setting from the registry. Here's the code I have:
Code:
Option Explicit
Public LoginSucceeded As Boolean
Private Sub cmdCancel_Click()
frmAgree.Show
frmLogin.Hide
End Sub
Private Sub cmdOK_Click()
Dim strUN As String
Dim strPW As String
Dim bfound As Boolean
If txtPassword.Text & txtUserName.Text = "" Then
MsgBox ("Please enter your username and password before pressing accept")
Exit Sub
End If
Open "C:EZ-AccessDatapasswords.txt" For Input As #1
Do While Not EOF(1)
Input #1, strUN, strPW
If strUN = UCase(txtUserName.Text) And UCase(txtPassword.Text) = strPW Then
strUser = strUN
bfound = True
Exit Do
Else: bfound = False
End If
Loop
Close #1
If bfound = True Then
frmStart.Show
Unload Me
End If
If bfound = False Then
MsgBox ("Try Again")
End If
End Sub
Private Sub Form_Load()
End Sub
Notice how I open a text file, read it, and then loop it. Well, I have no idea where to even start with the registry save/get. Of course, it will have to be getsetting, and it will come from this other form:
Code:
Private Sub cmdChk_Click()
Open "C:EZ-AccessDatausers.txt" For Input As #1
Do While Not EOF(1)
Input #1, strUse
If strUse = UCase(txtUser.Text) Then
Close #1
digAgree.Show
Close #1
Exit Sub
Close #1
Exit Do
Close #1
End If
Loop
Close #1
digUser.Show
End Sub
Private Sub cmdSubmit_Click()
Dim Username As String
Dim password As String
Dim password2 As String
Dim fname As String
Dim lname As String
Dim email As String
Username = frmAgree.txtUser.Text
password = frmAgree.txtPass.Text
password2 = frmAgree.txtPass2.Text
fname = frmAgree.txtFname.Text
lname = frmAgree.txtLname.Text
email = frmAgree.txtEmail.Text
If strUse = UCase(txtUser.Text) Then
digAgree.Show
Else
If txtUser.Text = "" Then
MsgBox ("Please choose an username.")
Else
If txtPass.Text = "" And txtPass2.Text = "" Then
MsgBox ("No password entered. Please complete the fields")
frmAgree.Show
Else
If UCase(txtPass.Text) = UCase(txtPass2.Text) Then
Open ("C:EZ-AccessDatapasswords.txt") For Append As #1
Write #1, UCase(Username); UCase(password)
Close #1
Open ("C:EZ-AccessDatausers.txt") For Append As #1
Write #1, UCase(Username)
Close #1
If fname & lname & email = "" Then
frmLogin.Show
Unload frmAgree
strAgree = True
Else
Open ("C:EZ-AccessDataoi.txt") For Append As #1
Write #1, UCase(fname); UCase(lname); UCase(email)
Close #1
End If
Open "C:EZ-AccessDatalaunch.txt" For Output As #1
Write #1, "NO"
Close #1
MsgBox ("Thank you for using EZ-Access Quick Launch")
frmLogin.Show
Unload frmAgree
strAgree = True
Else: MsgBox ("Your passwords do not match. Please reverify.")
If Trim$(txtUser.Text) = "" Then MsgBox ("Blank spaces are not allowed. Nice Try")
End If
End If
End If
End If
End Sub
Private Sub cmExit2_Click()
End
End Sub
Private Sub Form_Load()
Dim strUse As String
End Sub
Again, I know that this will be the form for savesetting, but I have no clue where to go with it. Do I need to take out the looping of it, how will it store multiple usernames (My testing of savesetting always overwrote what was already there instead of creating a new), what do I need to do. I'm confused. I do know how to use the save/get setting now, but not in this situation. As always, any and all help is appreciated.
Thanks!
Getting A Value For My Code From The Registry (Win32 Registry APIs)
There is a variable (SQL Connection String) in my code that I do not want hard-coded.
So I must find a way to be able to store that value in the Registry, and thus I need to import the Win32 Registry APIs (not sure what this implies) into my VB project and work from there.
Anyone able to give me some pointers or point me in the right direction? I do not have much experience with Win32 and APIs but I was told this is an easy task.
How To Encrypt A Value To Store In A Registry And Decrypt From The Registry
Hi all,
I am developing a demo pack for my software.In that i need to retrieve the system current date and store in the registry in an encrypted way.
How to encrypt the system date and decrypt back from the registry for comparing its value with another date value.plaese help me in this.
thanx,
indhuja
How Do I Get A List Of The Registry Keys In A Registry Folder
Hi All,
I am trying to get a list of the registry keys in a specific registry folder so that a user can select a profile to use and the settings be loaded from the respective key.
Eg. The folder:
HKEY_CURRENT_USERSoftwareORCFT
contains the following registry keys:
Gareth
James
Rob
Ian
I need to return the name of each of these keys in a listbox in my app called Combo_User_Profile.
I know how to read and write the registry keys but i just cant figure out how to do this so any help would be appreciated. I have googled and searched this forum but cant find anything related.
Thanks,
Gareth
NT Server Registry/Workstation Registry Access
Hi, I am trying to access the registry on a Server via the API in my code. I am using a timer to kick of some events, one of which is retrieving a key and updating it's value. Now this all works great with NT Workstation (my development machine) but the program does not seem to be able to update the registry on Server. Is there a difference? I would think not, but it's not going in and updating on Server but works great on a Workstation. Any thoughts?
Thanks.
Bryan
Close And Save Excel File, Pass Save Instructions
Hello All,
I was wondering if someone could help me with this. I have the following code-
CODEDim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel.Application")
ExcelSheet.Application.Visible = True
ExcelSheet.Workbooks.Open ("Z:BDCMDAILYDAILY PACKET COVER PAGE.XLS")
'Now print
ExcelSheet.Range("A1:Q44").Select
ExcelSheet.ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$44"
ExcelSheet.ActiveWindow.SelectedSheets.PrintOut copies:=1, collate:=True
ExcelSheet.Application.Quit
Set ExcelSheet = Nothing
End Function
NEWBIe Vs. The Registry - Registry Wins!
hi. i'm new to vb and was tinkering with the registry that tracks exe files with one of the vb program posted on this site and messed up the path. now i can't run any exe file but still have access to my VB program. i've tried using the program here that helps with writing and saving strings to the registry and having a difficult time to get it to work. this is the path in the registry that i messed up on:
HKEY_CLASSES_ROOTexefileshellcommand
the program called to change the default value to add a tracking program. all i wanna do now is change it back to the default which is:
"%1"%*
how can i do this using my vb program? and can it be done easily? i would greatly appreciate any feedbacks and please help me soon before i pull out all my hair!
|