[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

delphi & shell32.dll

Posted on 1998-03-14
2
Medium Priority
?
1,144 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 800 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 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