全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2547
推到 Plurk!
推到 Facebook!

在 WIN2000/XP 中如何取得機內綱絡卡之硬件序號

 
alexyip007
一般會員


發表:5
回覆:4
積分:1
註冊:2002-03-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2002-04-10 19:31:39 IP:202.175.xxx.xxx 未訂閱
本人在WIN9X中可透過Registers得知綱絡卡之硬件序號, 但不能用在 WIN2000/XP中, 敬請各位朋友指點, 不勝感激.
lee
站長


發表:55
回覆:173
積分:45
註冊:2002-02-27

發送簡訊給我
#2 引用回覆 回覆 發表時間:2002-04-10 21:07:46 IP:61.219.xxx.xxx 未訂閱
到本站的檔案區有一範例,見下 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=10648    但好像只能在windows 98,windows 2000好像不行! 列出原始程式碼:
unit MainMAC;    interface    uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, NB30;    type
  TGetMACForm = class(TForm)
    Edit1: TEdit;
    ComboBox1: TComboBox;
    MACAddrButton: TButton;
    ResetButton: TButton;
    Label1: TLabel;
    Label2: TLabel;
    procedure MACAddrButtonClick(Sender: TObject);
    procedure ResetButtonClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;    var
  GetMACForm: TGetMACForm;    implementation    {$R *.DFM}    type
 TNBLanaResources = (lrAlloc, lrFree);    type
 PMACAddress = ^TMACAddress;
 TMACAddress = array[0..5] of Byte;    {
The LanaEnum parameter specifies structure describing accessible numbers Lana.
The amounty Lana is defined by number of the installed network cards and network
protocols for each of them. Each accessible Lana identifies a unique combination
of one driver of the protocol and one network card. Each structure NCB contains
a field ncb_lana_num, in which necessary number Lana (i.e. identifier of pair
protocol/MAC) should be written.
In systems with one network card, Lana = 0, usually corresponds
"to the protocol by default".
}    // Get the list of adapters
function GetLanaEnum(LanaEnum: PLanaEnum): Byte;
var
  LanaEnumNCB: PNCB;
begin
  New(LanaEnumNCB);
  ZeroMemory(LanaEnumNCB, SizeOf(TNCB));
  try
    with LanaEnumNCB^ do
    begin
      ncb_buffer := PChar(LanaEnum);
      ncb_length := SizeOf(TLanaEnum);
      ncb_command  := Char(NCBENUM);
      NetBios(LanaEnumNCB);
      Result := Byte(ncb_cmd_cplt);
    end;
  finally
    Dispose(LanaEnumNCB);
  end;
end;    procedure TGetMACForm.FormCreate(Sender: TObject);
var
  LanaEnum: PLanaEnum;
  I: Integer;
begin
  Edit1.Text := '';
  New(LanaEnum);
  ZeroMemory(LanaEnum, SizeOf(TLanaEnum));
  try
    if GetLanaEnum(LanaEnum) = NRC_GOODRET then
    begin
      with ComboBox1, Items do
      begin
        Sorted := True;
        BeginUpdate;
        Clear;
        for I := 0 to Byte(LanaEnum.length) - 1 do
          Add(IntToStr(Byte(LanaEnum.lana[I])));
        ItemIndex := 0;
        EndUpdate;
      end;
    end;
  finally
    Dispose(LanaEnum);
  end;
  ResetButton.Enabled := (Win32Platform = VER_PLATFORM_WIN32_NT);
end;    function ResetLana(LanaNum, ReqSessions, ReqNames: Byte;
  LanaRes: TNBLanaResources): Byte;
var
  ResetNCB: PNCB;
begin
  New(ResetNCB);
  ZeroMemory(ResetNCB, SizeOf(TNCB));
  try
    with ResetNCB^ do
    begin
      ncb_lana_num := Char(LanaNum);        // Set Lana_Num
      ncb_lsn := Char(LanaRes);             // Allocation of new resources
      ncb_callname[0] := Char(ReqSessions); // Query of max sessions
      ncb_callname[1] := #0;                // Query of max NCBs (default)
      ncb_callname[2] := Char(ReqNames);    // Query of max names
      ncb_callname[3] := #0;                // Query of use NAME_NUMBER_1
      ncb_command  := Char(NCBRESET);
      NetBios(ResetNCB);
      Result := Byte(ncb_cmd_cplt);
    end;
  finally
    Dispose(ResetNCB);
  end;
end;    function GetMACAddress(LanaNum: Byte; MACAddress: PMACAddress): Byte;
var
  AdapterStatus: PAdapterStatus;
  StatNCB: PNCB;
begin
  New(StatNCB);
  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 := Char(LanaNum);
      ncb_command  := Char(NCBASTAT);
      NetBios(StatNCB);
      Result := Byte(ncb_cmd_cplt);
      if Result = NRC_GOODRET then
        MoveMemory(MACAddress, AdapterStatus, SizeOf(TMACAddress));
    end;
  finally
    FreeMem(AdapterStatus);
    Dispose(StatNCB);
  end;
end;    procedure TGetMACForm.MACAddrButtonClick(Sender: TObject);
var
  LanaNum: Byte;
  MACAddress: PMACAddress;
  RetCode: Byte;
