贴几段代码:
//获取当前路径
HINSTANCE hInst;
CString ls_Name;
ls_Name=AfxGetApp()->m_pszAppName;//获得应用程序的文件名
hInst=GetModuleHandle(ls_Name);//获得应用程序的句柄
char szBuf[256];
char * p;
GetModuleFileName(hInst,szBuf,sizeof(szBuf));//获得应用程序所在的目录
p=szBuf;
while(strchr(p,'//'))
{ p=strchr(p,'//');
p++;
}
*p='/0';
gszAppPath=(CString)szBuf;
...
//ini文本文件,不存在该文件就新建。若存在不允许覆盖
CString mTempStr;
mTempStr=gszAppPath+"param.ini";
CFileException ex;
CFile mFile;
if (!(mFile.Open(mTempStr, CFile::modeCreate|CFile::modeNoTruncate,&ex)))
{
//MessageBox("没有被创建");
TCHAR szError[1024];
ex.GetErrorMessage(szError, 1024);
MessageBox(szError);
}
else
{
//MessageBox("已经存在");
mFile.Close();
}
...
//写入参数设置
CString strTemp,strTemp1;
strTemp=gszAppPath+"param.ini";
strTemp1.Format("%d",m_AutoID);
::WritePrivateProfileString("ParamInfo","流水号",strTemp1,strTemp);
::WritePrivateProfileString("ParamInfo","卡号",m_CardNo,strTemp);
strTemp1.Format("%d",m_GunNo);
::WritePrivateProfileString("ParamInfo","枪号",strTemp1,strTemp);
strTemp1.Format("%d",m_GunNo1);
::WritePrivateProfileString("ParamInfo","枪编号第一字节",strTemp1,strTemp);
strTemp1.Format("%d",m_GunNo2);
::WritePrivateProfileString("ParamInfo","枪编号第二字节",strTemp1,strTemp);
strTemp1.Format("%d",m_GunNo3);
::WritePrivateProfileString("ParamInfo","枪编号第三字节",strTemp1,strTemp);
...
//加载参数设置
m_AutoID=::GetPrivateProfileInt("ParamInfo","流水号",0,mTempStr);
::GetPrivateProfileString("ParamInfo","卡号","",
m_CardNo.GetBuffer(100),100,mTempStr);
m_CardNo.ReleaseBuffer();
m_GunNo=::GetPrivateProfileInt("ParamInfo","枪号",0,mTempStr);
m_GunNo1=::GetPrivateProfileInt("ParamInfo","枪编号第一字节",0,mTempStr);
m_GunNo2=::GetPrivateProfileInt("ParamInfo","枪编号第二字节",0,mTempStr);
m_GunNo3=::GetPrivateProfileInt("ParamInfo","枪编号第三字节",0,mTempStr);
UpdateData(FALSE);
...
奇怪小问题,添加的类在类视图里不显示
5 楼zhdleo(叮东)回复于 2003-04-11 22:14:01 得分 20
不用那么烦!
就删调 *.ncb, *.clw后,
重新打开工程,再打开向导,这时候会提问你恢复破坏的文件.
什么也不管,也不选,一路NEXT,就行了.