2 #define WIN32_LEAN_AND_MEAN
16 bool CreateLink(char * lpszPathObj, char * lpszPathLink, char * lpszDesc)
22 hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLink, (void *)&psl);
26 uint16 pathObj[2048] = { 0 };
27 uint16 desc[2048] = { 0 };
29 UTF8toUTF16Buffer(lpszPathObj, pathObj, sizeof(pathObj) / sizeof(uint16));
30 UTF8toUTF16Buffer(lpszDesc, desc, sizeof(desc) / sizeof(uint16));
31 IShellLinkW_SetPath(psl, pathObj);
32 IShellLinkW_SetDescription(psl, desc);
34 //hres = IShellLinkA_QueryInterface(psl, &IID_IPersistFile, (void *)&ppf);
35 hres = IShellLinkW_QueryInterface(psl, &IID_IPersistFile, (void *)&ppf);
40 MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1, wsz, MAX_PATH);
41 hres = IPersistFile_Save(ppf, wsz, TRUE);
42 IPersistFile_Release(ppf);
44 IShellLinkW_Release(psl);