C 獲取IPCONFIG 返回值

2022-04-29 12:24:08 字數 1201 閱讀 4382

在我們獲取本機區域網ip以及其他相關資訊時,直接呼叫系統ipconfig,也是一種很有效的方法。

以下是我用c#實現的 讀取ipconfig的返回值的**:

**///

///獲取ipconfig返回值

//////

返回 ipconfig輸出

public

static

string

getipconfigreturns()

return

string

.empty;

}以下是返回的結果:

**/*

返回結果

windows ip configuration

host name . . . . . . . . . . . . : server

primary dns suffix  . . . . . . . : 

node type . . . . . . . . . . . . : unknown

ip routing enabled. . . . . . . . : no

wins proxy enabled. . . . . . . . : no

ethernet adapter 本地連線:

connection-specific dns suffix  . : 

description . . . . . . . . . . . : nvidia nforce 10/100 mbps ethernet 

physical address. . . . . . . . . : 00-e0-4c-bb-4f-ae

dhcp enabled. . . . . . . . . . . : no

ip address. . . . . . . . . . . . : 192.168.1.26

subnet mask . . . . . . . . . . . : 255.255.255.0

default gateway . . . . . . . . . : 192.168.1.1

dns servers . . . . . . . . . . . : 202.103.24.68

202.103.44.150

*/擴充套件說明:

這裡我們呼叫的是ipconfig,其實就是想在執行裡面輸入ipconfig一樣的效果。既然這樣我們就可以延伸的去呼叫其他的 應用程式,並可獲得呼叫的應用程式的輸出。

expect獲取返回值

對於獲取多台server狀態且不用互動須要用到expect,但有時候expect無法獲取返回值。這裡解釋一下expect怎樣獲取返回值 expect c spawn 1 expect assword eof expect eof catch wait result exit lindex resul...

C語言獲取linux shell命令返回值

c語言執行linux shell命令,對於沒有返回結果的,可直接使用system 函式,對於有返回結果的,可以用popen命令,對其封裝後,可以獲取相應的返回資訊,封裝函式如下 int systemrtn const char cmd,char pbyrtnstr while fgets resul...

C 返回值過載

源文 c 當然是不能僅僅通過返回值過載函式的,但是,我們往往會想 要是支援返回值過載就好了。現在,我就從c 的某個頗受爭議的角落,為您發掘一點東西。假設有這樣乙個函式 type getvalue const dbfield fd 可是,dbfield實際的資料型別對於getvalue來說,並不了解,...