Solved

delphi & shell32.dll

Posted on 1998-03-14
2
1,107 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

707 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