ファイルパス

http://frog.raindrop.jp/knowledge/archives/001079.html

// 有効なファイルパスか
// \/:,;*?"<>l
#include "shlwapi.h"
#pragma comment(lib,"shlwapi.lib")
// Neutral ANSI/UNICODE types and macros
#ifdef  UNICODE                     // r_winnt
typedef WCHAR TUCHAR, *PTUCHAR;
#else   /* UNICODE */               // r_winnt
typedef UCHAR TUCHAR, *PTUCHAR;
#endif
bool isRightFilePath( LPCTSTR path )
{
int count = lstrlen( path );
for(int i=0; i<count; i++){
TUCHAR c = path[i];
UINT ret = ::PathGetCharType(c);

if(ret == GCT_INVALID  ) return false;// 不正な文字

// if(ret & GCT_LFNCHAR   ) return false;// 長いファイル名に使用できる
// if(ret & GCT_SHORTCHAR ) return false;// 短いファイル名に使用できる
if(ret & GCT_WILD      ) return false;// ワイルドカード
if(ret & GCT_SEPARATOR ) return false;// 区切り文字
    }
return true;
}
最終更新:2009年09月08日 16:31
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。