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

站上一個C的範例,煩請前輩們幫幫小弟轉成delphi!

尚未結案
tonyplus
初階會員


發表:22
回覆:97
積分:28
註冊:2002-04-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-05-13 10:20:37 IP:211.23.xxx.xxx 未訂閱
這是站上一位前輩寫的範例,功能好像是取得同一個submask下的網卡mac,但 是小弟看不懂c,所以只好再請各位前輩幫幫忙,轉成delphi,謝謝! example: #include //include windows.h #include //include wincon.h #include //include stdlib.h #include //include stdio.h #include //include time typedef struct _ASTAT_ { ADAPTER_STATUS adapt; NAME_BUFFER NameBuff [30]; }ASTAT, * PASTAT; ASTAT Adapter; void main (void) { NCB ncb; UCHAR uRetCode; char NetName[50]; memset( &ncb, 0, sizeof(ncb) ); ncb.ncb_command = NCBRESET; ncb.ncb_lana_num = 0; uRetCode = Netbios( &ncb ); printf( "The NCBRESET return code is: 0x%x \n", uRetCode ); memset( &ncb, 0, sizeof(ncb) ); ncb.ncb_command = NCBASTAT; ncb.ncb_lana_num = 0; strcpy( ncb.ncb_callname, "* " ); ncb.ncb_buffer = (char *) &Adapter; ncb.ncb_length = sizeof(Adapter); uRetCode = Netbios( &ncb ); printf( "The NCBASTAT return code is: 0x%x \n", uRetCode ); if ( uRetCode == 0 ) { printf( "The Ethernet Number is: xxxxxx\n", Adapter.adapt.adapter_address[0], Adapter.adapt.adapter_address[1], Adapter.adapt.adapter_address[2], Adapter.adapt.adapter_address[3], Adapter.adapt.adapter_address[4], Adapter.adapt.adapter_address[5] ); } }
william
版主


發表:66
回覆:2535
積分:3048
註冊:2002-07-11

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-05-13 10:52:06 IP:147.8.xxx.xxx 未訂閱
Remember to uses Nb30.
var
    ncb: TNCB;
    uRetCode: char;
    NetName: string;
    Adapter: TAdapterStatus;
begin
    FillChar(ncb,SizeOf(ncb),0);
    ncb.ncb_command := char(NCBRESET);
    ncb.ncb_lana_num := char(0);
    uRetCode := Netbios(@ncb);
    ShowMessage(Format('The NCBRESET return code is: 0x%x',[byte(uRetCode)]));
    ncb.ncb_command := char(NCBASTAT);
    ncb.ncb_lana_num := char(0);
    ncb.ncb_callname := '* ';
    uRetCode := Netbios(@ncb);
    ncb.ncb_buffer := @Adapter;
    ncb.ncb_length := sizeof(Adapter);
    uRetCode := Netbios(@ncb);
    ShowMessage(Format('The NCBASTAT return code is: 0x%x',[byte(uRetCode)]));
    if uRetCode=#0 then with Adapter do
        ShowMessage(Format('The Ethernet Number is: xxxxxx',
        [byte(adapter_address[0]),byte(adapter_address[1]),byte(adapter_address[2]),
        byte(adapter_address[3]),byte(adapter_address[4]),byte(adapter_address[5])]));
end;
tonyplus
初階會員


發表:22
回覆:97
積分:28
註冊:2002-04-13

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-05-13 11:51:02 IP:211.23.xxx.xxx 未訂閱
引言: Remember to uses Nb30.
var
    ncb: TNCB;
    uRetCode: char;
    NetName: string;
    Adapter: TAdapterStatus;
begin
    FillChar(ncb,SizeOf(ncb),0);
    ncb.ncb_command := char(NCBRESET);
    ncb.ncb_lana_num := char(0);
    uRetCode := Netbios(@ncb);
    ShowMessage(Format('The NCBRESET return code is: 0x%x',[byte(uRetCode)]));
    ncb.ncb_command := char(NCBASTAT);
    ncb.ncb_lana_num := char(0);
    ncb.ncb_callname := '* ';
    uRetCode := Netbios(@ncb);
    ncb.ncb_buffer := @Adapter;
    ncb.ncb_length := sizeof(Adapter);
    uRetCode := Netbios(@ncb);
    ShowMessage(Format('The NCBASTAT return code is: 0x%x',[byte(uRetCode)]));
    if uRetCode=#0 then with Adapter do
        ShowMessage(Format('The Ethernet Number is: xxxxxx',
        [byte(adapter_address[0]),byte(adapter_address[1]),byte(adapter_address[2]),
        byte(adapter_address[3]),byte(adapter_address[4]),byte(adapter_address[5])]));
end;
thanks,I will try this right now! 發表人 -
wnhoo
高階會員


發表:75
回覆:443
積分:198
註冊:2003-04-22

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-05-13 19:46:55 IP:61.155.xxx.xxx 未訂閱
这是取得网卡的MAC地址的实现方法。 我将它写个函数,供您参考!!!    uses Nb30;//一定要加入    function GetPhysicalAddress: string; Var   NCB : TNCB;   ADAPTER : TADAPTERSTATUS;   LANAENUM : TLANAENUM;   intIdx : Integer;   re : Char;   buf : String; begin   Try     ZeroMemory(@NCB, SizeOf(NCB));     NCB.ncb_command := Chr(NCBRESET);     NCB.ncb_lana_num := LANAENUM.lana[0];     re := NetBios(@NCB);     If Ord(re)<>0 Then     begin       Result := '';       exit;     end;     ZeroMemory(@NCB, SizeOf(NCB));     NCB.ncb_command := Chr(NCBASTAT);     NCB.ncb_lana_num := LANAENUM.lana[0];     StrPCopy(NCB.ncb_callname, '*');     NCB.ncb_buffer := @ADAPTER.adapter_address[0];     NCB.ncb_length := SizeOf(ADAPTER);     re := NetBios(@NCB);     If Ord(re)<>0 Then       exit;        buf := '';     For intIdx := 0 To 5 Do       buf := buf + InttoHex(Integer(ADAPTER.adapter_address[intIdx]),2)+'-';     Result := copy(buf,0,length(buf)-1);   finally     //   end; end;    使用 procedure TForm1.Button1Click(Sender: TObject); begin EDIT1.Text :=GetPhysicalAddress; end;    风花雪月 e梦情缘
------
风花雪月 e梦情缘
系統時間:2024-06-27 4:11:47
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!