How to store a date in the registry

Access 10

I want to save a date in the registry, as the installation date,  so in subsequent runs of the program, I can check it against the current date to see if the time limit has expired.

Should I save it as a date, a variant, or a string which I convert when getting the setting?

Thanks in advance,

CRB
Clive BeatonAccess DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongCommented:
>>Should I save it as a date, a variant, or a string which I convert when getting the setting?

it can be saved as a date, a variant or a string but in general what you stored in Registry would be a string.

you need to use Windows Registry APIs in order to retrieve or store the info into Registry. but also keep in mind to encrypt your data in Registry, else the data could be compromised easily.
0
Clive BeatonAccess DeveloperAuthor Commented:
Thanks,

By mentioning the APIs, are you saying Access SaveSetting and GetSetting won't do the job?

I take your point about encryption.
0
Gustav BrockCIOCommented:
There is no data type specifically for date and time in the Registry. So use a string (REG_SZ):

RegDateValue = Format(DateValueToSave, "yyyy\/mm\/dd")

Open in new window


This you can retrieve and easily convert to a true date value:

DateValueSaved = DateValue(RegDateValue)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Clive BeatonAccess DeveloperAuthor Commented:
Thanks very much.
0
Ryan ChongCommented:
By mentioning the APIs, are you saying Access SaveSetting and GetSetting won't do the job?
SaveSetting and GetSetting provide you the flexibility to access to Registry easily via Access but at the same time you can't really specify the registry path to save your info (well, if that's not crucial then it would be fine).

what I have mentioned to use Windows APIs was more technical, in which you can configure the registry path you want.

Functions For Working With The Registry
http://www.cpearson.com/excel/registry.htm
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.