473,508 Members | 2,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Protect my work

759 Contributor
Hi all !
Please, can you point me in the right direction ?

I have a database with two parts: One part is for tables and the other one is for forms, queries, reports and so on.
I design this database for one customer but I realized that I can sell it more than one time to different clients.
To avoid unauthorized copies I wish to "install" the database (the "front" part) on a certain computer. Or to "read" the computer (processor, mother board and so on) and, based on the results, to "compute" a "key".
If someone make a copy and paste in other PC I wish that the database do not work and show a message like this: "Programmer phone number is: NN-NNN-NN.NN.NN. Please contact them !".

Can you help me ? Some advices ? Some code ? Some links ?

Note please that this is not the security for database. I am not looking for access rights.

Hope I can explain OK my problem with my poor English.

Thank you very much !
Sep 9 '11 #1
14 1807
NeoPa
32,557 Recognized Expert Moderator MVP
I think this is more complicated than perhaps you appreciate Mihail. Have you considered the legal side of this problem? How would you license such a deal? Do you imagine a user would be happy if their PC blew up and they found they were unable to install it again without calling you?

There are many issues to consider, and I'm not telling you any answers, just giving you questions I think you need to consider.
Sep 9 '11 #2
Mihail
759 Contributor
Hi, NeoPa.
Thank you for reply.

Yes, I think about the license.
But... what about Torrent site ? No. It is not a choice. Not in Romania :) . It is also very expensive for me. And, of course, my database has not a price like... Solid Works (as example).

So...
I have an idea how complicated is.
Also I have some code in VB6 which deal a part of the job.
I ask you (all) because there are some very good coders here. Maybe someone do the entire job before and wish to help me to avoid reinvent the warm water.

Thank you again for reply.
And if you wish (and could) help me I'll thank you again.
Sep 9 '11 #3
NeoPa
32,557 Recognized Expert Moderator MVP
I have nothing for you I'm afraid. I have steered away from that area in the past, but if I think of anything I'll try to remember you're looking.
Sep 9 '11 #4
Frinavale
9,735 Recognized Expert Moderator Expert
I have no idea how to do this in Access but have you considered developing a "client" application that connects to the Access database?

That client application could check computer characteristics etc to determine if it is permitted to access the database.

I have a good idea of how to do it in a .net application...but I've learned that Access is completely different.
Sep 9 '11 #5
Mihail
759 Contributor
Thank you, Frinavale.

