为了提高安全性,要在软件里设置“锁定本用户在本机”,这样在别的机子上不能用此用户名/密码登录。原理好象是读硬件信息,如“网卡号”,存储在服务器上。这是怎么详细设计的?

解决方案 »

  1.   

    判断网卡的MAC地址就可以了哦,具体方法请稍等。
      

  2.   

    获取MAC地址的函数,新建一个 UNIT 比如 unit1 把里面东西全部删除,把下面代码复制进去:unit unit1;
    interface
    uses
      Windows,SysUtils,Dialogs,NB30;
    function GetMacAddr_Lqb:String; //获取网卡 Mac 地址implementationfunction GetMacAddr_Lqb:String;
    type
    PMACAddress=^TMACAddress;
    TMACAddress=array[0..5] of Byte;
    var
      ResetNCB,StatNCB:PNCB;
      RetCode:Byte;
      AdapterStatus:PAdapterStatus;
      MACAddress:PMACAddress;
    begin
      New(ResetNCB);
      ZeroMemory(ResetNCB,SizeOf(TNCB));
      try
        with ResetNCB^ do
        begin
          ncb_lana_num:=#0;          // Set Lana_Num
          ncb_lsn:=#0;               // Allocation of new resources
          ncb_callname[0]:=#0; // Query of max sessions
          ncb_callname[1]:=#0; // Query of max NCBs (default)
          ncb_callname[2]:=#0;     // Query of max names
          ncb_callname[3]:=#0;                // Query of use NAME_NUMBER_1
          ncb_command:=Char(NCBRESET);
          NetBios(ResetNCB);
      RetCode :=Byte(ncb_cmd_cplt);
      if RetCode <> NRC_GOODRET then
      

  3.   

        ShowMessage('Reset Error! RetCode = $' + IntToHex(RetCode, 2));
        end;
      finally
        Dispose(ResetNCB);
      end;
    //*******************
      New(StatNCB);
      New(MACAddress);
      ZeroMemory(StatNCB,SizeOf(TNCB));
      StatNCB.ncb_length:=SizeOf(TAdapterStatus)+255*SizeOf(TNameBuffer);
      GetMem(AdapterStatus,StatNCB.ncb_length);
      try
        with StatNCB^ do
        begin
          ZeroMemory(MACAddress,SizeOf(TMACAddress));
          ncb_buffer:=PChar(AdapterStatus);
          ncb_callname:='*              ' + #0;
          ncb_lana_num:=#0;
          ncb_command:=Char(NCBASTAT);
          NetBios(StatNCB);
          RetCode:=Byte(ncb_cmd_cplt);
          if RetCode = NRC_GOODRET then
            MoveMemory(MACAddress, AdapterStatus, SizeOf(TMACAddress));
        if RetCode = NRC_GOODRET then
          Result:=Format('%2.2x-%2.2x-%2.2x-%2.2x-%2.2x-%2.2x',[MACAddress[0],MACAddress[1],MACAddress[2],MACAddress[3], MACAddress[4], MACAddress[5]])
          else
          Result:='Error';
        end;
      finally
        FreeMem(AdapterStatus);
        Dispose(StatNCB);
        Dispose(MACAddress);
      end;
    end;
    end.
      

  4.   

    在服务器上建一个表
    UserID          MacAddr
    10001           00-C0-4F-4A-8D-A1
      .                .
      .                .
      .                .
      

  5.   

    强!
    问一下:
    use 里的NB30是什么?