[PR]

『新妻LOVELY×CATION』を応援しています!
水無瀬の部屋 > Programming > sample > sendsend > cmdline.cpp
最終更新日: 2007/03/29

   1: //*********************************************************
   2: // プロジェクト: Send to 'SendTo'
   3: //   ファイル名: cmdline.cpp
   4: //*********************************************************
   5: #include "cmdline.h"
   6: #include "pathlist.h"
   7: #include <dlg/browsbox/browsbox.h>
   8: 
   9: 
  10: //---------------------------------------------------------
  11: // ファイルスコープ変数 の 定義
  12: //---------------------------------------------------------
  13: static const struct
  14: 	{ 
  15: 		      int    nCSIDL;
  16: 		      DWORD  flag;
  17: 		const char  *param;
  18: 	} 
  19: g_pair_sendto[] =
  20: 	{
  21: #define sendto_params( name ) { CSIDL_ ## name, SENDTO_ ## name, PARAM_ ## name }
  22: 		sendto_params( STARTMENU ),
  23: 		sendto_params( PROGRAMS ),
  24: 		sendto_params( STARTUP ),
  25: 		sendto_params( ADMINTOOLS ),
  26: 		sendto_params( SENDTO ),
  27: 		sendto_params( FAVORITES ),
  28: 		sendto_params( PERSONAL ),
  29: 		sendto_params( MYPICTURES ),
  30: 		sendto_params( MYMUSIC ),
  31: 		sendto_params( MYVIDEO ),
  32: 		sendto_params( DESKTOPDIRECTORY ),
  33: 		sendto_params( COMMON_STARTMENU ),
  34: 		sendto_params( COMMON_PROGRAMS ),
  35: 		sendto_params( COMMON_STARTUP ),
  36: 		sendto_params( COMMON_ADMINTOOLS ),
  37: 		sendto_params( COMMON_FAVORITES ),
  38: 		sendto_params( COMMON_DOCUMENTS ),
  39: 		sendto_params( COMMON_PICTURES ),
  40: 		sendto_params( COMMON_MUSIC ),
  41: 		sendto_params( COMMON_VIDEO ),
  42: 		sendto_params( COMMON_DESKTOPDIRECTORY ),
  43: 		sendto_params( WINDOWS ),
  44: 		sendto_params( SYSTEM ),
  45: #undef sendto_params
  46: 	};
  47: 
  48: 
  49: //*********************************************************
  50: // ParseCmdLineOption
  51: // コマンドラインを解析して SENDPARAM_t を初期化する
  52: //*********************************************************
  53: bool
  54: ParseCmdLineOption
  55: 	(
  56: 		SENDPARAM_t  *info,
  57: 		int           argc,
  58: 		char        **argv
  59: 	)
  60: {
  61: 	// パラメタの仮定
  62: 	ASSERT( IsValidArgcArgv( argc, argv ) );
  63: 	ASSERT( IsPathMyself( argv[ 0 ] ) ); // 自分自身
  64: 	ASSERT( IsValidPtr( info, sizeof( *info ) ) );
  65: 	
  66: 	// 初期値
  67: 	memzero( info, sizeof( *info ) );
  68: 	info->flags       = 0;
  69: 	info->bOpenFolder = true;  // フォルダは開く
  70: 	info->bNoExt      = false; // 拡張子は付ける
  71: 	info->folder      = CreatePtrList();
  72: 	if ( !info->folder )
  73: 	{
  74: 		return false;
  75: 	}
  76: 
  77: 	// ファイル名が指定されていない場合
  78: 	{
  79: 		bool bTarget = false;
  80: 		{for( int i = 1; !bTarget && (i < argc); ++i )
  81: 		{
  82: 			ASSERT( IsValidStringPtr( argv[i] ) );
  83: 			bTarget = (bTarget || IsPathExist( argv[i] ));
  84: 		}}
  85: 		if ( !bTarget )
  86: 		{
  87: 			return false; // ファイル名が指定されていない
  88: 		}
  89: 	}
  90: 
  91: 	//*********************************************************
  92: 	{
  93: 		//
  94: 		{for( int i = 1; i < argc; ++i )
  95: 		{
  96: 			ASSERT( IsValidStringPtr( argv[ i ] ) );
  97: 
  98: 			//
  99: 			if ( strhstri( argv[ i ], "/path:" ) )
 100: 			{
 101: 				const char *path = argv[ i ] + strlen( "/path:" );
 102: 				if ( IsPathDirectory( path ) )
 103: 				{
 104: 					PathList_AddDirectoryPath( info->folder, path );
 105: 				}
 106: 			}
 107: 
 108: 			// フォルダを開く
 109: 			if ( streqli( argv[ i ], PARAM_NOTOPEN ) )
 110: 			{
 111: 				info->bOpenFolder = false;
 112: 			}
 113: 			// 
 114: 			if ( streqli( argv[ i ], PARAM_NOEXT ) )
 115: 			{
 116: 				info->bNoExt = true;
 117: 			}
 118: 
 119: 			// 登録先(ダイアログで指定)
 120: 			if ( streqli( argv[ i ], PARAM_PATH ) )
 121: 			{
 122: 				info->flags |= SENDTO_PATH;
 123: 			}
 124: 
 125: 			// 登録先(Quick Launch)
 126: 			if ( streqli( argv[ i ], PARAM_QUICKLAUNCH ) )
 127: 			{
 128: 				info->flags |= SENDTO_QUICKLAUNCH;
 129: 			}
 130: 
 131: 			// 登録先(特殊名で指定)
 132: 			{for( int j = 0; j < numof( g_pair_sendto ); ++j )
 133: 			{
 134: 				if ( streqli( argv[ i ], g_pair_sendto[ j ].param ) )
 135: 				{
 136: 					info->flags |= g_pair_sendto[ j ].flag;
 137: 				}
 138: 			}}
 139: 		}}
 140: 
 141: 		// 登録先(ダイアログで指定)
 142: 		if ( SENDTO_PATH == (SENDTO_PATH & info->flags) )
 143: 		{
 144: 			char path[ MAX_PATH_BUF ];
 145: 			if ( BrowseBox( HWND_DESKTOP, 0, "", path, numof(path), "" ) )
 146: 			{
 147: 				PathList_AddDirectoryPath( info->folder, path );
 148: 			}
 149: 		}
 150: 	}
 151: 
 152: 	// 登録先が指定されているが
 153: 	// ファイル名が指定されていない場合
 154: 	return true;
 155: }//ParseCmdLineOption
 156: 
 157: 
 158: //** end **
 159: 

参照:


Google
ご意見・ご感想をお聞かせ下さい。匿名で送信できます。

 * 返信が必要な場合には postmaster@katsura-kotonoha.sakura.ne.jp へ直接メールしてください。

水無瀬の部屋 > sample > sendsend > cmdline.cpp

このページは cpp2web が出力しました。
水無瀬 優 postmaster@katsura-kotonoha.sakura.ne.jp
http://katsura-kotonoha.sakura.ne.jp/prog/code/sendsend/cmdline_cpp.shtml
同人ダウンロード販売
同人ダウンロード販売|DL.Getchu.com