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

#include <vcl.h>
#pragma hdrstop

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


void __fastcall TForm1::Button1Click(TObject *Sender)
{
 HINSTANCE Hdl;
     void __stdcall (*GetDiskSerialNumber1)(char drive, char * pout, int &poutsize); //定义函数原型
     Hdl = ::LoadLibrary("jydisk.dll"); //载入DLL
     if(Hdl != NULL) {
         GetDiskSerialNumber1 = (void __stdcall (*)(char drive, char * pout, int &poutsize))::GetProcAddress(Hdl,"GetDiskSerialNumber1"); //获取函数入口地址
         //GetDiskSerialNumber1 = (void __stdcall (*)(char drive, char * pout, int &poutsize))::GetProcAddress(Hdl,MAKEINTRESOURCE(4)); //获取函数入口地址
         //GetDiskSerialNumber1 = (void __stdcall (*)(char drive, char * pout, int &poutsize))::GetProcAddress(Hdl,MAKEINTRESOURCE(29)); //获取函数入口地址

         if(GetDiskSerialNumber1 != NULL) {
             int i;
             char p[100];
             char d;
             d=Edit1->Text[1];
             GetDiskSerialNumber1(d,p,i); //调用DLL中函数
             String s="";
             for (int k=1;k<=i;k++)
             {
             s=s+p[k-1];
             }
             Caption=s+","+IntToStr(i);
         } else {
             ShowMessage("不能找到函数入口!");
         }
         ::FreeLibrary(Hdl); //一定不要忘记调用完毕后释放DLL
     } else {
         ShowMessage("不能载入DLL!");
     }
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
 HINSTANCE Hdl;
     void __stdcall (*GetMacAddr)(char * pout, int &poutsize); //定义函数原型
     Hdl = ::LoadLibrary("jydisk.dll"); //载入DLL
     if(Hdl != NULL) {
         GetMacAddr = (void __stdcall (*)(char * pout, int &poutsize))::GetProcAddress(Hdl,"GetMacAddr"); //获取函数入口地址
         if(GetMacAddr != NULL) {
             int i;
             char p[1000];
             char d;
             d=Edit1->Text[1];
             GetMacAddr(p,i); //调用DLL中函数
             String s="";
             for (int k=1;k<=i;k++)
             {
             s=s+p[k-1];
             }
             Caption=s+","+IntToStr(i);
         } else {
             ShowMessage("不能找到函数入口!");
         }
         ::FreeLibrary(Hdl); //一定不要忘记调用完毕后释放DLL
     } else {
         ShowMessage("不能载入DLL!");
     }
}
//---------------------------------------------------------------------------
