Ver Mensaje Individual
  #5  
Antiguo 09-11-2008
_cero_ _cero_ is offline
Miembro
 
Registrado: abr 2007
Posts: 147
Reputación: 20
_cero_ Va por buen camino
Wink

Pff, ya esta, les dejo esta función que te devuelve el destino de un lnk (con algunas modificaciones te puede crear los accesos directos).

Código:
AnsiString __fastcall TForm1::ResolveLink(AnsiString&   LinkFile)
{
/**/
  IShellLink* pShellLink=NULL;

  AnsiString URL("");
  HRESULT HR = CoCreateInstance(CLSID_ShellLink,   NULL,   CLSCTX_INPROC_SERVER,
								IID_IShellLink, (void**)&pShellLink);
  if (SUCCEEDED(HR)) {
  IPersistFile* pPersistFile=NULL;
  HR=pShellLink->QueryInterface(IID_IPersistFile, (void**)&pPersistFile);
	if (SUCCEEDED(HR)) {
	  wchar_t WSZ[MAX_PATH];
	  MultiByteToWideChar(CP_ACP, 0, LinkFile.c_str(), -1, WSZ, MAX_PATH);
	  HR=pPersistFile->Load(WSZ, STGM_READ);
	  if (SUCCEEDED(HR)) {
		WIN32_FIND_DATA WFDD;
		HR=pShellLink->Resolve(Application->Handle, SLR_NO_UI);
		if (NOERROR==HR) {
		  char STR[MAX_PATH];
		  pShellLink->GetPath(STR, MAX_PATH,&WFDD, SLGP_UNCPRIORITY);
		  URL=STR;
		}
	  }
	  pPersistFile->Release();
	}
	pShellLink->Release();
  }
  return URL;
}
Espero que esto le sea útil a alguien más y gracias por el interés.
Responder Con Cita