/* ZazouUniversalOpen * * Par Xavier Garreau * * Permission est accordée de réutiliser, modifier, distribuer ce programme * sous forme compilée ou de fichiers sources. En indiquer la provenance n'est * pas obligatoire, c'est juste honnête ;-). * * Si ce bout de code vous est utile, envoyez moi un mail. Ca fait toujours plaisir. * */ #include "stdafx.h" int main(int argc, char* argv[]) { int RetVal; int myShowCmd = SW_SHOWNORMAL; if (argc < 2) { char msg[256]; sprintf (msg, "USAGE : %s \"fichier à ouvrir\" [hide]\nOu faites glisser une application ou un fichier sur l'icône.\n", argv[0]); ::MessageBox (NULL, msg, "Info :", MB_ICONINFORMATION); return ERROR_FILE_NOT_FOUND; } if (argc == 3 && !strcmp(argv[2], "hide")) myShowCmd = SW_HIDE; DWORD neededSize, estimatedSize = 4096; LPSTR PWD = (LPSTR)malloc(4096); neededSize = GetCurrentDirectory(4096, PWD); if (neededSize > estimatedSize) { PWD = (LPSTR)realloc(PWD, neededSize); GetCurrentDirectory(4096, PWD); } RetVal = (int)ShellExecute(NULL, NULL, argv[1], NULL, PWD, myShowCmd); free (PWD); return RetVal; }