PDA

View Full Version : Prevent coyping of my Acess database 2007



freehope
10-19-2010, 06:41 PM
Hi All,
Good Day

need a vb function that prevent copying of my Access database to make it just for use..
I am Confident of the presence of experts here are able to find a solution for my issue....

Or the other way

I need a strong program with way to explain how it is work on a cd contains of my Acess data base 2007
that to prevent copying of my Access database 2007

Wait any solution for those issues ASAP
Thanks..Appreciate your efforts

Junior Develoer c#

Alaa AbdelWahed

Imdabaum
10-20-2010, 06:42 AM
I haven't heard of anything to prohibit copying. As copying/pasting is inherent to most computers and not restricted to only VBA. But if you want people unable to access your code, there are lots of options. My favorite is the following.

Create a module (I called mine basSecurity) then enter the following code and save it.
Option Compare Database
Option Explicit
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function apiGetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function DisableSpecialKeys() As Boolean
On Error GoTo Err_DisableSpecialKeys
'This function restricts users from using special keys that open design features.
'Start up properties will always be executed.

Dim db As Database
Dim Prop As Property
Const conPropNotFound = 3270
Set db = CurrentDb()
db.Properties("AllowSpecialKeys") = False
Set db = Nothing
DisableSpecialKeys = True
Exit_DisableSpecialKeys:
Exit Function
Err_DisableSpecialKeys:
If Err = conPropNotFound Then
'If the property doesn't exist, create it
Set Prop = db.CreateProperty("AllowSpecialKeys", dbBoolean, True)
db.Properties.Append Prop
Resume Next
Else
MsgBox "Disable did not Work!!"
DisableSpecialKeys = False
Resume Exit_DisableSpecialKeys
End If
End Function
Public Function EnableSpecialKeys() As Boolean
On Error GoTo Err_DisableSpecialKeys
'This function enables special keys that open design features.
'Start up properties will always be executed.

Dim db As Database
Dim Prop As Property
Const conPropNotFound = 3270
Set db = CurrentDb()
db.Properties("AllowSpecialKeys") = True
Set db = Nothing
EnableSpecialKeys = True
Exit_DisableSpecialKeys:
Exit Function
Err_DisableSpecialKeys:
If Err = conPropNotFound Then
'If the property doesn't exist, create it
Set Prop = db.CreateProperty("AllowSpecialKeys", dbBoolean, True)
db.Properties.Append Prop
Resume Next
Else
MsgBox "Ensable did not Work!!"
EnableSpecialKeys = False
Resume Exit_DisableSpecialKeys
End If
End Function
Function p_DisableShiftBypass()
On Error GoTo errDisableByPass
'This function restricts users from modifying the database
'Start up properties will always be executed.
Dim db As Database
Dim Prop As DAO.Property
Const conPropNotFound = 3270

Set db = CurrentDb()
'Disable the shift key on startup.
db.Properties("AllowByPassKey") = False
DisableSpecialKeys
Exit Function

errDisableByPass:
'The first part of this error routine creates the "AllowByPassKey
'property if it does not exist.
If Err = conPropNotFound Then
Set Prop = db.CreateProperty("AllowByPassKey", dbBoolean, False)
db.Properties.Append Prop
Resume Next
Else
MsgBox "Function 'DisableShiftBypass' did not complete successfully."
Exit Function
End If
End Function
Function p_EnableShiftByPass()
'This function enables the SHIFT key at startup. This action causes
'the Autoexec macro and the Startup properties to be bypassed
'if the user holds down the SHIFT key when the user opens the database.
On Error GoTo errEnableShift
Dim db As DAO.Database
Dim Prop As DAO.Property
Const conPropNotFound = 3270
Set db = CurrentDb()
'This next line of code disables the SHIFT key on startup.
db.Properties("AllowByPassKey") = True
EnableSpecialKeys
'function successful
Exit Function
errEnableShift:
'The first part of this error routine creates the "AllowByPassKey
'property if it does not exist.
If Err = conPropNotFound Then
Set Prop = db.CreateProperty("AllowByPassKey", _
dbBoolean, True)
db.Properties.Append Prop
Resume Next
Else
MsgBox "Function 'p_DisableShiftByPass' did not complete successfully."
Exit Function
End If
End Function
Public Function LockDown()
' Runs if the database extension is .accde instead of .accdb
' Disables shift bypass, and special keys that would otherwise open the navigation window.
Dim sDbExt As String
sDbExt = Right(CurrentProject.Name, 6)
'Place your username in the check below.
If fOSUserName <> [yourUserName] AND fOSMachineName<>[MachineName]Then
p_DisableShiftBypass
Else
p_EnableShiftByPass
End If
End Function

