» 2. C++ Builder Sample Code: Generate unique HardwareID in 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);        
                }
                //---------------------------------------------------------------------------