ini 文件的 GetPrivateProfileInt 可以读取负数 CString GetAppPath() { CString path; GetModuleFileName(NULL,path.GetBuffer(MAX_PATH),MAX_PATH); path.ReleaseBuffer(); path=path.Left(path.ReverseFind('\\')+1); //这里得到的是当前路径 return(path); } void CTestIniDlg::OnOK() { // TODO: Add extra validation here //CDialog::OnOK(); CString strConFilePath; strConFilePath.Format("%s\\SpeedConf.ini",GetAppPath()); int nSpeed; nSpeed = GetPrivateProfileInt("Configure","D1Speed",0,strConFilePath); if(nSpeed == 0) { // TTRACE_EX(XH_LOG_TYPE_NORMAL, _T("SpeedConf.ini is not exited \r\n")); CString strTemp; strTemp.Format("%d",-2); WritePrivateProfileString("Configure","D1Speed",strTemp,strConFilePath); nSpeed = -4; } } |
|