[PR]

水無瀬の部屋 > Programming > sample > sendsend > custom.cpp
最終更新日: 2007/10/24

   1: //*********************************************************
   2: // プロジェクト: Send to 'SendTo'
   3: //   ファイル名: custom.cpp
   4: //*********************************************************
   5: #include "custom.h"
   6: #include "parambox.h"
   7: #include "res.h"
   8: #include "sendsend.h"
   9: #include <relation/relation.h>
  10: #include <header/myweburl.h>       //
  11: #include <dlg/aboutbox/aboutbox.h> //
  12: 
  13: 
  14: //---------------------------------------------------------
  15: // マクロ の 定義
  16: //---------------------------------------------------------
  17: #define PROP_DIALOGPARAM         "PROP_DIALOGPARAM"
  18: #define MAX_CMDLINE              ( 1024 )
  19: #define EXT_EXE                  ".exe"
  20: #define MENU_SENDTO              "[送る] へ登録"
  21: #define MENU_STARTUP             "[スタートアップ] へ登録"
  22: #define MENU_STARTMENU           "[スタートメニュー] へ登録"
  23: #define MENU_DESKTOPDIRECTORY    "[デスクトップ] へ登録"
  24: #define MENU_QUICKLAUNCH         "[クイック起動] へ登録"
  25: #define MENU_PATH                "[...] へ登録"
  26: 
  27: // 
  28: #define REGKEY_SENDTO            "toSendTo"
  29: #define REGKEY_STARTUP           "toStartup"
  30: #define REGKEY_STARTMENU         "toStartMenu"
  31: #define REGKEY_DESKTOPDIRECTORY  "toDesktop"
  32: #define REGKEY_QUICKLAUNCH       "toQuickLaunch"
  33: #define REGKEY_PATH              "toPath"
  34: 
  35: //
  36: #define REGPATH_CLASSESROOT              "HKEY_CLASSES_ROOT"
  37: #define REGPATH_EXEFILE_SHELL            REGPATH_CLASSES_ROOT "\\exefile\\shell\\"
  38: #define VERB_COMMAND                     "command"
  39: 
  40: //
  41: #define MAKE_REGPATH_COMMAND( keyname )  REGPATH_EXEFILE_SHELL keyname "\\" VERB_COMMAND
  42: #define REGPATH_SENDTO                   MAKE_REGPATH_COMMAND( REGKEY_SENDTO )            //
  43: #define REGPATH_STARTUP                  MAKE_REGPATH_COMMAND( REGKEY_STARTUP )           //
  44: #define REGPATH_STARTMENU                MAKE_REGPATH_COMMAND( REGKEY_STARTMENU )         //
  45: #define REGPATH_DESKTOPDIRECTORY         MAKE_REGPATH_COMMAND( REGKEY_DESKTOPDIRECTORY )  //
  46: #define REGPATH_QUICKLAUNCH              MAKE_REGPATH_COMMAND( REGKEY_QUICKLAUNCH )       //
  47: #define REGPATH_PATH                     MAKE_REGPATH_COMMAND( REGKEY_PATH )              //
  48: 
  49: 
  50: //---------------------------------------------------------
  51: // 構造体 の 宣言
  52: //---------------------------------------------------------
  53: // INFO_t
  54: typedef struct INFO_tag
  55: {
  56: 	INSTALLINFO_t insall[ COMMAND_NUM ];
  57: } INFO_t;
  58: 
  59: 
  60: //---------------------------------------------------------
  61: // ファイルスコープ関数 の 宣言
  62: //---------------------------------------------------------
  63: static bool LoadInfo( INFO_t *info );
  64: static bool SaveInfo( const INFO_t *info );
  65: static bool UnloadInfo( INFO_t *info );
  66: static INT_PTR UpdateDialogState( HWND hWnd );
  67: static INT_PTR CALLBACK CustomBoxProc( HWND, UINT, WPARAM, LPARAM );
  68: 
  69: 
  70: //---------------------------------------------------------
  71: // ファイルスコープ変数 の 定義
  72: //---------------------------------------------------------
  73: // 設定項目 と 登録先レジストリ, デフォルト引数, など
  74: static const struct
  75: 	{ 
  76: 		      int   nID;
  77: 		const char *verb;
  78: 		const char *defmenu; 
  79: 		const char *param; 
  80: 		const char *regpath;
  81: 	}
  82: g_pair[] = 
  83: 	{
  84: #define sendto_params( name ) { ID_ ## name, REGKEY_ ## name, MENU_ ## name, PARAM_ ## name, REGPATH_ ## name }
  85: 		sendto_params( STARTMENU ),
  86: 		sendto_params( STARTUP ),
  87: 		sendto_params( SENDTO ),
  88: 		sendto_params( DESKTOPDIRECTORY ),
  89: 		sendto_params( PATH ),
  90: 		sendto_params( QUICKLAUNCH ),
  91: #undef sendto_params
  92: 	};
  93: 
  94: // ダイアログ項目の組み
  95: static const struct
  96: 	{
  97: 		      int   nID; 
  98: 		      int   check;   // チェックボックス
  99: 		      int   menu;    //
 100: 		      int   btn;     // 詳細ボタン
 101: 		const char *defmenu; //
 102: 	}
 103: g_ddx[] = 
 104: 	{ 
 105: #define sendto_params( name ) { ID_ ## name, IDC_EXE ## name, IDC_MENU ## name, IDC_PARAM ## name }
 106: 		sendto_params( STARTMENU ),
 107: 		sendto_params( STARTUP ),
 108: 		sendto_params( SENDTO ),
 109: 		sendto_params( DESKTOPDIRECTORY ),
 110: 		sendto_params( QUICKLAUNCH ),
 111: #undef sendto_params
 112: 	};
 113: 
 114: 
 115: //*********************************************************
 116: // CustomBox
 117: //*********************************************************
 118: bool
 119: CustomBox
 120: 	(
 121: 		HWND hWnd
 122: 	)
 123: {
 124: 	// パラメタの仮定
 125: 	ASSERT( !hWnd || IsValidWindow( hWnd ) );
 126: 
 127: 	HINSTANCE hInstance = GetModuleHandle( null );
 128: 	return IDOK == DialogBoxParam
 129: 		(
 130: 			hInstance,
 131: 			MAKEINTRESOURCE( CUSTOM_BOX ),
 132: 			hWnd,
 133: 			CustomBoxProc,
 134: 			0
 135: 		);
 136: }//CustomBox
 137: 
 138: 
 139: //******************************************************************************************************************
 140: // private
 141: //******************************************************************************************************************
 142: static INT_PTR OnCustomDestroy( HWND hWnd );
 143: static INT_PTR OnCustomHitTest( HWND hWnd, WPARAM wParam, LPARAM lParam );
 144: static INT_PTR OnCustomInitDialog( HWND hWnd, LPARAM lParam );
 145: static INT_PTR OnCustomInitMenuPopup( HWND hWnd );
 146: static INT_PTR OnCustomCommand( HWND hWnd, WPARAM wParam );
 147: static INT_PTR OnCustomSystemCommand( HWND hWnd, WPARAM wParam );
 148: 
 149: 
 150: //*********************************************************
 151: // CustomBoxProc
 152: //*********************************************************
 153: static
 154: INT_PTR
 155: CALLBACK
 156: CustomBoxProc
 157: 	(
 158: 		HWND   hWnd,
 159: 		UINT   uMsg, 
 160: 		WPARAM wParam,
 161: 		LPARAM lParam
 162: 	)
 163: {
 164: 	// パラメタの仮定
 165: 	ASSERT( IsValidWindow( hWnd ) );
 166: 
 167: 	switch( uMsg )
 168: 	{		
 169: 		case WM_DESTROY:       return OnCustomDestroy( hWnd );
 170: 		case WM_NCHITTEST:     return OnCustomHitTest( hWnd, wParam, lParam );
 171: 		case WM_INITDIALOG:    return OnCustomInitDialog( hWnd, lParam );
 172: 		case WM_COMMAND:       return OnCustomCommand( hWnd, wParam );
 173: 		case WM_SYSCOMMAND:    return OnCustomSystemCommand( hWnd, wParam );
 174: 		case WM_INITMENUPOPUP: return OnCustomInitMenuPopup( hWnd );
 175: 		default:               return false;
 176: 	}
 177: }//CustomBoxProc
 178: 
 179: //*********************************************************
 180: // OnCustomDestroy
 181: //*********************************************************
 182: static
 183: INT_PTR
 184: OnCustomDestroy
 185: 	(
 186: 		HWND hWnd
 187: 	)
 188: {
 189: 	// パラメタの仮定
 190: 	ASSERT( IsValidWindow( hWnd ) );
 191: 
 192: 	// 独自データの解放
 193: 	INFO_t *info = (INFO_t *)GetProp( hWnd, PROP_DIALOGPARAM );
 194: 	VERIFY( RemoveProp( hWnd, PROP_DIALOGPARAM ) );
 195: 	VERIFY( UnloadInfo( info ) );
 196: 	free( info );
 197: 
 198: 	return true;
 199: }//OnCustomDestroy
 200: 
 201: //*********************************************************
 202: // OnCustomHitTest
 203: //*********************************************************
 204: static
 205: INT_PTR
 206: OnCustomHitTest
 207: 	(
 208: 		HWND   hWnd,
 209: 		WPARAM wParam, 
 210: 		LPARAM lParam
 211: 	)
 212: {
 213: 	// パラメタの仮定
 214: 	ASSERT( IsValidWindow( hWnd ) );	
 215: 
 216: 	// クライアント領域を掴んで移動できるように
 217: 	const LRESULT lResult = DefWindowProc( hWnd, WM_NCHITTEST, wParam, lParam );
 218: 	SetWindowLongPtr64( hWnd, DWL_MSGRESULT, (HTCLIENT == lResult) ? HTCAPTION : lResult );
 219: 
 220: 	return true;
 221: }//OnCustomHitTest
 222: 
 223: //*********************************************************
 224: // OnCustomInitDialog
 225: //*********************************************************
 226: static
 227: INT_PTR
 228: OnCustomInitDialog
 229: 	(
 230: 		HWND   hWnd, 
 231: 		LPARAM
 232: 	)
 233: {
 234: 	// パラメタの仮定
 235: 	ASSERT( IsValidWindow( hWnd ) );
 236: 
 237: 	//
 238: 	INFO_t *info = (INFO_t *)malloc( sizeof( *info ) );
 239: 	VERIFY( LoadInfo( info ) );
 240: 	VERIFY( SetProp( hWnd, PROP_DIALOGPARAM, info ) );
 241: 
 242: 	// ダイアログの初期化
 243: 	HINSTANCE hInstance = GetModuleHandle( null );
 244: 	SetWindowIcon( hWnd, ICON_BIG,   SHGetInstanceIcon(hInstance, SHGFI_LARGEICON) ); // 大きいアイコン
 245: 	SetWindowIcon( hWnd, ICON_SMALL, SHGetInstanceIcon(hInstance, SHGFI_SMALLICON) ); // 小さいアイコン
 246: 	VERIFY( WindowMoveToCursorPos( hWnd ) );
 247: 
 248: 	// システム・メニューの初期化
 249: 	HMENU hmenuSystem = GetSystemMenu( hWnd, false );
 250: 	const int pos = GetMenuItemPos( hmenuSystem, SC_CLOSE );
 251: 	if ( 0 <= pos )
 252: 	{
 253: 		Menu_InsertSeparator( hmenuSystem, pos, MF_BYPOSITION );
 254: 		InsertMenu( hmenuSystem, pos, MF_STRING|MF_BYPOSITION, IDM_ABOUT, "About(&A)" );
 255: 		Menu_InsertSeparator( hmenuSystem, pos, MF_BYPOSITION );
 256: 		InsertMenu( hmenuSystem, pos, MF_STRING|MF_BYPOSITION, IDM_TOPMOST, "常に最前面に表示(&T)" );
 257: 	}
 258: 
 259:   	// コントロールの初期化
 260: 	{for( int i = 0; i < numof(g_ddx); ++i )
 261: 	{
 262: 		CheckDlgButton
 263: 			(
 264: 				hWnd,
 265: 				g_ddx[ i ].check,
 266: 				info->insall[ g_ddx[ i ].nID ].bInstall ? BST_CHECKED : BST_UNCHECKED
 267: 			);
 268: 		SetDlgItemText
 269: 			(
 270: 				hWnd,
 271: 				g_ddx[ i ].menu,
 272: 				info->insall[ g_ddx[ i ].nID ].menu
 273: 			);
 274: 	}}
 275: 	
 276: 	//
 277: 	UpdateDialogState( hWnd );
 278: 
 279: 	return true;
 280: }//OnCustomInitDialog
 281: 
 282: //*********************************************************
 283: // OnCustomInitMenuPopup
 284: //*********************************************************
 285: static
 286: INT_PTR
 287: OnCustomInitMenuPopup
 288: 	(
 289: 		HWND hWnd
 290: 	)
 291: {
 292: 	// パラメタの仮定
 293: 	ASSERT( IsValidWindow( hWnd ) );
 294: 
 295: 	// システム・メニュー
 296: 	HMENU hSysMenu = GetSystemMenu( hWnd, false );
 297: 	const bool bTopmost = IsWindowTopmost( hWnd );
 298: 	Menu_CheckItem( hSysMenu, IDM_TOPMOST, MF_BYCOMMAND, bTopmost );
 299: 
 300: 	return true;
 301: }//OnCustomInitMenuPopup
 302: 
 303: 
 304: //******************************************************************************************************************
 305: // private - WM_COMMAND
 306: //******************************************************************************************************************
 307: static INT_PTR OnCustomCommandOK( HWND hWnd );
 308: static INT_PTR OnCustomCommandCancel( HWND hWnd );
 309: static INT_PTR OnCustomCommandDefault( HWND hWnd, WPARAM wParam );
 310: 
 311: 
 312: //*********************************************************
 313: // OnCustomCommand
 314: //*********************************************************
 315: static
 316: INT_PTR
 317: OnCustomCommand
 318: 	(
 319: 		HWND   hWnd,
 320: 		WPARAM wParam
 321: 	)
 322: {
 323: 	// パラメタの仮定
 324: 	ASSERT( IsValidWindow( hWnd ) );
 325: 
 326: 	switch( LOWORD(wParam) )
 327: 	{
 328: 		case IDOK:     return OnCustomCommandOK( hWnd );
 329: 		case IDCANCEL: return OnCustomCommandCancel( hWnd );
 330: 		default:       return OnCustomCommandDefault( hWnd, wParam );
 331: 	}
 332: }//OnCustomCommand
 333: 
 334: //*********************************************************
 335: // OnCustomCommandOK
 336: //*********************************************************
 337: static
 338: INT_PTR
 339: OnCustomCommandOK
 340: 	(
 341: 		HWND hWnd
 342: 	)
 343: {
 344: 	// パラメタの仮定
 345: 	ASSERT( IsValidWindow( hWnd ) );	
 346: 
 347: 	//
 348: 	INFO_t *info = (INFO_t *)GetProp( hWnd, PROP_DIALOGPARAM );
 349: 	ASSERT( IsValidPtr( info, sizeof( *info ) ) );
 350: 
 351: 	// 関連づけ
 352: 	{for( int i = 0; i < numof( g_ddx ); ++i )
 353: 	{
 354: 		if ( BST_CHECKED != IsDlgButtonChecked( hWnd, g_ddx[ i ].check ) )
 355: 		{
 356: 			info->insall[ g_ddx[ i ].nID ].bInstall = false;
 357: 		}
 358: 		else
 359: 		{
 360: 			info->insall[ g_ddx[ i ].nID ].bInstall = true;
 361: 
 362: 			free( info->insall[ g_ddx[ i ].nID ].menu );
 363: 			info->insall[ g_ddx[ i ].nID ].menu = AllocDlgItemText( hWnd, g_ddx[ i ].menu );
 364: 			if ( !info->insall[ g_ddx[ i ].nID ].menu )
 365: 			{
 366: 				info->insall[ g_ddx[ i ].nID ].menu = strdup( g_ddx[ i ].defmenu );
 367: 			}
 368: 		}
 369: 	}}
 370: 
 371: 	//	
 372: 	VERIFY( SaveInfo( info ) );
 373: 
 374: 	//
 375: 	VERIFY( EndDialog( hWnd, IDOK ) );
 376: 
 377: 	return true;
 378: }//OnCustomCommandOK
 379: 
 380: //*********************************************************
 381: // OnCustomCommandCancel
 382: //*********************************************************
 383: static
 384: INT_PTR
 385: OnCustomCommandCancel
 386: 	(
 387: 		HWND hWnd
 388: 	)
 389: {
 390: 	// パラメタの仮定
 391: 	ASSERT( IsValidWindow( hWnd ) );	
 392: 	
 393: 	VERIFY( EndDialog( hWnd, IDCANCEL ) );
 394: 
 395: 	return true;
 396: }//OnCustomCommandCancel
 397: 
 398: //*********************************************************
 399: // OnCustomCommandDefault
 400: //*********************************************************
 401: static
 402: INT_PTR
 403: OnCustomCommandDefault
 404: 	(
 405: 		HWND   hWnd,
 406: 		WPARAM wParam
 407: 	)
 408: {
 409: 	// パラメタの仮定
 410: 	ASSERT( IsValidWindow( hWnd ) );
 411: 
 412: 	// コントロール [詳細] が選択された
 413: 	// 引数設定ダイアログを起動する
 414: 	{for( int i = 0; i < numof(g_ddx); ++i )
 415: 	{
 416: 		if ( LOWORD(wParam) == g_ddx[i].btn )
 417: 		{
 418: 			INFO_t *info = (INFO_t *)GetProp( hWnd, PROP_DIALOGPARAM );
 419: 			ParamBox( hWnd, &info->insall[ g_ddx[i].nID ] );
 420: 			return true;
 421: 		}
 422: 	}}
 423: 
 424: 	// 有効/無効が変更された
 425: 	// 関連する各コントロールの有効/無効を更新する
 426: 	{for( int i = 0; i < numof(g_ddx); ++i )
 427: 	{
 428: 		if ( LOWORD(wParam) == g_ddx[i].check )
 429: 		{
 430: 			UpdateDialogState( hWnd );
 431: 			return true;
 432: 		}
 433: 	}}
 434: 
 435: 	// 何も処理しなかった場合
 436: 	return false;
 437: }//OnCustomCommandDefault
 438: 
 439: 
 440: //******************************************************************************************************************
 441: // private - WM_SYSCOMMAND
 442: //******************************************************************************************************************
 443: static INT_PTR OnCustomSystemCommandTopmost( HWND hWnd );
 444: static INT_PTR OnCustomSystemCommandAbout( HWND hWnd );
 445: 
 446: 
 447: 
 448: //*********************************************************
 449: // OnCustomSystemCommand
 450: //*********************************************************
 451: static
 452: INT_PTR
 453: OnCustomSystemCommand
 454: 	(
 455: 		HWND   hWnd,
 456: 		WPARAM wParam
 457: 	)
 458: {
 459: 	// パラメタの仮定
 460: 	ASSERT( IsValidWindow( hWnd ) );
 461: 
 462: 	switch( LOWORD(wParam) )
 463: 	{
 464: 		case IDM_ABOUT:   return OnCustomSystemCommandAbout( hWnd );
 465: 		case IDM_TOPMOST: return OnCustomSystemCommandTopmost( hWnd );
 466: 		default:          return false;
 467: 	}
 468: }//OnCustomSystemCommand
 469: 
 470: //*********************************************************
 471: // OnCustomSystemCommandAbout
 472: //*********************************************************
 473: static
 474: INT_PTR
 475: OnCustomSystemCommandAbout
 476: 	(
 477: 		HWND hWnd
 478: 	)
 479: {
 480: 	// パラメタの仮定
 481: 	ASSERT( IsValidWindow( hWnd ) );
 482: 
 483: 	ABOUTBOX_t tmp; // AboutBox のパラメータ
 484: 	tmp.url = URL_WEBPAGE;
 485: 	AboutBox( hWnd, &tmp ); // 「……について」ダイアログを表示する。
 486: 
 487: 	return true;
 488: }//OnCustomSystemCommandAbout
 489: 
 490: //*********************************************************
 491: // OnCustomSystemCommandTopmost
 492: //*********************************************************
 493: static
 494: INT_PTR
 495: OnCustomSystemCommandTopmost
 496: 	(
 497: 		HWND hWnd
 498: 	)
 499: {
 500: 	// パラメタの仮定
 501: 	ASSERT( IsValidWindow( hWnd ) );
 502: 
 503: 	const bool bTopmost = IsWindowTopmost( hWnd );
 504: 	TopmostWindow( hWnd, !bTopmost );
 505: 
 506: 	return true;
 507: }//OnCustomSystemCommandTopmost
 508: 
 509: 
 510: //******************************************************************************************************************
 511: //
 512: //******************************************************************************************************************
 513: //*********************************************************
 514: // UpdateDialogState
 515: //*********************************************************
 516: static
 517: INT_PTR
 518: UpdateDialogState
 519: 	(
 520: 		HWND hWnd
 521: 	)
 522: {
 523: 	// パラメタの仮定
 524: 	ASSERT( IsValidWindow( hWnd ) );
 525: 
 526: 	{for( int i = 0; i < numof(g_ddx); ++i )
 527: 	{
 528: 		const bool bReadOnly = (BST_CHECKED != IsDlgButtonChecked( hWnd, g_ddx[i].check ));
 529: 		HWND hCtrl = GetDlgItem( hWnd, g_ddx[i].menu );
 530: 		Edit_SetReadOnly( hCtrl, bReadOnly );
 531: 		EnableDlgItem( hWnd, g_ddx[i].btn, !bReadOnly );
 532: 	}}
 533: 
 534: 	return true;
 535: }//UpdateDialogState
 536: 
 537: 
 538: //******************************************************************************************************************
 539: // private
 540: //******************************************************************************************************************
 541: static bool MakeCommandLine( char *buffer, int bufsize, const char *param );
 542: 
 543: 
 544: //*********************************************************
 545: // LoadInfo
 546: //*********************************************************
 547: static
 548: bool
 549: LoadInfo
 550: 	(
 551: 		INFO_t *info
 552: 	)
 553: {
 554: 	// パラメタの仮定
 555: 	ASSERT( IsValidPtr( info, sizeof( *info ) ) );
 556: 
 557: 	{for( int i = 0; i < numof(g_pair); ++i )
 558: 	{
 559: 		info->insall[ g_pair[i].nID ].menu     = RegAllocClassRelationShellVerbMenu( EXT_EXE, g_pair[i].verb );
 560: 		info->insall[ g_pair[i].nID ].cmdline  = RegAllocClassRelationShellVerbCommandLine( EXT_EXE, g_pair[i].verb );
 561: 		info->insall[ g_pair[i].nID ].regpath  = strdup( g_pair[i].regpath );
 562: 
 563: 		if ( info->insall[ g_pair[i].nID ].menu )
 564: 		{
 565: 			info->insall[ g_pair[i].nID ].bInstall = true;
 566: 		}
 567: 		else
 568: 		{
 569: 			info->insall[ g_pair[i].nID ].bInstall = false;
 570: 			info->insall[ g_pair[i].nID ].menu     = strdup( g_pair[i].defmenu );
 571: 
 572: 			// コマンドラインの作成
 573: 			char cmdline[ MAX_CMDLINE+1 ];
 574: 			VERIFY( MakeCommandLine( cmdline, numof(cmdline), g_pair[i].param ) );
 575: 			info->insall[ g_pair[i].nID ].cmdline = strdup( cmdline );
 576: 		}
 577: 
 578: 		ASSERT( IsValidStringPtr( info->insall[ g_pair[i].nID ].menu ) );
 579: 		ASSERT( IsValidStringPtr( info->insall[ g_pair[i].nID ].cmdline ) );
 580: 		ASSERT( IsValidStringPtr( info->insall[ g_pair[i].nID ].regpath ) );
 581: 	}}
 582: 
 583: 	return true;
 584: }//LoadInfo
 585: 
 586: //*********************************************************
 587: // UnloadInfo
 588: //*********************************************************
 589: static
 590: bool
 591: UnloadInfo
 592: 	(
 593: 		INFO_t *info
 594: 	)
 595: {
 596: 	// パラメタの仮定
 597: 	ASSERT( IsValidPtr( info, sizeof( *info ) ) );
 598: 
 599: 	{for( int i = 0; i < numof(g_pair); ++i )
 600: 	{
 601: 		ASSERT( IsValidStringPtr( info->insall[ g_pair[i].nID ].menu ) );
 602: 		ASSERT( IsValidStringPtr( info->insall[ g_pair[i].nID ].cmdline ) );
 603: 		ASSERT( IsValidStringPtr( info->insall[ g_pair[i].nID ].regpath ) );
 604: 
 605: 		free( info->insall[ g_pair[i].nID ].menu );
 606: 		free( info->insall[ g_pair[i].nID ].regpath );
 607: 		free( info->insall[ g_pair[i].nID ].cmdline );
 608: 	}}
 609: 
 610: 	return true;
 611: }//UnloadInfo
 612: 
 613: //*********************************************************
 614: // SaveInfo
 615: //*********************************************************
 616: static
 617: bool
 618: SaveInfo
 619: 	(
 620: 		const INFO_t *info
 621: 	)
 622: {
 623: 	// パラメタの仮定
 624: 	ASSERT( IsValidReadPtr( info, sizeof( *info ) ) );
 625: 
 626: 	{for( int i = 0; i < numof(g_pair); ++i )
 627: 	{
 628: 		ASSERT( IsValidStringPtr( info->insall[ g_pair[i].nID ].menu ) );
 629: 		ASSERT( IsValidStringPtr( info->insall[ g_pair[i].nID ].cmdline ) );
 630: 		ASSERT( IsValidStringPtr( info->insall[ g_pair[i].nID ].regpath ) );
 631: 
 632: 		if ( ! info->insall[ g_pair[i].nID ].bInstall )
 633: 		{
 634: 			VERIFY( RegResetClassRelation( EXT_EXE, g_pair[i].verb ) );
 635: 		}
 636: 		else
 637: 		{
 638: 			VERIFY( RegSetClassRelation( EXT_EXE, g_pair[i].verb, info->insall[ g_pair[i].nID ].menu, info->insall[ g_pair[i].nID ].cmdline ) );
 639: 		}
 640: 	}}
 641: 
 642: 	return true;
 643: }//SaveInfo
 644: 
 645: //*********************************************************
 646: // MakeCommandLine
 647: //*********************************************************
 648: static
 649: bool
 650: MakeCommandLine
 651: 	(
 652: 		      char *buffer,
 653: 		      int   bufsize, 
 654: 		const char *param
 655: 	)
 656: {
 657: 	// パラメタの仮定
 658: 	ASSERT( MAX_CMDLINE < bufsize );
 659: 	ASSERT( IsValidPtr( buffer, bufsize ) );
 660: 	ASSERT( IsValidStringPtr( param ) );
 661: 
 662: 	char path[ MAX_PATH_BUF ];
 663: 	HINSTANCE hInstance = GetModuleHandle( null );
 664: 	VERIFY( GetModuleFileName( hInstance, path, numof(path) ) );
 665: 
 666: 	snprintf( buffer, bufsize, "\"%s\" %s \"%s\"", path, param, "%1" );
 667: 	buffer[bufsize-1] = '\0';
 668: 
 669: 	ASSERT( IsValidStringPtr( buffer ) );
 670: 	return true;
 671: }//MakeCommandLine
 672: 
 673: 
 674: //** end **
 675: 

参照:


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

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

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

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