Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing/reading to/from the registry 4

Status
Not open for further replies.

JBG

Programmer
Oct 22, 2001
99
US
I have an Access 2000 program that needs to write to and read from the registry.

First, I need to write a value, say, "THis is a test" to the registry. What I dont know is, one, how do I write a value to the registry, and two, where to write a value that I can read from?

Is there a generic place that I can create a registry value? If so, under what folder?

The place that I write it to in the registry is immaterial, as long as it cazn be done on an NT, 2000, or 98 machine.

Is there a place in the registry (accross platforms) that is somehow, like, a generic place to create a key or folder?

How would it be done?

Any help would be appreciated.

Thanks~ JBG
 
Have a look at GetSetting and ReadSetting.

Both are built in functions (bonus),but only allow you to save and read from a specific area of the registry (HKEY CURRENT USER\SOFTWARE\VB AND VBA PROGRAM SETTINGS). They are ideal for persisting data for the platforms you mentioned.

Here's a sample I prepared for someone else this morning...
The code checks if program has been run earlier that day.


Private Sub SaveCurrentDate()
SaveSetting appname:="MyProg", section:="Settings", key:="LastRunDate", setting:=Date
End Sub

Private Function ReadLastRunDate() As Date
'return yesterdays date if no setting exists
ReadLastRunDate = GetSetting(appname:="MyProg", section:="Settings", key:="LastRunDate", Default:=(Date - 1))
End Function

Sub main()
If ReadLastRunDate = Date Then
Exit Sub
End If

'...

'save run date
SaveCurrentDate
End Sub


 
Chogben,

Thank you very much for taking the time to reply. This is what I was looking for. I will test it asap.

JBG

 
Chogben,

I said in my last reply Id test your code asap. My job has kept me too busy, and I just now got to it.

It works perfect.

Thanks again,

JBG
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top