◀ANSI版開発トップへ
  • 2565 CProfile::WriteProfileは_lwriteのままだったので
    • 2576 Re: CProfile::WriteProfileは_lwriteのままだったので
  • [2565] CProfile::WriteProfileは_lwriteのままだったので Mr.Nak 2003年02月12日 12:20

    こういう風に書き換えてはどうでしょうか?

    BOOL CProfile::WriteProfile( const char* pszProfileName, const char* pszComment )
    {
    int i;
    int j;
    // char szLine[102400];
    HFILE hFile;
    char* pData;
    int nDataLen;
    if( NULL != pszProfileName ){
    strcpy( m_szProfileName, pszProfileName );
    }

    hFile = _tfopen( m_szProfileName, _T("wb") );
    if( NULL == hFile ){
    ::MYMESSAGEBOX( NULL, MB_OK | MB_ICONSTOP | MB_TOPMOST, GSTR_APPNAME,
    "ファイルを作成できませんでした。\n\n%s", m_szProfileName
    );
    return FALSE;
    }
    /* コメント書き込み */
    fwrite( "//", 1, 2, hFile );
    fwrite( pszComment, strlen( pszComment ), hFile );
    fwrite( "\r\n", 1, 2, hFile );
    fwrite( "\r\n", 1, 2, hFile );


    for( i = 0; i < m_nSecNum; ++i ){
    if( 0 < i ){
    fwrite( "\r\n", 1, 2, hFile );
    }
    fwrite( hFile, "[", 1, hFile );
    pData = m_pSecNameArr[i]->GetPtr( &nDataLen );
    fwrite( pData, 1, nDataLen, hFile );
    fwrite( "]\r\n", 1, 3, hFile );
    for( j = 0; j < m_nSecDataNumArr[i]; ++j ){
    pData = m_pDataNameArr[i][j]->GetPtr( &nDataLen );
    fwrite( pData, 1, nDataLen, hFile );
    fwrite( "=", 1, 1, hFile );
    pData = m_pDataArr[i][j]->GetPtr( &nDataLen );
    fwrite( pData, 1, nDataLen, hFile );
    fwrite( "\r\n", 1, 2, hFile );
    }
    }
    fwrite( "\r\n", 1, 2 ,hFile );
    fclose( hFile );
    return TRUE;
    }

    ついでにReadProfileもfreadに書き換えたほうがいいのかも。
    • [2576] Re: CProfile::WriteProfileは_lwriteのままだったので もか 2003年02月17日 16:23

      >BOOL CProfile::WriteProfile( const char* pszProfileName, const char* pszComment )
      > hFile = _tfopen( m_szProfileName, _T("wb") );
      に書き換えるのだから、
      > HFILE hFile;
      は、
      FILE* hFile;
      ですよね。
      変数名もhFileというより、pFileですが...