I don't understand your question, please supply more information!
Hey shamal, still doesn't make sense, sorry.![]()
do you need to know the serial number of harddisk?
Public Function GetSetHardDiskSerial()
Dim prop As DAO.Property
Dim dbs As DAO.Database
On Error GoTo Err_Handler
Dim strHarddisk As String
Set dbs = CurrentDb
'Set the property's value
'If it doesn't exist, an error 3270 "Property not found" will occur
strHarddisk = dbs.Containers("Databases")("UserDefined").Properties("HardDisk").Value
If Err.Number = 0 Then
If strHarddisk <> GetPhysicalSerial()(1) & "" Then
MsgBox "You have been a victim of counterfeit!"
Application.Quit
End If
End If
Set prop = Nothing
Set dbs = Nothing
Exit Function
Err_Handler:
If Err = 3270 Then
'If the property doesn't exist, create it
Set prop = dbs.CreateProperty("HardDisk", dbText, GetPhysicalSerial()(1) & "")
'Append it to the collection
dbs.Containers("Databases")("UserDefined").Properties.Append prop
End If
Resume Next
End Function
Function GetPhysicalSerial() As Variant
Dim obj As Object
Dim WMI As Object
Dim SNList() As String, i As Long, Count As Long
Set WMI = GetObject("WinMgmts:")
For Each obj In WMI.InstancesOf("Win32_PhysicalMedia")
If obj.SerialNumber <> "" Then Count = Count + 1
Next
'ReDim SNList(1 To Count, 1 To 1)
ReDim SNList(1 To Count)
i = 1
For Each obj In WMI.InstancesOf("Win32_PhysicalMedia")
'SNList(i, 1) = obj.SerialNumber
SNList(i) = obj.SerialNumber
i = i + 1
If i > Count Then Exit For
Next
GetPhysicalSerial = SNList
End Function
simply create a "custom" property on the database and compare that value when the db is started, maybe on autoexec macro. you are right all the way we can use the serial number of harddisk as a property.
put this in a module and call this on autoexec macro:
macro: RunCode: GetSetHardDiskSerial()
Code:Public Function GetSetHardDiskSerial() Dim prop As DAO.Property Dim dbs As DAO.Database On Error GoTo Err_Handler Dim strHarddisk As String Set dbs = CurrentDb 'Set the property's value 'If it doesn't exist, an error 3270 "Property not found" will occur strHarddisk = dbs.Containers("Databases")("UserDefined").Properties("HardDisk").Value If Err.Number = 0 Then If strHarddisk <> GetPhysicalSerial()(1) & "" Then MsgBox "You have been a victim of counterfeit!" Application.Quit End If End If Set prop = Nothing Set dbs = Nothing Exit Function Err_Handler: If Err = 3270 Then 'If the property doesn't exist, create it Set prop = dbs.CreateProperty("HardDisk", dbText, GetPhysicalSerial()(1) & "") 'Append it to the collection dbs.Containers("Databases")("UserDefined").Properties.Append prop End If Resume Next End Function Function GetPhysicalSerial() As Variant Dim obj As Object Dim WMI As Object Dim SNList() As String, i As Long, Count As Long Set WMI = GetObject("WinMgmts:") For Each obj In WMI.InstancesOf("Win32_PhysicalMedia") If obj.SerialNumber <> "" Then Count = Count + 1 Next 'ReDim SNList(1 To Count, 1 To 1) ReDim SNList(1 To Count) i = 1 For Each obj In WMI.InstancesOf("Win32_PhysicalMedia") 'SNList(i, 1) = obj.SerialNumber SNList(i) = obj.SerialNumber i = i + 1 If i > Count Then Exit For Next GetPhysicalSerial = SNList End Function
shamal,
You asked the question
..how you can protect the database Accesse when you give it to the customer
The best way to protect the database
The best solution to protect the database so that it can not be sold to more than one person
and arnelgp answered you directly.
What part do you not understand?
If we have still misunderstood your question, then I think you will have to do some research or post a few examples to clarify things.
I think arnelgp has given you the answer.
for sample sake, run the db first time on your pc. copy the db and run it in another pc.