As far as I know this information (about computer characteristics) can be "read" by calling one or more libraries.
Can you explain what librarie(s) I need (I use Windows XP - 32) and the exact syntax to apply? (API syntax). I need only a few essential characteristics of the hardware (which can't be change by users).

Even only the name of the libraries I need is a good point to start for me.

If you have some code in VB.NET I think I can understand it and make necessary changes to use it in Access VBA.

Thank you again.
Sep 10 '11 #6
NeoPa
32,557 Recognized Expert Moderator MVP
I have a module I use for basic operating with the OS Mihail. It includes routines to read from, and write to, Registry Values. You probably won't want to write anything to any of them, but if you do be very careful, as the usual warnings apply : Back up your registry before playing. Actually that applies also to reading from it as they can get corrupted if not opened and closed properly. As they stand, these routines handle that for you, but if you make any changes be aware that you will be putting your Registry at risk if you get them wrong. Always ensure that any Values opened in your code are closed again before it completes.

I've included the whole module here, as other procedures may also prove interesting, but only RegRead() and RegWrite() pertain to the Registry directly. I've named this module modOS in my projects :

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. 'Windows API Variable Prefixes
  5. 'cb = Count of Bytes (32-bit)
  6. 'w  = Word (16-bit)
  7. 'dw = Double Word (32-bit)
  8. 'lp = Long Pointer (32-bit)
  9. 'b  = Boolean (32-bit)
  10. 'h  = Handle (32-bit)
  11. 'ul = Unsigned Long (32-bit)
  12.  
  13. Public Const conHKCR = &H80000000
  14. Public Const conHKCU = &H80000001
  15. Public Const conHKLM = &H80000002
  16. Public Const conHKU = &H80000003
  17. Public Const REG_NONE As Long = 0               'None
  18. Public Const REG_SZ As Long = 1                 'Null terminated string
  19. Public Const REG_EXPAND_SZ As Long = 2          'As above but contains
  20.                                                 '  unexpanded Env Vars
  21. Public Const REG_BINARY As Long = 3             'binary data
  22. Public Const REG_DWORD As Long = 4              'Double Word (Long)
  23. Public Const REG_DWORD_BIG_ENDIAN As Long = 5   'As above but reversed
  24. Public Const REG_LINK As Long = 6               'Unicode symbolic link
  25. Public Const REG_MULTI_SZ As Long = 7           'Array of SZs (dbl null ends)
  26. Public Const REG_RESOURCE_LIST As Long = 8
  27. Public Const REG_FULL_RESOURCE_DESCRIPTOR As Long = 9
  28. Public Const REG_RESOURCE_REQUIREMENTS_LIST As Long = 10
  29. Public Const REG_QWORD As Long = 11             ' Quad Word
  30. Public Const conStandardRightsAll = &H1F0000
  31. Public Const conReadControl = &H20000
  32. Public Const conStandardRightsRead = (conReadControl)
  33. Public Const conRegSz = 1
  34. Public Const conOK = 0&
  35. Public Const conKeyQueryValue = &H1
  36. Public Const conKeySetValue = &H2
  37. Public Const conKeyCreateSubKey = &H4
  38. Public Const conKeyEnumerateSubKeys = &H8
  39. Public Const conKeyNotify = &H10
  40. Public Const conKeyCreateLink = &H20
  41. Public Const conSynchronise = &H100000
  42. Public Const conRegOptionNonVolatile = 0
  43. Public Const conKeyAllAccess = ((conStandardRightsAll _
  44.                               Or conKeyQueryValue _
  45.                               Or conKeySetValue _
  46.                               Or conKeyCreateSubKey _
  47.                               Or conKeyEnumerateSubKeys _
  48.                               Or conKeyNotify _
  49.                               Or conKeyCreateLink) _
  50.                             And (Not conSynchronise))
  51. Public Const conKeyRead = ((conReadControl _
  52.                          Or conKeyQueryValue _
  53.                          Or conKeyEnumerateSubKeys _
  54.                          Or conKeyNotify) _
  55.                        And (Not conSynchronise))
  56.  
  57. Private Const conUseShowWindow = &H1&
  58. Private Const conNormalPriority = &H20&
  59. Private Const conInfinite = -1&
  60. Private Const conWinVis = &H10000000
  61. Private Const conGWLStyle = -16
  62.  
  63. Private Type typStartupInfo
  64.     cbLen As Long
  65.     lpReserved As String
  66.     lpDesktop As String
  67.     lpTitle As String
  68.     dwX As Long
  69.     dwY As Long
  70.     dwXSize As Long
  71.     dwYSize As Long
  72.     dwXCount As Long
  73.     dwYCount As Long
  74.     dwFillAtt As Long
  75.     dwFlags As Long
  76.     wShowWindow As Integer
  77.     cbReserved2 As Integer
  78.     lpReserved2 As Long
  79.     hStdIn As Long
  80.     hStdOut As Long
  81.     hStdErr As Long
  82. End Type
  83.  
  84. Private Type typProcInfo
  85.     hProc As Long
  86.     hThread As Long
  87.     dwProcID As Long
  88.     dwThreadID As Long
  89. End Type
  90.  
  91. Private Declare Function RegOpenKeyEx Lib "advapi32.dll" _
  92.     Alias "RegOpenKeyExA" (ByVal hKey As Long, _
  93.                            ByVal lpSubKey As String, _
  94.                            ByVal ulOptions As Long, _
  95.                            ByVal samDesired As Long, _
  96.                            phkResult As Long) As Long
  97. Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) _
  98.                              As Long
  99. Private Declare Function RegQueryValueExStr Lib "advapi32.dll" _
  100.     Alias "RegQueryValueExA" (ByVal hKey As Long, _
  101.                               ByVal lpValueName As String, _
  102.                               ByVal lpReserved As Long, _
  103.                               ByRef lpType As Long, _
  104.                               ByVal lpData As String, _
  105.                               ByRef lpcbData As Long) As Long
  106.  
  107. Private Declare Function RegSetValueExStr Lib "advapi32.dll" _
  108.     Alias "RegSetValueExA" (ByVal hKey As Long, _
  109.                             ByVal lpValueName As String, _
  110.                             ByVal lpReserved As Long, _
  111.                             ByVal lpType As Long, _
  112.                             ByVal lpData As String, _
  113.                             ByVal lpcbData As Long) As Long
  114.  
  115. Private Declare Function CreateProcessA Lib "kernel32" ( _
  116.     ByVal lpApplicationName As Long, _
  117.     ByVal lpCommandLine As String, _
  118.     ByVal lpProcessAttributes As Long, _
  119.     ByVal lpThreadAttributes As Long, _
  120.     ByVal bInheritHandles As Long, _
  121.     ByVal dwCreationFlags As Long, _
  122.     ByVal lpEnvironment As Long, _
  123.     ByVal lpCurrentDirectory As Long, _
  124.     lpStartupInfo As typStartupInfo, _
  125.     lpProcessInformation As typProcInfo) As Long
  126. Private Declare Function WaitForSingleObject Lib "kernel32" ( _
  127.     ByVal hHandle As Long, _
  128.     ByVal dwMilliseconds As Long) As Long
  129. Private Declare Function CloseHandle Lib "kernel32" ( _
  130.     ByVal hObject As Long) As Long
  131.  
  132. Private Declare Function FindWindowEx Lib "user32" _
  133.     Alias "FindWindowExA" (ByVal hwndParent As Long, _
  134.                            ByVal hwndChildAfter As Long, _
  135.                            ByVal lpszClass As String, _
  136.                            ByVal lpszWindow As String) As Long
  137. Private Declare Function GetWindowLong Lib "user32" _
  138.     Alias "GetWindowLongA" (ByVal hwndID As Long, _
  139.                             ByVal nIndex As Long) As Long
  140.  
  141. Public Function RegRead(ByVal lngHive As Long, _
  142.                         ByVal strKey As String, _
  143.                         ByVal strValue As String) As Variant
  144.     Dim intX As Integer
  145.     Dim strBuf As String
  146.     Dim lngRet As Long, lngHKey As Long, lngType As Long, lngBufLen As Long
  147.  
  148.     RegRead = Null
  149.     strKey = strKey & vbNullChar
  150.     lngRet = RegOpenKeyEx(hKey:=lngHive, _
  151.                           lpSubKey:=strKey, _
  152.                           ulOptions:=0, _
  153.                           samDesired:=conKeyRead, _
  154.                           phkResult:=lngHKey)
  155.     If lngRet = conOK Then
  156.         'Set up buffer to store value
  157.         lngBufLen = 255
  158.         strBuf = String(lngBufLen, 0)
  159.         strValue = strValue & vbNullChar
  160.         lngRet = RegQueryValueExStr(hKey:=lngHKey, _
  161.                                     lpValueName:=strValue, _
  162.                                     lpReserved:=0&, _
  163.                                     lpType:=lngType, _
  164.                                     lpData:=strBuf, _
  165.                                     lpcbData:=lngBufLen)
  166.         'Close key
  167.         Call RegCloseKey(lngHKey)
  168.         Select Case lngType
  169.         Case REG_SZ, REG_EXPAND_SZ, REG_MULTI_SZ, REG_BINARY
  170.             If lngBufLen = 255 Then
  171.                 RegRead = Null
  172.             Else
  173.                 If lngType <> REG_BINARY Then lngBufLen = lngBufLen - 1
  174.                 RegRead = Left(strBuf, lngBufLen)
  175.                 If lngType = REG_MULTI_SZ Then _
  176.                     RegRead = Split(RegRead, vbNullChar)
  177.             End If
  178.         Case REG_DWORD
  179.             For intX = 4 To 1 Step -1
  180.                 lngRet = Asc(Mid(strBuf, intX))
  181.                 If intX = 4 Then
  182.                     If (lngRet And &H80) > 0 Then
  183.                         RegRead = &H80000000
  184.                         lngRet = (lngRet And &H7F)
  185.                     Else
  186.                         RegRead = 0
  187.                     End If
  188.                 End If
  189.                 RegRead = RegRead Or (lngRet * 256 ^ (intX - 1))
  190.             Next intX
  191.         End Select
  192.     End If
  193. End Function
  194.  
  195. Public Function RegWrite(ByVal lngHive As Long, _
  196.                          ByVal strKey As String, _
  197.                          ByVal strValue As String, _
  198.                          ByVal varValue As Variant) As Boolean
  199.     Dim intX As Integer
  200.     Dim strBuf As String
  201.     Dim lngRet As Long, lngHKey As Long, lngBufLen As Long, lngType As Long
  202.     Dim lngNeg As Long
  203.  
  204.     RegWrite = False
  205.     strKey = strKey & vbNullChar
  206.     strValue = strValue & vbNullChar
  207.     lngRet = RegOpenKeyEx(hKey:=lngHive, _
  208.                           lpSubKey:=strKey, _
  209.                           ulOptions:=0, _
  210.                           samDesired:=conKeyAllAccess, _
  211.                           phkResult:=lngHKey)
  212.     If lngRet = conOK Then
  213.         'Set up buffer to store value
  214.         lngBufLen = 255
  215.         strBuf = String(lngBufLen, 0)
  216.         lngRet = RegQueryValueExStr(hKey:=lngHKey, _
  217.                                     lpValueName:=strValue, _
  218.                                     lpReserved:=0&, _
  219.                                     lpType:=lngType, _
  220.                                     lpData:=strBuf, _
  221.                                     lpcbData:=lngBufLen)
  222.         Select Case lngType
  223.         Case REG_SZ, REG_EXPAND_SZ, REG_BINARY
  224.             If VarType(varValue) = vbString Then _
  225.                 strBuf = varValue & IIf(lngType = REG_BINARY, "", vbNullChar)
  226.         Case REG_MULTI_SZ
  227.             If VarType(varValue) = (vbArray Or vbString) Then _
  228.                 strBuf = Join(varValue, vbNullChar) & vbNullChar
  229.         Case REG_DWORD
  230.             strBuf = Space(4)
  231.             lngNeg = (varValue \ &H1000000) And &H80
  232.             For intX = 1 To 4
  233.                 lngRet = (((varValue And &H7FFFFFFF) \ 256 ^ (intX - 1)) And &HFF)
  234.                 If intX = 4 Then lngRet = lngRet Or lngNeg
  235.                 Mid(strBuf, intX, 1) = Chr(lngRet)
  236.             Next intX
  237.         End Select
  238.         lngBufLen = Len(strBuf)
  239.         lngRet = RegSetValueExStr(hKey:=lngHKey, _
  240.                                   lpValueName:=strValue, _
  241.                                   lpReserved:=0&, _
  242.                                   lpType:=lngType, _
  243.                                   lpData:=strBuf, _
  244.                                   lpcbData:=lngBufLen)
  245.         RegWrite = (lngRet = conOK)
  246.         'Close key
  247.         Call RegCloseKey(lngHKey)
  248.     End If
  249. End Function
  250.  
  251. 'ShellWait() executes a command synchronously (Shell() works asynchronously).
  252. Public Sub ShellWait(strCommand As String, _
  253.                      Optional intWinStyle As Integer = vbNormalFocus)
  254.     Dim objProcInfo As typProcInfo
  255.     Dim objStart As typStartupInfo
  256.     Dim lngRet As Long
  257.  
  258.     'Initialize the typStartupInfo structure:
  259.     With objStart
  260.         .cbLen = Len(objStart)
  261.         .dwFlags = conUseShowWindow
  262.         .wShowWindow = intWinStyle
  263.     End With
  264.     'Start the shelled application:
  265.     Call CreateProcessA(lpApplicationName:=0&, _
  266.                         lpCommandLine:=strCommand, _
  267.                         lpProcessAttributes:=0&, _
  268.                         lpThreadAttributes:=0&, _
  269.                         bInheritHandles:=1&, _
  270.                         dwCreationFlags:=conNormalPriority, _
  271.                         lpEnvironment:=0&, _
  272.                         lpCurrentDirectory:=0&, _
  273.                         lpStartupInfo:=objStart, _
  274.                         lpProcessInformation:=objProcInfo)
  275.     'Wait for the shelled application to finish
  276.     Call WaitForSingleObject(hHandle:=objProcInfo.hProc, _
  277.                              dwMilliseconds:=conInfinite)
  278.     Call CloseHandle(hObject:=objProcInfo.hProc)
  279. End Sub
  280.  
  281. Public Function DBWindowVisible() As Boolean
  282.     Dim hWnd As Long, lngStyle As Long
  283.  
  284.     'Get handle of MDIClient window of current application
  285.     hWnd = FindWindowEx(hWndAccessApp, 0, "MDIClient", vbNullString)
  286.     'Within that, find child window matching class Odb (database window)
  287.     hWnd = FindWindowEx(hWnd, 0, "Odb", vbNullString)
  288.     'Default result to False in case handle wasn't found
  289.     DBWindowVisible = False
  290.     If (hWnd) Then
  291.         'Having found window, check the visibility flag of its style value
  292.         lngStyle = GetWindowLong(hWnd, conGWLStyle)
  293.         DBWindowVisible = ((lngStyle And conWinVis) = conWinVis)
  294.     End If
  295. End Function
