Pas de dépendances
#include <shlwapi.h> #include <stdio.h> #include <tchar.h> #pragma comment(lib,"shlwapi.lib") int main(void) { TCHAR szPath[MAX_PATH]; DWORD dwSize = sizeof szPath; if (AssocQueryString(0, ASSOCSTR_EXECUTABLE, _T("http"), _T("open"), szPath, &dwSize)==S_OK) _tprintf(_T("%s\n"),szPath); if (AssocQueryString(0, ASSOCSTR_EXECUTABLE, _T(".html"), _T("open"), szPath, &dwSize)==S_OK) _tprintf(_T("%s\n"),szPath); if (AssocQueryString(0, ASSOCSTR_EXECUTABLE, _T(".mp3"), _T("open"), szPath, &dwSize)==S_OK) _tprintf(_T("%s\n"),szPath); return 0; }
Un programme qui permet de savoir avec quel programme sont ouverts les différents types de fichiers. Ici, je regarde avec quoi j'ouvre le .html, et les .mp3 Et également avec quoi j'ouvre le protocole http J'affiche le chemin de l'EXE associé. Je vous renvoie a la doc de la fonction AssocQueryString http://msdn.microsoft.com/en-us/library/windows/desktop/bb773471(v=vs.85).aspx