資源描述:
《Linux--如何讀取ini文件.doc》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、1.#define?CONF_FILE_PATH??"Config.ini"??2.??3.#include???4.??5.#ifdef?WIN32??6.#include???7.#include???8.#else??9.??10.#define??MAX_PATH?260??11.??12.#include???13.#include???14.#include???15.#include???16.#include???17.
2、#endif??18.??19.char?g_szConfigPath[MAX_PATH];??20.??21.//獲取當(dāng)前程序目錄??22.int?GetCurrentPath(char?buf[],char?*pFileName)??23.{??24.#ifdef?WIN32??25.????GetModuleFileName(NULL,buf,MAX_PATH);???26.#else??27.????char?pidfile[64];??28.????int?bytes;??29.????int?fd;??30.??31.????sprintf(pidfile,?"/proc/%d
3、/cmdline",?getpid());??32.??33.????fd?=?open(pidfile,?O_RDONLY,?0);??34.????bytes?=?read(fd,?buf,?256);??35.????close(fd);??36.????buf[MAX_PATH]?=?'