Ver Mensaje Individual
  #3  
Antiguo 22-08-2010
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Reputación: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Si lo deseas sólo con la API (SHBrowseForFolder) y válido para compiladores diferentes al Builder, podemos hacer una implementación sencilla de dicha función:

Código:
BOOL SelectDirectory(HWND hWnd, const PCHAR Caption, PCHAR Directory)
{
  BROWSEINFO    BrowseInfo;
  LPITEMIDLIST  ItemIDList;
  LPMALLOC      ShellMalloc;

  ZeroMemory(&BrowseInfo, sizeof(BrowseInfo));
  if(SHGetMalloc(&ShellMalloc) == S_OK && ShellMalloc){
    BrowseInfo.hwndOwner = hWnd;
    BrowseInfo.pidlRoot = 0;
    BrowseInfo.pszDisplayName = Directory;
    BrowseInfo.lpszTitle = Caption;
    BrowseInfo.ulFlags = BIF_RETURNONLYFSDIRS;
    ItemIDList = SHBrowseForFolder(&BrowseInfo);
    if(ItemIDList){
      SHGetPathFromIDList(ItemIDList, Directory);
      ShellMalloc->Free(ItemIDList);
    }
  }
  return ItemIDList!=0;
}
Como ejemplo:
Código:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  // Asegúrate que la variable Carpeta tiene un tamaño igual o mayor que MAX_PATH
  char Carpeta[MAX_PATH]; 
  SelectDirectory(Handle, "Seleccione carpeta", Carpeta);
}
Responder Con Cita