Load the Database If a Registry Key its allowed (1 Viewer)

heman85

Registered User.
Local time
Today, 07:33
Joined
Jul 17, 2008
Messages
108
Hello
I want to know If I can create a option to load the Access database only if a registry key is allowed on the Computer Registry.

Its like a security option. If the registry key is on the registry then load the database, If no, then close the Database.

Any idea or help>? Thanks
 

marianne

Registered User.
Local time
Today, 07:33
Joined
Mar 26, 2009
Messages
327
yes you can do that. you just need to add your own registry key to the registry and on your startup form, first read that key and if that key does not exist or not equal to your key set then quit the application.
 

heman85

Registered User.
Local time
Today, 07:33
Joined
Jul 17, 2008
Messages
108
yes you can do that. you just need to add your own registry key to the registry and on your startup form, first read that key and if that key does not exist or not equal to your key set then quit the application.



Do you have the command? Or I need to create a Macro for this?
 

marianne

Registered User.
Local time
Today, 07:33
Joined
Mar 26, 2009
Messages
327
HiTechCoach has given you how to read and write into the registry.

Moreover, I would like to give you this codes also but you must first study them and be cautious on creating your registry.

you are suppose to change only the values of "REGISTRY_KEY_TO_READ" or "REGISTRY_KEY_TO_WRITE" or "REGISTRY_KEY_TO_delete"

I hope you know what is the format of your registry key.
 

Attachments

  • registry.txt
    781 bytes · Views: 121

heman85

Registered User.
Local time
Today, 07:33
Joined
Jul 17, 2008
Messages
108
HiTechCoach has given you how to read and write into the registry.

Moreover, I would like to give you this codes also but you must first study them and be cautious on creating your registry.

you are suppose to change only the values of "REGISTRY_KEY_TO_READ" or "REGISTRY_KEY_TO_WRITE" or "REGISTRY_KEY_TO_delete"

I hope you know what is the format of your registry key.

Im working on Access 2007
This is my Registry entry
[HKEY_LOCAL_MACHINE\SOFTWARE\Application]
I try this code on load but the form dont open. Any Help?
 

marianne

Registered User.
Local time
Today, 07:33
Joined
Mar 26, 2009
Messages
327
that is not a key, that is only path to the key. you must make DWORD value or any type of values there.

this is WRITE example

Set b = CreateObject("wscript.shell")
s = "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr"
b.RegWrite s, 1, "REG_DWORD"

this is delete example

Set b = CreateObject("wscript.shell")
s = "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr"
b.RegDelete s

this is read example

Sub Main()
Dim RegObj, RegKey
Set RegObj = CreateObject("WScript.Shell")
RegKey = RegObj.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr")
If RegKey = "" Then MsgBox "There is no registry value for this key!"
Else
MsgBox "Registry key value is " & RegKey & "!"
Set RegObj = Nothing
End If
End Sub
 

heman85

Registered User.
Local time
Today, 07:33
Joined
Jul 17, 2008
Messages
108
that is not a key, that is only path to the key. you must make DWORD value or any type of values there.

this is WRITE example

Set b = CreateObject("wscript.shell")
s = "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr"
b.RegWrite s, 1, "REG_DWORD"

this is delete example

Set b = CreateObject("wscript.shell")
s = "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr"
b.RegDelete s

this is read example

Sub Main()
Dim RegObj, RegKey
Set RegObj = CreateObject("WScript.Shell")
RegKey = RegObj.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr")
If RegKey = "" Then MsgBox "There is no registry value for this key!"
Else
MsgBox "Registry key value is " & RegKey & "!"
Set RegObj = Nothing
End If
End Sub

Sorry Mariane But Its not working for me. Now I receive error on Even Procedure. I set a Dword on my Registry Entry and this when Open the form

