WWW.ИСХОДНИКИ.РУ cpp.sources.ru
java.sources.ru web.sources.ru soft.sources.ru
jdbc.sources.ru asp.sources.ru api.sources.ru

  Форум на исходниках
  C / C++ / Visual C++
  Вопрос про программное создание ярлыков

СПРОСИТЬ  ОТВЕТИТЬ
профайл | регистрация | faq

Автор Тема:   Вопрос про программное создание ярлыков
Kasya опубликован 13-01-2002 04:23 MSK   Click Here to See the Profile for Kasya   Click Here to Email Kasya  
Люди - вот тут когда-то мне рассказали как создавать программно ярлык. А можно ли как то задавать программно все его свойства. Ну например иконку и так далее. Если реально, то также интересует как для досовских ярлыков задавать все свойства, например закрыть окно после завершения программы. Или если это есть в МСДН, то где это можно там почитать. Заранее блягодарен.
michl_m опубликован 13-01-2002 14:00 MSK     Click Here to See the Profile for michl_m  Click Here to Email michl_m     
В MSDN описан способ использования Shell Links. Поищи по ключам Shell Links, IShellLink.
Вот кусочек из MSDN ( я не проверял ).
// CreateLink - uses the shell's IShellLink and IPersistFile interfaces
// to create and store a shortcut to the specified object.
// Returns the result of calling the member functions of the interfaces.
// lpszPathObj - address of a buffer containing the path of the object.
// lpszPathLink - address of a buffer containing the path where the
// shell link is to be stored.
// lpszDesc - address of a buffer containing the description of the
// shell link.

HRESULT CreateLink(LPCSTR lpszPathObj,
LPSTR lpszPathLink, LPSTR lpszDesc)
{
HRESULT hres;
IShellLink* psl;

// Get a pointer to the IShellLink interface.
hres = CoCreateInstance(&CLSID_ShellLink, NULL,
CLSCTX_INPROC_SERVER, &IID_IShellLink, &psl);
if (SUCCEEDED(hres)) {
IPersistFile* ppf;

// Set the path to the shortcut target and add the
// description.
psl->lpVtbl->SetPath(psl, lpszPathObj);
psl->lpVtbl->SetDescription(psl, lpszDesc);

// Query IShellLink for the IPersistFile interface for saving the
// shortcut in persistent storage.
hres = psl->lpVtbl->QueryInterface(psl, &IID_IPersistFile,
&ppf);

if (SUCCEEDED(hres)) {
WORD wsz[MAX_PATH];

// Ensure that the string is ANSI.
MultiByteToWideChar(CP_ACP, 0, lpszPathLink, -1,
wsz, MAX_PATH);

// Save the link by calling IPersistFile::Save.
hres = ppf->lpVtbl->Save(ppf, wsz, TRUE);
ppf->lpVtbl->Release(ppf);
}
psl->lpVtbl->Release(psl);
}
return hres;
}

ADK опубликован 14-01-2002 13:30 MSK     Click Here to See the Profile for ADK  Click Here to Email ADK     
Юзал этот кусок , нормально всё.

СПРОСИТЬ  ОТВЕТИТЬ
Перейти:


E-mail | WWW.ИСХОДНИКИ.RU

Powered by: Ultimate Bulletin Board, Freeware Version 5.10a
Purchase our Licensed Version- which adds many more features!
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 2000.