FILE *pfIniPathName ;
if( (pfIniPathName = fopen(g_fIniPathName , "r")) == NULL )
{
wsprintf(strtmp,"%s%s",gWorkingPath,"CCDAdjust.ini"); 
WritePrivateProfileString("Action", "IniPathName", "CCDAdjust.ini" , strtmp);
wsprintf(g_fIniPathName,"%s%s",gWorkingPath,"CCDAdjust.ini");
}
else
{
fclose(pfIniPathName);
wsprintf(g_fIniPathName,"%s%s",gWorkingPath,"CCDAdjust.ini"); 
GetPrivateProfileString("Action" , "IniPathName" , "CCDAdjust.ini" , (char*)sIniName,64,(char*)g_fIniPathName);
wsprintf(g_fIniPathName,"%s%s",gWorkingPath,sIniName); 
}
请结合以上代码帮我详细介绍一下以下函数的功能和各个形参表示的意思
                   wsprintf();
                   GetprivateProfileString
                   fopen()
                    WritePrivateProfileString
谢谢!!!

解决方案 »

  1.   

    GetprivateProfileString/WritePrivateProfileString读写INI
    fopen打开文件,wspintf向文件的格式化输出。
      

  2.   

    在Windows下应该用CreateFile/ReadFile/WriteFile进行文件操作
      

  3.   

    GetprivateProfileString,WritePrivateProfileString用来读写ini文件,
    fopen用来打开文件
    wsprintf()用来“拼”字符串。具体请察看msdn。
      

  4.   

    BOOL WritePrivateProfileString(
    LPCTSTR lpAppName,
    LPCTSTR lpKeyName,
    LPCTSTR lpString,
    LPCTSTR lpFileName
    ); 
      其中各参数的意义:
       LPCTSTR lpAppName 是INI文件中的一个字段名.
       LPCTSTR lpKeyName 是lpAppName下的一个键名,通俗讲就是变量名.
       LPCTSTR lpString 是键值,也就是变量的值,不过必须为LPCTSTR型或CString型的.
       LPCTSTR lpFileName 是完整的INI文件名.其他函数的参数意义也差不多的
      

  5.   

    // 打开配置文件
    if( (pfIniPathName = fopen(g_fIniPathName , "r")) == NULL ) {
    //合并字符串到strtmp
    wsprintf(strtmp,"%s%s",gWorkingPath,"CCDAdjust.ini"); 
    //把strtmp的内容写到.ini文件中
    // [Action]
    //  IniPathName = strtmp
    WritePrivateProfileString("Action", "IniPathName", "CCDAdjust.ini" , strtmp);
    wsprintf(g_fIniPathName,"%s%s",gWorkingPath,"CCDAdjust.ini");
    }
    else
    {
    fclose(pfIniPathName);
    wsprintf(g_fIniPathName,"%s%s",gWorkingPath,"CCDAdjust.ini"); 
    GetPrivateProfileString("Action" , "IniPathName" , "CCDAdjust.ini" , (char*)sIniName,64,(char*)g_fIniPathName);
    wsprintf(g_fIniPathName,"%s%s",gWorkingPath,sIniName); 
    }