Club Builder - Foros de discusión Club Builder
Foro de C++Builder en español
 
 FAQFAQ   BuscarBuscar   MiembrosMiembros   Grupos de UsuariosGrupos de Usuarios   RegistrarseRegistrarse 
 PerfilPerfil   Entra para ver tus mensajes privadosEntra para ver tus mensajes privados   EntrarEntrar 

Accesos directos

 
Publicar nuevo tema   Responder al tema    Foros de discusión -> Consultas
Ver tema anterior :: Ver tema siguiente  
Autor Mensaje
Mensaje    Asunto: Accesos directos Responder citando

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
Mensaje    Asunto: Responder citando

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
Ver perfil de usuario Enviar mensaje privado Enviar email
Mostrar mensajes de anteriores:   
Cambiar a:  
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


Hosting WordPress Indedmedia desde 3,99 €
© 2002–2026 Club Builder · Funciona con phpBB.