#include #include /* Drag & Drop でファイル名を受け取るプログラムの雛形 gcc -O2 -W -Wall -mno-cygwin -mwindows -o DragAndDropExArg DragAndDropExArg.c gcc -O2 -W -Wall -mno-cygwin -mwindows -mconsole -o DragAndDropExArg DragAndDropExArg.c */ TCHAR fnameWithPath[MAX_PATH] ; void messageFromDragAndDrop( char *fnameWithPath ) {// fprintf の使用には、gcc のコンパイルオプションに -mconsole を指定することが必須 fprintf( stdout, "D&D:%s\n", fnameWithPath ) ; } void messageFromClipboard( char *message ) {// fprintf の使用には、gcc のコンパイルオプションに -mconsole を指定することが必須 fprintf( stdout, "Clipboard:%s\n", message ) ; } void messageFromCommandLine( char *message ) {// fprintf の使用には、gcc のコンパイルオプションに -mconsole を指定することが必須 fprintf( stdout, "CommandLine:%s\n", message ) ; } //////////////////////////////////////////////////////////////////////////////// // ウィンドウプログラム部 // HWND は、対象ウィンドウを特定するハンドル (Window ID) LRESULT CALLBACK WindowProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch( message ) { case WM_CREATE: // CreateWindowEx(...) で WS_EX_ACCEPTFILES, を指定済み // DragAcceptFiles(hWnd, TRUE); // この Drag & Drop操作を有効にする処理は不要 break; case WM_DROPFILES: // ドラッグアンドドロップで呼び出される SetForegroundWindow(hWnd); // 他のスレッドよりも若干高い優先順位を割り当て {register int i, max; for( i=0, max=DragQueryFile( (HDROP)wParam, -1, NULL, 0 ); i