Solved

delphi & shell32.dll

Posted on 1998-03-14
2
1,086 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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