function SelectFolder(Caption, DefPath: string): string; var bi: TBrowseInfo; lpBuffer: PChar; pidlPrograms, pidlBrowse: PItemIDList; function BrowseCallbackProc(hwnd: HWND; uMsg: UINT; lParam: Cardinal; lpData: Cardinal): Integer; stdcall; var PathName: array[0..MAX_PATH] of Char; begin case uMsg of BFFM_INITIALIZED: SendMessage(Hwnd, BFFM_SETSELECTION, Ord(True), Integer(lpData)); BFFM_SELCHANGED: begin SHGetPathFromIDList(PItemIDList(lParam), @PathName); SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, Longint(PChar(@PathName))); end; end; Result := 0; end; begin if (not SUCCEEDED(SHGetSpecialFolderLocation(GetActiveWindow, CSIDL_DRIVES, pidlPrograms))) then exit; GetMem(lpBuffer, MAX_PATH ); FillChar(BI, SizeOf(BrowseInfo), 0); bi.hwndOwner := GetActiveWindow; bi.pidlRoot := pidlPrograms; bi.pszDisplayName := lpBuffer; bi.lpszTitle := PChar(Caption); bi.ulFlags := BIF_RETURNONLYFSDIRS or BIF_STATUSTEXT; bi.lpfn := @BrowseCallbackProc; bi.lParam := Integer(PChar(DefPath)); pidlBrowse := SHBrowseForFolder(bi); ... end;
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE