#include typedef std::string Chaine; static bool CreeLien (const char* EXE_avec_path, const char* start_in, const char* arguments_ligne_commande, const char* LNK_avec_path, const char* description) { IShellLink* psl; HRESULT hres; // Get a pointer to the IShellLink interface. hres = CoCreateInstance (CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&psl); if (!SUCCEEDED (hres)) return false; psl-> SetArguments (arguments_ligne_commande); psl-> SetDescription (description); psl-> SetPath (EXE_avec_path); psl-> SetWorkingDirectory (start_in); IPersistFile* ppf; hres = psl-> QueryInterface (IID_IPersistFile, (void**) (&ppf)); if (SUCCEEDED (hres)) { wchar_t wsz[MAX_PATH]; // Ensure that the string is ANSI. MultiByteToWideChar (CP_ACP, 0, LNK_avec_path, -1, wsz, MAX_PATH); hres = ppf-> Save (wsz, true); ppf-> Release(); } psl-> Release(); return (SUCCEEDED (hres)); } Chaine ChercheEmplacementProfil (const char* nom_rep_special) { const char* nom_clef= "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"; HKEY clef; if (RegOpenKeyEx (HKEY_CURRENT_USER, nom_clef, 0, KEY_READ, &clef) != ERROR_SUCCESS) { // Erreur return ""; } unsigned char reponse [MAX_PATH+1]; DWORD taille= sizeof reponse; if (RegQueryValueEx (clef, nom_rep_special, 0, 0, reponse, &taille) != ERROR_SUCCESS) { // Erreur reponse[0]= '\0'; } RegCloseKey (clef); return Chaine ((char*) (reponse)); } Chaine EmplacementBureau() { return ChercheEmplacementProfil ("Desktop"); // C:\\WINNT\\Profiles\\Administrateur\\Bureau } Chaine EmplacementMenuDemarrerProgrammes() { return ChercheEmplacementProfil ("Programs"); // C:\\WINNT\\Profiles\\Administrateur\\Menu Démarrer\\Programmes }