Sep 10 '11 #7
Mihail
759 Contributor
Thank you, NeoPa.
I need some times to read and understand your code.
From now I wish to thank you very much.
By the way: I am also interested in a SHELL command which open a file SYNCHRONOUSLY and I see that subroutine in your code. It is great for me. Thank you again.
Sep 10 '11 #8
NeoPa
32,557 Recognized Expert Moderator MVP
You're welcome of course Mihail. OS stuff (the API) is designed to work in a way that suits C and languages that pass parameters in the same way. VB & VBA don't do that so interface routines are necessary to enable these facilities for most VB/VBA programmers I find. I use these as rarely as I can as I believe in using the inbuilt object model (Access for Access; Excel for Excel; etc) wherever possible.
Sep 10 '11 #9
Mihail
759 Contributor
NeoPa !
I know that you are a better coder than me, so I am very care to your opinions. But I think that the API interface is a very very VERY useful and powerful tool but, unfortunately, hard to learn. And hard to use from VB.
Sep 10 '11 #10
NeoPa
32,557 Recognized Expert Moderator MVP
It's definitely useful Mihail. No argument there (and I do use it when necessary). I simply use the interface designed within Access where I can, rather than using OS API calls when I don't need to. That's all I'm saying. They're great for the things that Access can't manage.
Sep 10 '11 #11
AR Ratheesh
25 New Member
I have experienced the same issue. but my team solved this method in simple vba coding.I don't know whether this method is suitable for you or not!!!

