• Question

  • Hello Dear friends

    can I get  a VBA code show me the Motherboard and Processor serial number working on Microsoft access VB code please ? 

    because I want to protect my Database !!!

    please help 

    Alalikhan Abbas 



    Thursday, June 1, 2017 3:01 AM

All replies

  • That's impractical. Too many MOBO and Processor vendors, and too few and evolving standards. The companies that specialize in this sell their products for a good amount of money for a reason: it is decidedly non-trivial.

    One thing you could implement as a better-than-average VBA developer is code to pass some information to your webservice on your website to see if a particular installation is valid.

    The finer points depend heavily on your specific situation.

    At the end of the day, nothing done with Access is ever truly secure.

    Have you thought about rather than distributing an application to be installed locally outside of your control, hosting it for your customers and give them access to it via RemoteApp or similar?

    -Tom. Microsoft Access MVP

    Thursday, June 1, 2017 4:03 AM
  • Look at Windows Management Instrumentation (WMI).

    If "protect my Database" means you want to develop some kind of licensing then note that that has been done very many times, you are not likely to develop anything better than what someone else has and note that many people have substantial experience breaking the licensing of software. Doing it in VBA is futile.

    Sam Hobbs

    Thursday, June 1, 2017 5:38 PM
  • Hello,

    Please test the code below:

    Option Explicit
     Private m_mainWmi As Object
     Private m_deviceLists As Collection
    Sub abc()
    MsgBox GetWmiDeviceSingleValue("Win32_BaseBoard", "SerialNumber")
    End Sub
     Private Function GetMainWMIObject() As Object
       On Error GoTo eh
       If m_mainWmi Is Nothing Then
         Set m_mainWmi = GetObject("WinMgmts:")
       End If
       Set GetMainWMIObject = m_mainWmi
       Exit Function
       Set GetMainWMIObject = Nothing
     End Function
     Public Function WmiIsAvailable() As Boolean
       WmiIsAvailable = CBool(Not GetMainWMIObject Is Nothing)
     End Function
     Public Function GetWmiDeviceSingleValue(ByVal WmiClass As String, ByVal WmiProperty As String) As String
       On Error GoTo done
       Dim result As String
       Dim wmiclassObjList As Object
       Set wmiclassObjList = GetWmiDeviceList(WmiClass)
       Dim wmiclassObj As Object
       For Each wmiclassObj In wmiclassObjList
         result = CallByName(wmiclassObj, WmiProperty, VbGet)
         Exit For
       GetWmiDeviceSingleValue = Trim(result)
     End Function
     Public Function GetWmiDeviceList(ByVal WmiClass As String) As Object
       If m_deviceLists Is Nothing Then
         Set m_deviceLists = New Collection
       End If
       On Error GoTo fetchNew
       Set GetWmiDeviceList = m_deviceLists.Item(WmiClass)
       Exit Function
       Dim devList As Object
       Set devList = GetWmiDeviceListInternal(WmiClass)
       If Not devList Is Nothing Then
         Call m_deviceLists.Add(devList, WmiClass)
       End If
       Set GetWmiDeviceList = devList
     End Function
     Private Function GetWmiDeviceListInternal(ByVal WmiClass As String) As Object
       On Error GoTo eh
       Set GetWmiDeviceListInternal = GetMainWMIObject.Instancesof(WmiClass)
       Exit Function
       Set GetWmiDeviceListInternal = Nothing
     End Function

    You could visit How to get the serial of my motherboard to see how to achieve it using VB.NET/System.Management.dll



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, June 2, 2017 6:22 AM