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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) /* handle the messages */
{
case WM_CREATE:
DragAcceptFiles(hwnd,TRUE);
break;
case WM_DROPFILES:
HDROP hDropFiles;
int nFile,i;
hDropFiles = (HDROP)wParam;
nFile = DragQueryFile(hDropFiles,0xFFFFFFFF,NULL,0); // nombre de fichiers si 0xFFF...
for(i=0;i<nFile;i++)
{
char *nameFile;
int nChar;
WIN32_FIND_DATA dataFile;
HANDLE hFile;
nChar = 1 + DragQueryFile(hDropFiles,i,NULL,0); // aile du buffer --> NULL
nameFile = (char*) malloc(nChar * sizeof(char));
DragQueryFile(hDropFiles,i,nameFile,nChar);
ShellExecute
(
NULL, // handle to parent window
"open", // pointer to string that specifies operation to perform
"ClassURL.exe", // pointer to filename or folder name string
nameFile, // pointer to string that specifies executable-file parameters
NULL, // pointer to string that specifies default directory
SW_MINIMIZE // whether file is shown when opened
);
FindClose(hFile);
free(nameFile);
}
DragFinish(hDropFiles);
break;
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
return 0;
} |
Partager