 |
Club Builder Foro de C++Builder en español
|
| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
Cerúleo Invitado
|
Publicado: Jue 02 Ene, 2003 10:44 am Asunto: Accesos directos |
|
|
Hola a todos.
Me gustaría saber cómo poder cargar un TComboBox con los nombres de los accesos directos situados en el escritorio, y lo más importante, almacenar en un objeto el path completo del programa asociado al acceso directo.
Por otra parte, también me gustaría saber si es posible y cómo crear accesos directos sobre el escritorio desde un programa.
Gracias y feliz año 2003. |
|
| Volver arriba |
|
 |
Tino Cdt


Registrado: 29 Oct 2002Mensajes: 4Ubicación: PERU
|
Publicado: Dom 26 Ene, 2003 1:25 pm Asunto: |
|
|
Hola Cerúleo , bueno te mando algo sobre como crear acceso(s) directo(s), espero que te sea de utilidad.
Pasos :
1)Click "Project | Options | Directories/Conditionals" y adicionar "NO_WIN32_LEAN_AND_MEAN" en la conditional defines section, si encuentras otras las separas con “;
Nota -.-Si no pones esto te saldrá un error de “multiple declaration errors for FVSHOWINFO, FOLDERSETTINGS, DESKBANDINFO, SHELLFLAGSTATE”
2)Incluir en tu archivo de cabecera (.h)
#include "shlobj.h"
3)En tu cpp agrega la siguiente funcion
void TForm1::CreateShortCut(const AnsiString &file)
{
// IShellLink allows us to create the shortcut. IPersistFile allows us
// to save the link to the hard drive.
IShellLink* pLink;
IPersistFile* pPersistFile;
LPMALLOC ShellMalloc;
LPITEMIDLIST DesktopPidl;
char DesktopDir[MAX_PATH];
if(FAILED(SHGetMalloc(&ShellMalloc)))
return;
if(FAILED(SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOPDIRECTORY, &DesktopPidl)))
return;
if(!SHGetPathFromIDList(DesktopPidl, DesktopDir))
{
ShellMalloc->Free(DesktopPidl);
ShellMalloc->Release();
return;
}
ShellMalloc->Free(DesktopPidl);
ShellMalloc->Release();
// First, we have to initialize the COM library
if(SUCCEEDED(CoInitialize(NULL)))
{
// If CoInitialize doesn't fail, then instantiate an IShellLink object
// by calling CoCreateInstance.
if(SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,IID_IShellLink, (void **) &pLink)))
{
// if that succeeds, then fill in the shortcut attributes
pLink->SetPath(file.c_str());
pLink->SetDescription("Woo hoo, look at Homer's shortcut");
pLink->SetShowCmd(SW_SHOW);
/* Now we need to save the shortcut to the hard drive. The IShellLink object also doubles as an IPersistFile object. Fetch the IPersistFile part of the object by calling QueryInterface. */
if (SUCCEEDED (pLink->QueryInterface(IID_IPersistFile, (void **) &pPersistFile)))
{
// If that succeeds, then call the Save method of the
// IPersistFile object to write the shortcut to the desktop.
WideString strShortCutLocation(DesktopDir);
strShortCutLocation += "\\bcbshortcut.lnk";
pPersistFile->Save(strShortCutLocation.c_bstr(), TRUE);
pPersistFile->Release();
}
pLink->Release();
}
// Calls to CoInitialize need a corresponding CoUninitialize call
CoUninitialize();
}
}
4) Listo, ya puedes llamarlo como por ejemplo
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(OpenDialog1->Execute())
CreateShortCut(OpenDialog1->FileName);
} _________________ Tino |
|
| Volver arriba |
|
 |
|
|
No puedes publicar temas nuevos en este foro No puedes responder a temas en este foro No puedes editar tus mensajes en este foro No puedes borrar tus mensajes en este foro No puedes votar en las encuestas de este foro
|
© 2002–2026 Club Builder · Funciona con phpBB.
|