我在基本对话框上面加两个Radio Button控件,分别为Radio1,Radio2我想实现的功能是: 如果运行程序选中Radio1,则以后每次运行程序都会默认选中Radio1,如果运行程序选中Radio2,则以后每次运行程序都会默认选中Radio2,概括来说就是每次运行程序后默认选中的是上次程序结束时选中的Radio Button控件。我想通过用.ini文件保存控件信息的方法实现这个功能,但是不知道怎么写,请高手们详细指点,一定要详细啊!
解决方案 »
- [lsq19871207]进来 还记得你回的那个帖子吗?子网号为16bit的A类地址 和 子网号为8bit的B类地址的子网掩码有什么不同?
- 怎么按时间条件查询数据库
- 关于文件中读写字符串的问题?
- 关于#define的##连接和#连接
- 又是100分QQ最第3问,如何给QQ发送删除好友消息,也就是给菜单发消息让他弹出删除好友的对话框
- 多线程调试的技术问题。
- 怎样运行时修改listbox的某一列的列名?
- 请问如何读写mp3文件的IDv1和IDv2标签?
- 关于IO完成端口,WSASend()发送后,GetQueuedCompletionStatus一直阻塞着?求解答!
- 跨dll 线程互斥量,不起作用
- 线程安全的问题
- 简单问题:如何让listctrl(里面有数据report)自动选中指定的行
GetPrivateProfileString 从私有初始化文件获取字符串型值
WritePrivateProfileString 写字符串到私有初始化文件
memset(pBuf, 0xCC, sizeof(char)*512);
::GetCurrentDirectory(sizeof(char)*512,pBuf);
CString strPath(pBuf);
strPath += "\\config.ini";//配置文件名,可以任意写
//读取选中的按钮,当对话框初始化时调用。
int iReturn = ::GetPrivateProfileInt("状态","选中",0,strPath);
//设置选中的按钮,当对话框退出时调用
假如选中的是m_iSelectOk = 1
CString str = "";
str.Format("%d",m_iSelectOk);
::WritePrivateProfileString("状态","选中",str,strPath);
写文件:
//得到系统盘路径
CString mFilename;
char systempath[100];
::GetSystemDirectory(systempath,50); CString m_strfname;
CString newdata;
CString curfilename;
CString curfilpath;
//curfilpath = GetCurPath();
curfilpath = systempath;
curfilename = "\\servermarshal.ini";
m_strfname = curfilpath + curfilename;
//在指定位置创建一个文件
CStdioFile m_file(m_strfname,CFile::modeCreate|CFile::modeWrite);
//设置文件长度,
m_file.SetLength(0);
//将结点表内容写入指定文件
m_file.WriteString(strFLG);
//关闭文件
m_file.Close(); 读://得到系统盘路径
CString mFilename;
char systempath[100];
::GetSystemDirectory(systempath,50); CString m_strfname;
CString newdata;
CString curfilename;
CString curfilpath;
//curfilpath = GetCurPath();
curfilpath = systempath;
curfilename = "\\servermarshal.ini";
m_strfname = curfilpath + curfilename;
char m_str3[200];
CFile fis; fis.Open(m_strfname,CFile::modeRead|CFile::typeBinary); if(!fis)
{
AfxMessageBox("FAILEDD");
exit(1);
}
else
{
int m_newinflongth = fis.Read(m_str3,100);
m_str3[m_newinflongth]='\0'; newdata = m_str3;
//AfxMessageBox(newdata);
}