Solved

delphi & shell32.dll

Posted on 1998-03-14
2
1,080 Views
Last Modified: 2012-06-27
how can I call the shell32.dll function 'shBrowseForFolder'
i've got problems with declaring and fill then
'BROWSEINFO' structur.
thanks to everyone who helped me!
0
Comment
Question by:rene100
2 Comments
 
LVL 2

Accepted Solution

by:
Waldek earned 200 total points
ID: 1360492
Check this :
unit FBrowse;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ShlObj;

type

  TFolderBrowse = class(TComponent)
  private
    FDirectory  : string;
    FTitle      : string;
    FBrowseInfo : TBrowseInfo;
  public
    function Execute( Form : TForm ) : Boolean;
  published
    property Directory : string read FDirectory write FDirectory;
    property Title : string read FTitle write FTitle;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TFolderBrowse]);
end;

function BrowseCallback(Wnd: HWND; uMsg: UINT; lParam, lpData: LPARAM): Integer stdcall;
begin
  Result := 0;
  if uMsg = BFFM_Initialized then
    with TFolderBrowse( lpData ) do
      if Length( Directory ) > 0 then
        SendMessage( Wnd , BFFM_SetSelection , 1 , Longint( PChar( Directory ) ) );
end;

function TFolderBrowse.Execute( Form : TForm ) : Boolean;
var
  Buffer : array [ 0..MAX_PATH ] of char;
  ItemIdList : PItemIDList;
begin
  Result := False;

  with FBrowseInfo do
    begin
      hwndOwner := Form.Handle;
      pidlRoot  := nil;
      pszDisplayName := Buffer;
      lpszTitle := PChar( FTitle );
      ulFlags := BIF_RETURNONLYFSDIRS;
      lpfn := BrowseCallback;
      lParam := Longint( Self );
    end;

  ItemIdList := ShBrowseForFolder( FBrowseInfo );

  if ItemIDList = nil then
    Exit;

  Result := SHGetPathFromIDList( ItemIDList , Buffer );
  FDirectory := Buffer;
end;

end.

This is a module created by
by Pablo Pissanetzky
pablo@neosoft.com
http://www.neosoft.com/~pablo

0
 
LVL 2

Author Comment

by:rene100
ID: 1360493
thanks, it works fine!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi Form ownership 4 70
How to debug For loops? 3 45
Error E2158 compiling with Delphi XE10 Seattle 2 86
Firemonkey DbLookupComboBox equivalent ? 2 34
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now