線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:837
推到 Plurk!
推到 Facebook!

如何取得net view下的網路上所有主機?

尚未結案
writeman
初階會員


發表:31
回覆:34
積分:28
註冊:2004-02-17

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-07-22 15:56:10 IP:61.60.xxx.xxx 未訂閱
在命令列模式下可下net view取得現在網路上的主機 除了用winexec直接去呼叫net view之外 用delphi怎麼取得這些主機的名稱?
JustinShen
中階會員


發表:22
回覆:104
積分:80
註冊:2003-09-20

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-07-24 00:07:36 IP:221.225.xxx.xxx 未訂閱
引言: 在命令列模式下可下net view取得現在網路上的主機 除了用winexec直接去呼叫net view之外 用delphi怎麼取得這些主機的名稱?
使用NetQueryDisplayInformation函数,vc 程式如下: #define UNICODE #include #include #include void main( int argc, char *argv[ ] ) { PNET_DISPLAY_GROUP pBuff, p; DWORD res, dwRec, i = 0; // // You can pass a NULL or empty string // to retrieve the local information. // TCHAR szServer[255]=TEXT(""); if(argc > 1) // // Check to see if a server name was passed; // if so, convert it to Unicode. // MultiByteToWideChar(CP_ACP, 0, argv[1], -1, szServer, 255); do // begin do { // // Call the NetQueryDisplayInformation function; // specify information level 3 (group account information). // res = NetQueryDisplayInformation(szServer, 3, i, 1000, MAX_PREFERRED_LENGTH, &dwRec, &pBuff); // // If the call succeeds, // if((res==ERROR_SUCCESS) || (res==ERROR_MORE_DATA)) { p = pBuff; for(;dwRec>0;dwRec--) { // // Print the retrieved group information. // printf("Name: %S\n" "Comment: %S\n" "Group ID: %u\n" "Attributs: %u\n" "--------------------------------\n", p->grpi3_name, p->grpi3_comment, p->grpi3_group_id, p->grpi3_attributes); // // If there is more data, set the index. // i = p->grpi3_next_index; p ; } // // Free the allocated memory. // NetApiBufferFree(pBuff); } else printf("Error: %u\n", res); // // Continue while there is more data. // } while (res==ERROR_MORE_DATA); // end do return; } 您转换一下吧 Justin Shen ============================================= 如果能帮到您,我会很开心;如果能得到您的帮助,是我的荣幸 =============================================
------
====================
我为一切作努力!
Justin Shen

系統時間:2024-06-03 2:23:17
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!