Author Topic: Windows only: Invoking Active Directory Search Dialog  (Read 4327 times)

kpeters58

  • Sr. Member
  • ****
  • Posts: 267
Windows only: Invoking Active Directory Search Dialog
« on: January 10, 2014, 07:55:07 pm »
Took me quite some time to figure this one out - am posting it here in hopes that it might save someone else some time....

Code: [Select]
uses
  ShellAPI, ShFolder;

function GetSpecialFolderPath(const FolderID: Integer): String;
const
  SHGFP_TYPE_CURRENT = 0;
var
  path: Array [0..MAX_PATH] of Char;

begin
  if (SHGetFolderPath(0, FolderID, 0, SHGFP_TYPE_CURRENT, @path[0]) = 0) then
    Result := path
  else
    Result := '';
end;

procedure TForm1.Button1Click(Sender: TObject);
const
  PARAMS = 'dsquery.dll,OpenQueryWindow';  // many possibilities: add this GUID {B577F070-7EE2-11D0-913F-00AA00C16E65} to Find Printers
var
  runstr: String;

begin
  // still using deprecated CSIDLs instead of KNOWNFOLDERIDs since we need to support Windows XP
  runstr := IncludeTrailingBackslash(GetSpecialFolderPath(CSIDL_SYSTEM)) + 'rundll32.exe';
  ShellExecute(0, 'open', PChar(runstr), PARAMS, nil, 1);//SW_SHOWNORMAL = 1);
end;
« Last Edit: January 11, 2014, 03:04:37 am by kpeters58 »
Lazarus 2.0.4/FPC 3.0.4/Win 64

 

TinyPortal © 2005-2018