Server.ini文件:
[General]
FastStart=1
Changeler=1233
ChangellerA=1234
操作:
CString m_strAppPath,m_strIni;
char buf[MAX_PATH];
::GetModuleFileName(NULL,buf,sizeof(buf));
CString str=buf;
int m=str.ReverseFind('//');
m_strAppPath=str.Left(m+1);
str.Empty();
double dOldVersion=0;
m_strIni = m_strAppPath + _T("//Server.ini");
//取为字符串
::GetPrivateProfileString("General","Changeler","0",buf,sizeof(buf),m_strIni);
//取为整型值
int nget;
nget = GetPrivateProfileInt("General","FastStart",0,m_strIni);
//写INI值
WritePrivateProfileString("General","H323InAuthPrefix",m_strIni,m_strIni);
原型:winbase.h
WINBASEAPI
DWORD
WINAPI
GetPrivateProfileStringA(
LPCSTR lpAppName,
LPCSTR lpKeyName,
LPCSTR lpDefault,
LPSTR lpReturnedString,
DWORD nSize,
LPCSTR lpFileName
);
WINBASEAPI
DWORD
WINAPI
GetPrivateProfileStringW(
LPCWSTR lpAppName,
LPCWSTR lpKeyName,
LPCWSTR lpDefault,
LPWSTR lpReturnedString,
DWORD nSize,
LPCWSTR lpFileName
);
#ifdef UNICODE
#define GetPrivateProfileString GetPrivateProfileStringW
#else
#define GetPrivateProfileString GetPrivateProfileStringA
#endif // !UNICODE