Board Maker Serial Number

azhar2006

Registered User.
Local time
Yesterday, 16:15
Joined
Feb 8, 2012
Messages
238
Hi guys
I am using this function to protect the database from copying and transferring it to another computer. And it works very well. But the problem I am facing is that I have to open a window (VBA) to put the Board Maker Serial Number for the program to work. Is there a way to create a table and put the Serial Number of the Board Maker?
Thank you very much
Code:
Public Function GetSetComputerSerial()
    Dim prop As DAO.Property
    Dim dbs As DAO.Database
    On Error GoTo err_handler
    Dim strPCLocker As String
    Set dbs = CurrentDb
    'Set the property's value
    'If it doesn't exist, an error 3270 "Property not found" will occur
    strPCLocker = dbs.Containers("Databases")("UserDefined").Properties("YB01xxxxx288").Value
    If strPCLocker = "_$_" Then
        strPCLocker = GetComputerSerial()
        dbs.Containers("Databases")("UserDefined").Properties("YB01xxxxx88").Value = strPCLocker
    End If
    If Err.Number = 0 Then
        If strPCLocker <> GetComputerSerial() & "" Then
             MsgBox "Check the database manager" & vbCrLf & vbCrLf & _
            "This database cannot be copied to this computer.", vbOKOnly + vbExclamation
            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("YB01xxxxx88", dbText, GetComputerSerial() & "")
        'Append it to the collection
        dbs.Containers("Databases")("UserDefined").Properties.Append prop
    End If
    Resume
End Function
 
you do not need to put it in a table, it is already saved to the db's user-defined property.
what you need is to call this function on Autoexec macro.
 
The code won't work as written.
The function is called GetSetComputerSerial but you reference GetComputerSerial on 3 occasions
Also why use a user defined function YB01xxxxx88?
Why not just get the motherboard number using VBA - I assume that's what you mean by Board Maker Serial Number
 
The code won't work as written.
The function is called GetSetComputerSerial but you reference GetComputerSerial on 3 occasions
Also why use a user defined function YB01xxxxx88?
Why not just get the motherboard number using VBA - I assume that's what you mean by Board Maker Serial Number
Thank you isladogs
Yes I mean the motherboard number

Code:
Public Function GetComputerSerial() As String
 
'gives serial number for processor / motherboard (?)
    Dim SWbemSet As Object
    Dim SWbemObj As Object
    Dim strSerial As String
    Dim strShowForm As String
    Dim strSerialInTable As String
    
    Set SWbemSet = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_Processor")
    For Each SWbemObj In SWbemSet
      strSerial = SWbemObj.Properties_("ProcessorId") 'Property value
      strSerial = Trim(strSerial)
      If Len(strSerial) < 1 Then strSerial = "Unknown value"
    Next
    'clean up
    Set SWbemObj = Nothing
    Set SWbemSet = Nothing
    GetComputerSerial = strSerial
    
    Debug.Print GetComputerSerial
End Function
 
Last edited:

Users who are viewing this thread

Back
Top Bottom