忍者ブログ
NINJA
[1] [2] [3] [4] [5] [6] [7] [8] [9]
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

CStringをLPTSTRへ変換する


LPTSTR xxxxxx::CStringToLptstr(CString strData)
{
    LPTSTR str    = new TCHAR[ strData.GetLength() + 1 ];
    _tcscpy( str, strData );

    return str;
}

PR
指定したフォルダに、指定した形式のファイルを取得する


void xxxxxx::GetFileList(LPCTSTR lpFolder, BOOL bSubFolder, LPCTSTR ExtName ,CStringArray& csFileArray )
{

    // 変数宣言
    CString csSearchFile;
    CFileFind FileFind;
    BOOL bFindNext;

    csSearchFile.Format( _T("%s%s%s") , lpFolder , _T("\\*"), ExtName );

    if(!FileFind.FindFile(csSearchFile))
        return;

    bFindNext = TRUE;

    while( bFindNext ){

        bFindNext = FileFind.FindNextFile();

        // ".",".."でない場合に処理を行う
        if(!FileFind.IsDots()){

            //ディレクトリで、更にサブディレクトリを処理するのであれば自分を呼ぶ
            if(FileFind.IsDirectory() && bSubFolder != FALSE ){
                this->GetFileList(FileFind.GetFilePath() , bSubFolder , csFileArray );
            }
            //ファイルであれば、ファイル名配列に追加していく。
            else{
                csFileArray.Add( FileFind.GetFilePath() );
            }
        }
    }

    // 開放
    FileFind.Close();
}

指定したフォルダにあるファイルを取得する


void xxxxxx::GetFileList(LPCTSTR lpFolder, BOOL bSubFolder, CStringArray& csFileArray )
{
    // クラス宣言
    CUtils mc_utils;

    // 変数宣言
    CString        csSearchFile;
    CFileFind    FileFind;
    BOOL        bFindNext;


    // 検索キーワード作成
    csSearchFile.Format( _T("%s%s") , lpFolder , _T("\\*.*") );

    if(!FileFind.FindFile(csSearchFile))
        return;

    bFindNext = TRUE;

    while( bFindNext ){

        bFindNext = FileFind.FindNextFile();

        // ".",".."でない場合に処理を行う
        if(!FileFind.IsDots()){

            //ディレクトリで、更にサブディレクトリを処理するのであれば自分を呼ぶ
            if(FileFind.IsDirectory() && bSubFolder != FALSE ){
                this->GetFileList(FileFind.GetFilePath() , bSubFolder , csFileArray );
            }
            //ファイルであれば、ファイル名配列に追加していく。
            else{
                csFileArray.Add( FileFind.GetFilePath() );
            }
        }
    }

    // 開放
    FileFind.Close();
}

16進数を文字列に変換する。


CString xxxxxx::DecDoubleToString( double dNum )
{
    CString str;
    str.Format( _T("%lf"), dNum );

    return str;
}

整数を文字列へ変換する。

CString xxxxxx::DexToString(int iData)
{
    CString str;
    str.Format( _T("%d"), iData );

    return str;
}

カレンダー
04 2025/05 06
S M T W T F S
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
フリーエリア
最新CM
最新TB
プロフィール
HN:
No Name Ninja
性別:
非公開
バーコード
ブログ内検索
アーカイブ
P R
Powered by ニンジャブログ  Designed by ゆきぱんだ
Copyright (c) Visual Studio C++のお勉強 All Rights Reserved
忍者ブログ / [PR]