我些了一个小程序,里面进行了一个参数设置,我想把这些设置的结果保存起来,下次直接使用这些设置就可以了,不用每次都设置。
有什么好的办法,就是别人的软件是怎样实现的?

解决方案 »

  1.   

    WritePrivateProfileString
    WriteProfileString或...Int
      

  2.   

    简单,实在不会写注册表的话可以写在当前目录:
    char szCur[256];
    ::GetModuleFileName((HMODULE)AfxGetInstanceHandle( ),szCur,256);
    CString str=szCur;
    int pos=str.ReverseFind('\\'); //把文件名去掉,得到当前目录
    if(pos!=-1)
          str=str.Left(pos+1);
    str+="myconfig.txt";FILE *fp;
    fp=fopen((LPCTSTR)str,"w");
    ASSERT(fp!=NULL);
    ..... //把你的东西写进去
    fclose(fp);读取也是这样。
      

  3.   

    首先SetRegistryKey(_T("Local AppWizard-Generated Applications"));
    写注册表AfxGetApp()->WriteProfileString(ItemText,"pass",Userpass)
    读注册表CString OldText=AfxGetApp()->GetProfileString(UserName,"Set","");