Create a start up form(hidden) to check license of you!
if you have a license file located in a secret folder.you just check the file and import the file content and check is it true.if wrong file or location show the message and quit.

you must protect your vba for this method. otherwise access developers or others can unlock this method.

and must disable the shift bye pass key using vba.(remember to make a mechanism or method to enable this bye pass key).
Sep 11 '11 #12
Mihail
759 Contributor
Thank you, AR Ratheesh.

Is a good idea and I use it before to protect some programs.
But, if the computer crash and need a disk format the files with "license" will be lost, so the user need me for a new installation.
I like to avoid that. The hardware is somewhat "fixed" so, if I can generate an "serial" based on it, a backup copy of database will work also after a computer crash.

Thank you again for your interest.
Sep 11 '11 #13
AR Ratheesh
25 New Member
Ya , Disk format is a issue. but this will be a rare case. not happens in every day.so you advise to take back ups for safety.

And try to send the license file via e-mail to you while the first installation. and if they committed to disk format.They can use the backups.But they must
contact you(They cant use DB from the formatting).

U just send a tiny Access program to reset license. Note that u should kill the that access activating file after the first use via vba.(Otherwise clients can misuse or redistribute it.)

The license file must be only for that PC(setup something unique for that pc -> PC-name or IP adress or something like that).