begin
  LanaNum := StrToInt(ComboBox1.Text);
  New(MACAddress);
  try
    RetCode := GetMACAddress(LanaNum, MACAddress);
    if RetCode = NRC_GOODRET then
    begin
      Edit1.Text := 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]]);
    end else
    begin
      Beep;
      Edit1.Text := 'Error';
      ShowMessage('GetMACAddress Error! RetCode = $'   IntToHex(RetCode, 2));
    end;
  finally
    Dispose(MACAddress);
  end;
end;    procedure TGetMACForm.ResetButtonClick(Sender: TObject);
var
  RetCode: Byte;
  LanaNum: Byte;
begin
  LanaNum := StrToInt(ComboBox1.Text);
  RetCode := ResetLana(LanaNum, 0, 0, lrAlloc);
  if RetCode <> NRC_GOODRET then
  begin
    Beep;
    ShowMessage('Reset Error! RetCode = $'   IntToHex(RetCode, 2));
  end;
end;    procedure TGetMACForm.ComboBox1Change(Sender: TObject);
begin
  Edit1.Text := '';
end;    end.
~~~Delphi K.Top網站總管~~~
------
~~~Delphi K.Top網站總管~~~
alexyip007
一般會員


發表:5
回覆:4
積分:1
註冊:2002-03-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2002-04-11 22:45:43 IP:202.175.xxx.xxx 未訂閱
多謝 Delphi K.Top網站總管, 閣下供給供之程式在WINDOWS98中運作正常,在WINDOWS 2000必先安裝 NETBEUI PROTOCOL 並稍作修改: procedure TGetMACForm.MACAddrButtonClick(Sender: TObject); var LanaNum: Byte; MACAddress: PMACAddress; RetCode: Byte; begin LanaNum := StrToInt(ComboBox1.Text); //********** MODIFY ********** RetCode := ResetLana(LanaNum, 0, 0, lrAlloc); if RetCode <> NRC_GOODRET then begin Beep; ShowMessage('Reset Error! RetCode = $' IntToHex(RetCode, 2)); end; //**************************** New(MACAddress); try if RetCode = NRC_GOODRET then begin Edit1.Text := 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]]); end else begin Beep; Edit1.Text := 'Error'; ShowMessage('GetMACAddress Error! RetCode = $' IntToHex(RetCode, 2)); end; finally Dispose(MACAddress); end; end;
alexyip007
一般會員


發表:5
回覆:4
積分:1
註冊:2002-03-13

發送簡訊給我
#4 引用回覆 回覆 發表時間:2002-04-11 22:45:47 IP:202.175.xxx.xxx 未訂閱
多謝 Delphi K.Top網站總管, 閣下供給供之程式在WINDOWS98中運作正常,在WINDOWS 2000必先安裝 NETBEUI PROTOCOL 並稍作修改: procedure TGetMACForm.MACAddrButtonClick(Sender: TObject); var LanaNum: Byte; MACAddress: PMACAddress; RetCode: Byte; begin LanaNum := StrToInt(ComboBox1.Text); //********** MODIFY ********** RetCode := ResetLana(LanaNum, 0, 0, lrAlloc); if RetCode <> NRC_GOODRET then begin Beep; ShowMessage('Reset Error! RetCode = $' IntToHex(RetCode, 2)); end; //**************************** New(MACAddress); try if RetCode = NRC_GOODRET then begin Edit1.Text := 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]]); end else begin Beep; Edit1.Text := 'Error'; ShowMessage('GetMACAddress Error! RetCode = $' IntToHex(RetCode, 2)); end; finally Dispose(MACAddress); end; end;
lee
站長


發表:55
回覆:173
積分:45
註冊:2002-02-27

發送簡訊給我
#5 引用回覆 回覆 發表時間:2002-04-12 08:06:47 IP:61.219.xxx.xxx 未訂閱
非常感謝網友alexyip007提供修正程式, 我已經程式重新整理好放在: http://delphi.ktop.com.tw/topic.php?TOPIC_ID=17963 供網友參考!    ~~~Delphi K.Top網站總管~~~
------
~~~Delphi K.Top網站總管~~~
thomas0728
中階會員


發表:112
回覆:260
積分:89
註冊:2002-03-12

發送簡訊給我
#6 引用回覆 回覆 發表時間:2002-08-28 17:45:45 IP:61.220.xxx.xxx 未訂閱
請問這支程式能重新啟動網路卡嗎? Thomas Chiou
------
Thomas Chiou
jackkcg
站務副站長


發表:891
回覆:1050
積分:848
註冊:2002-03-23

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-07-30 00:39:28 IP:61.64.xxx.xxx 未訂閱
【問題】Delphi如何取得網路卡編號 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=34846 【轉貼】netsh 的dos ip 指令 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=33615 或使用 會員 8866的方式 【發表】動態更改 IP , Subnet Mask , Gateway 等設定值 不用重新開機 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=26552 ********************************************************* 哈哈&兵燹 最會的2大絕招 這個不會與那個也不會 哈哈哈 粉好 Delphi K.Top的K.Top分兩個字解釋Top代表尖端的意思,希望本討論區能提供Delphi的尖端新知 K.表Knowlege 知識,就是本站的標語:Open our mind to make knowledge together! 希望能大家敞開心胸,將知識寶庫結合一起
------
**********************************************************
哈哈&兵燹
最會的2大絕招 這個不會與那個也不會 哈哈哈 粉好

Delphi K.Top的K.Top分兩個字解釋Top代表尖端的意思,希望本討論區能提供Delphi的尖端新知
K.表Knowlege 知識,就是本站的標語:Open our mind
系統時間:2024-05-02 9:08:31
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!