C++ Builder
| Главная | Уроки | Статьи | FAQ | Форум | Downloads | Литература | Ссылки | RXLib | Диски |

Создание ярлыка программы на Рабочем столе
Отправлено: 28.05.2004, 14:17

Станционный диспетчер

Группа: Участник
Сообщений: 124

Необходимо создать программно Ярлык на Рабочем столе и Программную группу.
Если есть какие-то решения рад буду помощи!
Отправлено: 28.05.2004, 21:30

Машинист паровоза

Группа: Участник
Сообщений: 239

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

// Get a pointer to the IShellLink interface.
hres = CoCreateInstance(&CLSID_ShellLink, NULL,
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,

if (SUCCEEDED(hres)) {

// 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);
return hres;
Отправлено: 29.05.2004, 12:40

Машинист паровоза

Группа: Участник
Сообщений: 239

Ну тогда на попробу ето:
хранится в shellapi.h


SHGetNewLinkInfo Function

Creates the proper name for a new shortcut. This function does not actually create a shortcut.


BOOL SHGetNewLinkInfo(

LPCTSTR pszLinkTo,
LPTSTR pszName,
BOOL *pfMustCopy,
UINT uFlags

[in] Specifies the path and file name of the target of the shortcut. If uFlags does not contain the SHGNLI_PIDL value, this parameter is the address of a null-terminated string that contains the target. If uFlags contains the SHGNLI_PIDL value, this parameter is a pointer to an item identifier list (PIDL) that represents the target.
[in] Address of a null-terminated string that contains the path of the folder that the shortcut would be created in.
[out] Address of a string that receives the null-terminated path and file name for the shortcut. This buffer is assumed to be at least MAX_PATH characters in size.
[out] Address of a BOOL value that receives a flag that indicates if the shortcut would be copied. When a shortcut to another shortcut is created, the Shell simply copies the target shortcut and modifies that copied shortcut appropriately. This value receives a non-zero value if the target specified in pszLinkTo specifies a shortcut that will cause the target shortcut to be copied. This value receives zero if the target does not specify a shortcut that would be copied.
[in] Specifies the options for the function. This can be zero or a combination of the following values:
pszLinkTo is a PIDL that represents the target. If this flag is not included, pszLinkTo is the address of a string that contains the path and file name of the target.
The function will not create a unique name within the destination folder. If this flag is not included, the function creates the shortcut name and then determine if the name is unique in the destination folder. If a file with the same name exists within the destination folder, the shortcut name will be modified. This process is repeated until a unique name is found.
The created name will be preceded by the string "Shortcut to ".
Version 5.0 Do not add the .lnk file name extension. You must set _WIN32_IE to 5.01 or greater to use this flag. See Shell and Common Controls Versions for further discussion of versioning.

Return Value
Returns non-zero if successful or zero otherwise.

не забудь подлинковать lib \ PSDK \ shell32.lib

Отредактировано klen — 29/05/2004, 13:44

Вернуться в Вопросы программирования в C++Builder