AR Ratheesh
Sep 12 '11 #14
Mihail
759 Contributor
Yes, AR Ratheesh. It is what I am looking for: to catch, via VBA, something unique and unalterable for a certain PC.
Sep 12 '11 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2379
by: Mario_5 | last post by:
How you protect your application from ilegal coping? Is it some passwords, or limited number of copies, or something else. Do you develop your own protection or you are use third party solutions?...
11
3342
by: siliconmike | last post by:
Is there a way to protect data files from access by root ? I have a data-centered website and would like to protect data piracy from any foot-loose hosting company employee. Any ideas? ...
23
2327
by: Luc | last post by:
how can I copy protect the text content of my webpage?
3
3304
by: Narlen | last post by:
Hi there, I don't know much about web design but I proudly managed to password protect a page on my site. Later I realized that everyone looking at the source in any web browser can see the...
15
5043
by: Fady Anwar | last post by:
Hi while browsing the net i noticed that there is sites publishing some software that claim that it can decompile .net applications i didn't bleave it in fact but after trying it i was surprised...
5
2981
by: Brent Burkart | last post by:
I want to protect my website with a user and password. I have SQL Server 2000 where I want to store the users and passwords and the website is complete. I just need to add in some security with...
4
2559
by: sunniyeow | last post by:
Hi, My question is regarding password protecting 2 different folders inside a single virtual directory using forms authentication method. Easier if I illustrate things out... - <authentication...
3
3749
by: Miro | last post by:
Why Password protect an MDB when someone can google and get a hack? Wondering if anyone else has thought of this and just said "oh well"... I plan to password protect an MDB where I have some...
22
5768
by: teejayem | last post by:
Hi, I am new to programming with databases and was wanting some help. Is there any way to password protect an access database and access sent sql commands to it via vb.net code? Any help...
7
2335
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. I have an ASP.NET 2.0 web application which contains an Images directory with all website images. How can I prevent other websites from creating img tags with the source as my images? I want...
0
7226
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7125
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7049
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5631
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3199
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3186
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1561
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
767
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.