WritePrivateProfileString等讀寫.ini配置檔案
阿新 • • 發佈:2020-08-03
轉載:https://blog.csdn.net/wuguai4/article/details/7287346
配置檔案中經常用到ini檔案,在VC中其函式分別為:
寫入.ini檔案:
BOOL WritePrivateProfileString( LPCTSTR lpAppName, // INI檔案中的一個欄位名[節名]可以有很多個節名 LPCTSTR lpKeyName, // lpAppName 下的一個鍵名,也就是裡面具體的變數名 LPCTSTR lpString, // 鍵值,也就是資料 LPCTSTR lpFileName // INI檔案的路徑 );
讀取.ini檔案:
DWORD GetPrivateProfileString( LPCTSTR lpAppName,// INI檔案中的一個欄位名[節名]可以有很多個節名 LPCTSTR lpKeyName, // lpAppName 下的一個鍵名,也就是裡面具體的變數名 LPCTSTR lpDefault, // 如果lpReturnedString為空,則把個變數賦給lpReturnedString LPTSTR lpReturnedString, // 存放鍵值的指標變數,用於接收INI檔案中鍵值(資料)的接收緩衝區 DWORD nSize, // lpReturnedString的緩衝區大小 LPCTSTR lpFileName // INI檔案的路徑);