'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If (lngX > 0) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
'******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Function fOSMachineName() As String
'Returns the computername
Dim lngLen As Long, lngX As Long
Dim strCompName As String
lngLen = 16
strCompName = String$(lngLen, 0)
lngX = apiGetComputerName(strCompName, lngLen)
If lngX <> 0 Then
fOSMachineName = Left$(strCompName, lngLen)
Else
fOSMachineName = ""
End If
End Function
Then create a Macro and call it AutoExec. Make the Action RunCode and the Argument LockDown()

Again that will not prevent copying the database and won't keep people from using your database. But it will prevent them from modifying the tables, forms, queries, modules, and macros.
I usually make an .accde from the master copy and run it at least once before I put it anywhere unsecured from my network. Then if anyone does ever get a copy of it, they still can't shift bypass the AutoExec macro.

Althought it would be fun to write an obliterate code... so if someone opens the database that isn't you and isn't on an authorized machine it could cycle through your tables, forms, and queries and delete them all.... kind of Mission Impossible-ish. MsgBox("Database will obliterate in 5, 4, 3, 2, 1... Bye")

Sorry I got carried away there. Have you looked into the Developer Extensions for Access? That allows you to create installations that you could have on a CD. Creating passwords on your database is a way of keeping people out of your databases also and it comes standard on a wizard in most versions of Access. Sorry for being so verbose. HTH.

HiTechCoach
10-20-2010, 09:20 PM
Check out Keyed Access (http://www.peterssoftware.com/ka.htm)

HiTechCoach
10-20-2010, 09:46 PM
Althought it would be fun to write an obliterate code... so if someone opens the database that isn't you and isn't on an authorized machine it could cycle through your tables, forms, and queries and delete them all.... kind of Mission Impossible-ish. MsgBox("Database will obliterate in 5, 4, 3, 2, 1... Bye")

If you are using an accde/mde you could only delete the tables and queries.

freehope
10-21-2010, 12:34 AM
Dear imdabaum ,Hitechcoach

thanks for your response ..about the code above it is greate and i will use it sure to keep my database uneditable ...so just for use it.. cause it contains of tables and forms to show its fields no user need to insert data ,just to search names with its information at the form...

But my question hope it was clear ..I know you understanding my require.

...About Kayed Access I tried to understand about it more and download it from HetichCoach path ..thanks but Not been very effective because it is a trial version like a demo will finish Or buy it(299$) waw .. and tried to know my serial number for the KA installition ...no way cant react with it

I am still keep searching to solve this issue please retry help me

Thanks a lot ,appreciate your efforts

Alaa AbdlWahed

HiTechCoach
10-21-2010, 09:23 AM
Dear imdabaum ,Hitechcoach

thanks for your response ..about the code above it is greate and i will use it sure to keep my database uneditable ...so just for use it.. cause it contains of tables and forms to show its fields no user need to insert data ,just to search names with its information at the form...

But my question hope it was clear ..I know you understanding my require.

...About Kayed Access I tried to understand about it more and download it from HetichCoach path ..thanks but Not been very effective because it is a trial version like a demo will finish Or buy it(299$) waw .. and tried to know my serial number for the KA installition ...no way cant react with it

I am still keep searching to solve this issue please retry help me

Thanks a lot ,appreciate your efforts

Alaa AbdlWahed

It takes a lot of time and money to develop what you want. I would not expect anyone to give this aways for free or making there protection scheme public. This would great reduce the effectiveness of the nmethods.

You will probably not find any free code to do this. If you do, I would NOT use it. Since it is public knowledge then it will be a whole lot easier to crack.

Hardware option:

Using a USB Dongle works great.

Software option:


The best way I have figure out to do this is web based. I would uses a"validation server".

For example, you could develop a web service that runs on your site. Each time your database loads it would need to check with the web service to see if this is a valid installation.

There are companies that do this for a fee.

DLL protection:

There is the open source: Activelock (http://www.activelocksoftware.com/)

I have NOT used this since it is open source.