Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Searching for Files from an Intranet system

Status
Not open for further replies.

petertickler

Programmer
Oct 1, 2002
67
GB
I want to develop a Find File facility from my Intranet system.
I have tried a procedure which uses 'FindFirst .... FindNext ...'. This procedure works absolutely perfectly from a desktop application, but not when incorporated in an IntraNet.
Indeed, it seems that then you use 'FindFirst' from a web application (ISAPI), it searches your local C:\WINNT\System32 folder and subfolders.
Can anyone tell me what to do!?
Peter Tickler
 
Code:
unit Unit1;
{
 Notes:
   (1) Window98 and Delphi5.

   (2) The inacessible drive event was not treated.
   (3) Show me please your enhancements, thanks.
}

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

uses ShlObj;

var
  CloseApp : boolean = false;

function GetFileFolder(ShellFolder : IShellFolder) : UINT;
{
 This function would be modified to run in a different thread
}
var
  EnumIdList : IEnumIdList;
  ItemId : PItemIdList; {only one list item will be get each time}
  stuff : ULONG;
  location : TStrRet;
  NewShellFolder : IShellFolder;
begin
  result := S_OK;
  if CloseApp then
    exit;
  stuff := 0;
  if ShellFolder.EnumObjects(application.handle, SHCONTF_FOLDERS, EnumIdList) <> NOERROR then
                          {try to get the folder objects}
                          {i supose all ShellFolder       children are in EnumIdList}
    exit;{if failed at obtain the folder objects, get out}
  while (EnumIdList.Next(1, ItemId, stuff) = NOERROR) and (not CloseApp) do {pick up a list item}
  begin
    if ShellFolder.GetDisplayNameOf(ItemId, SHGDN_FORPARSING, location) = NOERROR then
      case location.uType of  {print location}
        STRRET_CSTR :
          if MessageDlg('Path: ' + string(location.cStr), mtInformation, [mbOk, mbAbort], 0) = mrAbort then {Instead this, location.cStr could be put in a array of the main thread.}
                   {With the path, you could use FindFirst/FindNext in the main thread, i hope.}
          begin
            CloseApp := true;
            Break;
          end;
          (*
        STRRET_OFFSET :
          ShowMessage('Path: ' + string(PChar(UINT(@ItemId) + location.uOffset)));
           //i didnt find any uOffset case in my environment.
        STRRET_WSTR :
          ShowMessage('Path: ' + string(location.pOleStr));
          *)
      end;
    if ItemId <> nil then {if the folder has a child... (i hope ItemId is nil when there is not a child)}
    begin
      ShellFolder.BindToObject(ItemId, nil, IID_IShellFolder, NewShellFolder);
      if NewShellFolder <> nil then
        GetFileFolder(NewShellFolder); {recurse}
    end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  ShellDesktopFolder : IShellFolder;
  ShellFolder : IShellFolder;
  ItemId : PItemIdList;
begin
  CloseApp := false;
  if SHGetDesktopFolder(ShellDesktopFolder) <> NOERROR then {try to go to the root shell name space}
  begin
    ShowMessage('Failed at getting the desktop folder');
    exit;
  end;
  if SHGetSpecialFolderLocation(application.handle, CSIDL_NETWORK, ItemId) <> NOERROR then
                                {try to go to the network neighborhood folder}
  begin
    ShowMessage('Failed at getting the network neighborhood folder');
    exit;
  end;
  ShellDesktopFolder.BindToObject(ItemId, nil, IID_IShellFolder, ShellFolder);
                        {Make ShellFolder points to the neighborhood folder} 
  if GetFileFolder(ShellFolder) = S_OK then {Start search  from the neighborhood folder}
  begin
    ShowMessage('Search finished');{the if must be 
                                             completed}
  end;
end;

end.

hi,
I apologize for the bad edition. To faciltate most comments are inside brackets.
Ramalho.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top