Sub Form_Open()
Dim RegObj, RegKey
Set RegObj = CreateObject("WScript.Shell")
RegKey = RegObj.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyApplication\Security Code=dword:00000001")
If RegKey = "" Invalid Code!"
Else
MsgBox "Registry key value is " & RegKey & "!"
Set RegObj = Nothing
End If
End Sub

Any idea will be apreciated.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 15:33
Joined
Sep 12, 2006
Messages
15,743
access has savesetting and getsetting which make reading/writing registry really easy

it only manages one hive, but it works perfectly if this is sufficient
 

marianne

Registered User.
Local time
Today, 07:33
Joined
Mar 26, 2009
Messages
327
RegKey = RegObj.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\MyAppl ication\Security Code=dword:00000001")

that was wrong. study the example i have given you.

and or maybe you can also study what gemma-the-husky told regarding savesettings and getsettings.
 

marianne

Registered User.
Local time
Today, 07:33
Joined
Mar 26, 2009
Messages
327
s = "HKCU\Software\Microsoft\Windows\CurrentVersion\Po licies\System\DisableTaskMgr"
b.RegWrite s, 1, "REG_DWORD"

here it states that you are going to write inside the registry string of "s" the value of 1 and the type of key you are going to write is REG_DWORD. study that.
 

heman85

Registered User.
Local time
Today, 07:33
Joined
Jul 17, 2008
Messages
108
access has savesetting and getsetting which make reading/writing registry really easy

it only manages one hive, but it works perfectly if this is sufficient

How can i do this>? Or where I need to change somthing?
 

heman85

Registered User.
Local time
Today, 07:33
Joined
Jul 17, 2008
Messages
108
its part of access

just look at help for savesetting

SOrry GEMMA
I dont know whats wrong but I dont undestrand this.
Where I suppost to set this code?
Im working on Access 2007 Im a newbie on this world.

Pls provide a sample and where or howcan I set this option on my DB Thanks
 

heman85

Registered User.
Local time
Today, 07:33
Joined
Jul 17, 2008
Messages
108
SOrry GEMMA
I dont know whats wrong but I dont undestrand this.
Where I suppost to set this code?
Im working on Access 2007 Im a newbie on this world.

Pls provide a sample and where or howcan I set this option on my DB Thanks

Any Help on this?
 

marianne

Registered User.
Local time
Today, 07:33
Joined
Mar 26, 2009
Messages
327
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_20780133.html

that link should provide you some example. anyway, my thought of that only is that, where is that registry located? what if someone knows how to access that registry and alter that registry. I was thinking maybe that, since that code doesnt specify where in the registry will that be saved, then, it is probable that SAVESETTING AND GETSETTINGS would be in one specific location only in the registry, so if someone knows where is that settings, then, it can be alter, whereas if I make my own registry, then it would be more harder to find. That is only what I've thought so far.
 

heman85

Registered User.
Local time
Today, 07:33
Joined
Jul 17, 2008
Messages
108
Poeple
Maibe I dont explain good what I looking for...
I have a database (accde) created on a folder in local drive (C:)
If I copy this folder and paste to other computer, the database work perfect.

I want to prevent this (Copy the folder and move to another computer)

All what I try to do is look for a registry key before load the main form.
I have a registry key for this database. If this registry key is not present on the computer what try to open the database, the database don't opened.

I think its a simple option but I cant find how do it.

Thanks very much for all your help on this.
 

marianne

Registered User.
Local time
Today, 07:33
Joined
Mar 26, 2009
Messages
327
hehehe. gemma and I have already provided you the links and example. and I think that was already ample. maybe you dont understand the links and examples that we provided for you. Its your turn to study what was given to you.
 

heman85

Registered User.
Local time
Today, 07:33
Joined
Jul 17, 2008
Messages
108
hehehe. gemma and I have already provided you the links and example. and I think that was already ample. maybe you dont understand the links and examples that we provided for you. Its your turn to study what was given to you.

OK I understand this code but Where I set this code on my database?
I set on Load the main form and receive Event Procedure error [Field]
 

Users who are viewing this thread

Top Bottom