The cure:
Code:#include <windows.h> #include <stdio.h> #include <tchar.h> #define COUNTOF(x) (sizeof(x)/sizeof(x[0])) BOOL MakeFilePathNextToMe(LPCTSTR fileName, LPTSTR outPath, DWORD cchPath) { if (GetModuleFileName(NULL, outPath, cchPath)) { LPTSTR p = _tcsrchr(outPath, TEXT('\\')); if (p) { _tcscpy(p + 1, fileName); return TRUE; } } return FALSE; } int _tmain() { int getID; TCHAR iniPath[MAX_PATH] = {0}; if (!MakeFilePathNextToMe(TEXT("infoDat.ini"), iniPath, COUNTOF(iniPath))) { return -1; } getID = GetPrivateProfileInt(TEXT("Guy"), TEXT("id"), -1, iniPath); _tprintf(TEXT("id = %d\n"), getID); return 0; }




Reply With Quote