Windows API獲取系統配置檔案的配置引數

2022-04-04 08:05:01 字數 938 閱讀 4653

在windows平台下獲取系統配置檔案(如:system.ini)的配置引數。

系統配置檔案system.ini的內容如下:

[system]

serviceip = 10.128.11.99:60000

commutype = sharememory

**如下:

包含標頭檔案 winbase.h (include windows.h)

//getcurrentpath()函式獲取可執行模組的全路徑,並將路徑中的"\\"變為『\』,之後去掉了路徑中的可執行檔案的名字

static void getcurrentpath(char *pathname)

while (q);

if (p) *p = 0;

p = strstr(pathname,":");

if (p)

while(*p != 0);

*q = 0;

} }}//getsystemconfig()獲取system欄位下,鍵為strkeyname對應的值,如果沒有獲取到,則以預設值strdefault填充。

void getsystemconfig( string strkeyname,string strdefault,char *szrecibuff,int nlen )

//getsystemipconfig()獲取系統檔案中serviceip鍵的值

void getsystemipconfig( char *szrecibuff,int nlen )

//getsystemcommtypeconfig()獲取系統檔案中sharememory鍵的值

void getsystemcommtypeconfig( char *szrecibuff,int nlen )

//測試**:

int main()

Windows API獲取系統配置檔案的配置引數

在windows平台下獲取系統配置檔案 如 system.ini 的配置引數。系統配置檔案system.ini的內容如下 system serviceip 10.128.11.99 60000 commutype sharememory 如下 包含標頭檔案 winbase.h include win...

Windows API 獲取系統路徑

但是這樣每次開發效率就比較低,所以還是整理下吧,加深下印象,至少後面可以在自己部落格裡就能輕鬆的找到了吧。直接上 吧。include stdafx.h include include include include define make pair id std pair id,t id void ...

WindowsAPI獲取時間資訊

時間資訊 1.設定獲取系統時間 1 關鍵api和資料結構 systemtime資料結構 typedef struct systemtime systemtime,psystemtime,lpsystemtime api void winapi getlocaltime lpsystemtime lp...