/*
  test.c
  $ gcc -o test -luser32 -lgdi32 test.c
  $ ./test
*/
#include <windows.h>
#include <shlobj.h>
int main(void)
{
  BROWSEINFO bi;
  ITEMIDLIST *id;
  memset(&bi, 0, sizeof(BROWSEINFO));
  bi.hwndOwner = NULL;
  bi.ulFlags = BIF_EDITBOX | BIF_STATUSTEXT | BIF_VALIDATE;
  bi.lpszTitle = "aho";
  id = SHBrowseForFolder(&bi);
  if(id){
    HRESULT hr;
    LPMALLOC p = NULL;
    hr = SHGetMalloc(&p);
    if(hr == E_FAIL){
      MessageBox(NULL, "SHGetMalloc Error", "Error", MB_OK);
    }else{
      char dir[MAX_PATH];
      SHGetPathFromIDList(id, dir);
      printf(dir);
    }
  }
  return 0;
}