2 #define WIN32_LEAN_AND_MEAN
20 bool CreateLink(char * lpszPathObj, char * lpszPathLink, char * lpszDesc)
26 hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (void *)&psl);
30 uint16 pathObj[2048] = { 0 };
31 uint16 desc[2048] = { 0 };
33 UTF8toUTF16Buffer(lpszPathObj, pathObj, sizeof(pathObj) / sizeof(uint16));
34 UTF8toUTF16Buffer(lpszDesc, desc, sizeof(desc) / sizeof(uint16));
35 IShellLinkW_SetPath(psl, pathObj);
36 IShellLinkW_SetDescription(psl, desc);
38 //hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile, (void *)&ppf);
39 hres = IShellLinkW_QueryInterface(psl, &IID_IPersistFile, (void *)&ppf);
44 MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1, wsz, MAX_PATH);
45 hres = IPersistFile_Save(ppf, wsz, TRUE);
46 IPersistFile_Release(ppf);
48 IShellLinkW_Release(psl);