This C++ Builder example loads HardwareID.dll dynamically with LoadLibrary and resolves each function with GetProcAddress. Dynamic loading lets the application start even if the DLL is missing, and makes it easy to show a clear error message.

The example reads the machine ID, checks for VMware and prints the result.

Before you start

  1. Install the trial build.
  2. Copy HardwareID.dll next to the executable or into the application directory.
  3. Load the DLL and resolve the function pointers.
  4. Call SetLicenseKey(), then GetHardwareId().

Complete example

C++ Builder
//---------------------------------------------------------------------------
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}

void (__stdcall *SetLicenseKey)(char*);
void (__stdcall *SetAppName)(char*);
int (__stdcall *GetHardwareId)(BOOL, BOOL, BOOL, BOOL, char*, int);

HINSTANCE DllInst = NULL;

//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
    char lpHWID[255];
    int iRtn;

    SetAppName("");

    iRtn = GetHardwareId(cbHDD->Checked, cbNIC->Checked, cbCPU->Checked, cbBIOS->Checked, lpHWID, 255);
    if (iRtn > 0)
    {
        Edit1->Text = lpHWID;
    }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::btnGetWithAppClick(TObject *Sender)
{
    char lpHWID[255];
    int iRtn;

    SetAppName(Edit2->Text.c_str());
    iRtn = GetHardwareId(cbHDD->Checked, cbNIC->Checked, cbCPU->Checked, cbBIOS->Checked, lpHWID, 255);
    if (iRtn > 0)
    {
        Edit3->Text = lpHWID;
    }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  if (DllInst == NULL) DllInst = LoadLibrary("HardwareID.dll");
  if (DllInst)
  {
    SetLicenseKey = (void (__stdcall*)(char*))GetProcAddress(DllInst,"SetLicenseKey");
    SetAppName = (void (__stdcall*)(char*))GetProcAddress(DllInst,"SetAppName");
    GetHardwareId = (int (__stdcall*)(BOOL, BOOL, BOOL, BOOL, char*, int))GetProcAddress(DllInst,"GetHardwareId");

    SetLicenseKey("Your-License-Key");
   }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormDestroy(TObject *Sender)
{
  if ( DllInst ) FreeLibrary (DllInst);        
}
//---------------------------------------------------------------------------

How it works

  • Check every GetProcAddress result before calling it.
  • Call FreeLibrary() when the application exits.
  • Use the matching 32-bit or 64-bit DLL build.
During evaluation, leave the placeholder license key in place. After purchase, replace it with the key from your email.