f



Open dialog to display directory only (D4)

Hopefully there are still people reading this newsgroup...

I am working on a new Delphi project called DupZapper which intends to open 
a directory which contains many duplicate files (in this case, email), and 
then find the duplicates and move them to a separate ZAP directory. I can 
hard code the email directory and then use the Open Dialog to select all the 
files in the folder I want to ZAP, and perhaps that is easiest and best. But 
I would like to know how to navigate to the directory in case I want to use 
this application on a different computer or for a different user. My email 
directory is:

C:\Users\paul_000\AppData\Local\Microsoft\Windows Live Mail\Peschoen (paul)

It would be easy enough to store this file location in a text file for the 
application so it can be edited, or perhaps it is available in the registry. 
I don't do much with Delphi lately and I'm rather rusty, and want to 
maintain at least a modicum of familiarity and competence.

Thanks,

Paul 

0
P
7/20/2015 9:15:49 PM
comp.lang.pascal.delphi.misc 5769 articles. 1 followers. miniFAQ (1) is leader. Post Follow

4 Replies
269 Views

Similar Articles

[PageSpeed] 6

P E Schoen wrote:

> Hopefully there are still people reading this newsgroup...
> 
> I am working on a new Delphi project called DupZapper which intends
> to open a directory which contains many duplicate files (in this
> case, email), and then find the duplicates and move them to a
> separate ZAP directory. I can hard code the email directory and then
> use the Open Dialog to select all the files in the folder I want to
> ZAP, and perhaps that is easiest and best. But I would like to know
> how to navigate to the directory in case I want to use this
> application on a different computer or for a different user. My email
> directory is:
> 
> C:\Users\paul_000\AppData\Local\Microsoft\Windows Live Mail\Peschoen
> (paul)
> 
> It would be easy enough to store this file location in a text file
> for the application so it can be edited, or perhaps it is available
> in the registry. I don't do much with Delphi lately and I'm rather
> rusty, and want to maintain at least a modicum of familiarity and
> competence.

If you use a TOpenDialog component you can set its InitialDir property
the directory you want the dialog to open in. The Options property
allows you to configure the behaviour of the dialog, e.g. whether it
should allow the user to select more than one file. You call the
dialog's Execute method to show it, and once it is up the user can
navigate around the file system at will. If the directory you specified
at design-time does not exist on the target machine the dialog will
open at a defaul location. Of course you can also set InitialDir at
runtime, e.g. to the folder the user last visited and which you
remembered in a settings file.

-- 
Peter Below (TeamB)
0
Peter
7/21/2015 5:38:59 PM

Peter Below (TeamB) wrote:

> P E Schoen wrote:
> 
> > Hopefully there are still people reading this newsgroup...
> > 
> > I am working on a new Delphi project called DupZapper which intends
> > to open a directory which contains many duplicate files (in this
> > case, email), and then find the duplicates and move them to a
> > separate ZAP directory. I can hard code the email directory and then
> > use the Open Dialog to select all the files in the folder I want to
> > ZAP, and perhaps that is easiest and best. But I would like to know
> > how to navigate to the directory in case I want to use this
> > application on a different computer or for a different user. My
> > email directory is:
> > 
> > C:\Users\paul_000\AppData\Local\Microsoft\Windows Live Mail\Peschoen
> > (paul)
> > 
> > It would be easy enough to store this file location in a text file
> > for the application so it can be edited, or perhaps it is available
> > in the registry. I don't do much with Delphi lately and I'm rather
> > rusty, and want to maintain at least a modicum of familiarity and
> > competence.
> 
> If you use a TOpenDialog component you can set its InitialDir property
> the directory you want the dialog to open in. The Options property
> allows you to configure the behaviour of the dialog, e.g. whether it
> should allow the user to select more than one file. You call the
> dialog's Execute method to show it, and once it is up the user can
> navigate around the file system at will. If the directory you
> specified at design-time does not exist on the target machine the
> dialog will open at a defaul location. Of course you can also set
> InitialDir at runtime, e.g. to the folder the user last visited and
> which you remembered in a settings file.

Maybe the use of ShBrowseForFolder is the better way with older Delphi.

Here is a short description:
http://delphi.about.com/od/windowsshellapi/l/aa070400a.htm


0
Faxe
7/21/2015 6:12:55 PM
On 20/07/15 23:15, P E Schoen wrote:
> Hopefully there are still people reading this newsgroup...
> 
> I am working on a new Delphi project called DupZapper which intends to
> open a directory which contains many duplicate files (in this case,
> email), and then find the duplicates and move them to a separate ZAP
> directory. I can hard code the email directory and then use the Open
> Dialog to select all the files in the folder I want to ZAP, and perhaps
> that is easiest and best. But I would like to know how to navigate to
> the directory in case I want to use this application on a different
> computer or for a different user. My email directory is:
> 
> C:\Users\paul_000\AppData\Local\Microsoft\Windows Live Mail\Peschoen (paul)
> 
> It would be easy enough to store this file location in a text file for
> the application so it can be edited, or perhaps it is available in the
> registry. I don't do much with Delphi lately and I'm rather rusty, and
> want to maintain at least a modicum of familiarity and competence.
> 
> Thanks,
> 
> Paul

This should work in D5. (I do not know if this works with D4)

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    FIniFile: TRegIniFile;
  end;

var
  Form1: TForm1;

implementation
uses ShlObj, FileCtrl;
var lg_StartFolder: String;

{$R *.DFM}

const
  SECTION = 'Sample';

procedure TForm1.FormCreate(Sender: TObject);
begin
  FIniFile := TRegIniFile.Create('Sample Registry');
  Edit1.Text := FIniFile.ReadString(SECTION, 'HandleFolder', 'No folder
selected');
end;

function BrowseForFolderCallBack(Wnd: HWND; uMsg: UINT; lParam, lpData:
LPARAM): Integer stdcall;
begin
  if uMsg = BFFM_INITIALIZED then
    SendMessage(Wnd,BFFM_SETSELECTION, 1, Integer(@lg_StartFolder[1]));
    result := 0;
end;

function BrowseForFolder(const browseTitle: String; const initialFolder:
String =''): String;
var
  browse_info: TBrowseInfo;
  folder: array[0..MAX_PATH] of char;
  find_context: PItemIDList;
begin
  FillChar(browse_info,SizeOf(browse_info),#0);
  lg_StartFolder := initialFolder;
  browse_info.pszDisplayName := @folder[0];
  browse_info.lpszTitle := PChar(browseTitle);
  browse_info.ulFlags := BIF_RETURNONLYFSDIRS;
  browse_info.lpfn := BrowseForFolderCallBack;
  find_context := SHBrowseForFolder(browse_info);
  if Assigned(find_context) then
  begin
    if SHGetPathFromIDList(find_context,folder) then
      result := folder
    else
      result := '';
    end
  else
    result := '';
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := BrowseForFolder('Select folder');
  if (DirectoryExists(Edit1.Text)) then
  FIniFile.WriteString(SECTION, 'HandleFolder', Edit1.Text);
end;

procedure TForm1.FormDestroy(Sender: TObject);
var
  Cleanup: TRegistry;
  key: string;
begin
  key := FIniFile.FileName;
  FIniFile.Free;
  // make sure we don't leave junk in the registry behind.
  Cleanup := TRegistry.Create;
  try
    Cleanup.DeleteKey(key);
  finally
    Cleanup.Free;
  end;
end;

end.

// EOF
0
Richard
7/22/2015 5:19:19 PM
"Faxe"  wrote in message news:mom237$bkm$1@solani.org...

> Maybe the use of ShBrowseForFolder is the better way with older Delphi.

> Here is a short description:
> http://delphi.about.com/od/windowsshellapi/l/aa070400a.htm

Those were some good suggestions. I went ahead and coded the project using a 
hard-coded location for the folders and files I wanted to "ZAP", and I was 
able to move and delete the duplicate files in the Junk Email folder. But I 
found that mucking with the files in Windows Live Mail causes problems so I 
may need to do something different.

Probably I can just use WLM to move most of the files to another folder and 
copy them elsewhere and then delete the duplicates and put the remaining 
files in a compressed folder for backup. But, really, I just need to save 
important emails as I receive and send them, and stop thinking that I might 
someday get the time to read the others that usually have limited interest 
and are irrelevant after a couple of weeks. I get about 100/day so they pile 
up quickly!

I got some helpful information in the Tek-Tips forum:

OpenDialog1.InitialDir := GetCSIDLPath(CSIDL_LOCAL_APPDATA) + 
'\Microsoft\Windows Live Mail\';

http://www.tek-tips.com/viewthread.cfm?qid=1752538

Thanks for the help. At least I know that this newsgroup is still active and 
useful :)

Paul

0
P
7/26/2015 3:59:54 AM
Reply:

Similar Artilces:

Common open/save dialogs and initial directory...
Ok this is basically a rant, but maybe someone has a rationale... With Win2000, the rules for the initial directory used by the common dialogs (GetOpenFileName, GetSaveFileName) changed significantly. Whereas previously, if you didn't specify a directory (or a filename), it would use the current windows directory, it now remembers which directory the last common dialog in your application used. It doesn't take much thinking to realise this hopelessly breaks applications that use open/save dialogs for various purposes, not just for opening the primary document type. Whereas...

directory path without open dialog window
i have a vi which automatically opens files from a specified directory, but once a day this directory is flushed. Then labview opens a dialog box and wait till a user make an action. How can i turn off this option ??? Thanx for answers Often you correct this by selecting the Open or Create option with the open/create/replace.vi make sure your path is valid. If the path points to a directory that was flushed then the directory must be created first. If this doesn't work for you try listing the file i/o funtions in use and dialog message you are getting. Randall What do you mean by flush...

Open Windows "Active Directory Users and Computers" dialog
Hi all, I am writing a simple app to provide an simple GUI to write windows netlogon scripts. Is there a way in vb.net to provide a button on a form to open the "Active Directory Users and Computers" dialog? Cheers, Jay ...

how to get Firefox 'open' dialog to look inside .app directory?
The 'Path Finder' app is installed in the /Applications folder as '/Applications/Path Finder.app'. This subdirectory conatins further subdirectories, one of which finally has various html files that I want to browse with Firefox. But when I start the Open dialog, all the di- rectories with names ending in '.app' are grayed out and inaccessible. This seems idiotic. I can open the desired file by typing in its name into the location bar, but this is pretty backward. Yes, I can probably drop the html file onto Firefox, but what I really want to do is modify Firefox...

CommonDialog1.InitDir = "C:\Program Files\MyData" 'This has no effect on what directory the File Open dialog box starts in: WHY ?
Private Sub mnuOpen_Click() Dim sfbPos As Long, LFRow As Integer, LFCol As Integer, LFStrBuf As String, TempStr As String Dim RowCtr As Integer, Prompt1 As String, Responce As Byte Const sfbLen As Byte = 1 TempStr = "" sfbPos = 1 RowCtr = -1 Prompt1 = "Before opening a new file, do you want to Save Changes" & Chr$(13) & _ " to the data now displayed on this screen ?" 'MsgBox(prompt[, buttons] [, title] [, helpfile, context]) 'vbYes If CellDataChanged Then Responce = MsgBox(Prompt1, vbYesNo, "S...

pwd display linked directory not current directory
Hi, I have a problem of pwd on Solairs 10. Below is an example The directory /home/zhangl/wifs is a link of /wisefs/zhangl/wifs. gdc5e35 is a Solais 10 machine. When I execute pwd under /usr/bin/ksh, it display the linked directory not current directory. That is not my expectation. gdcsr60 is a Solaris 2.5.1 machine. It does not show this kind of problem. Can anybody help on this issue? Thanks a lot! gdc5e35:/home/zhangl:> ls -l /home/zhangl/wifs lrwxrwxrwx 1 zhangl zhangl 19 Feb 21 2006 /home/zhangl/wifs -> /wisefs/zhangl/wifs gdc5e35:/home/zhangl/wifs:> pwd /home/zh...

display print preview dialog, not print dialog
If I do the following, it will pop up print dialog. But i want to produce "File->Print Preview" Screen. Is it possible to do that? <input type="button" value='Print Preview' onClick='window.print();'> thanks!! Matt wrote: > If I do the following, it will pop up print dialog. But i want to produce > "File->Print Preview" Screen. Is it possible to do that? Not in a default security, non-ActiveX environment. -- Randy comp.lang.javascript FAQ - http://jibbering.com/faq Answer:It destroys the order of the conversation Questio...

Which function displays this save dialog or how is this save dialog called?
I want to run a file. Obviously ShellExecute can do that. But before the file is run I want Windows to show this kind of dialog: http://i55.tinypic.com/2ljss2b.png This example shows Outlook Express on Windows XP opening a file. But this is not a OE unique custom dialog but something from Windows because Internet Explorer shows very similar dialog when downloading files. So... which Win32 call/function displays this type of dialog or how is this kind of dialog called? I found something: ShellExecuteEx has in SHELLEXECUTEINFO a fMask flag called SEE_MASK_NOZONECHECKS...

Can VIM display and open the files which have been opened recently
In the HOME directory, there is a file named .vimrecent, which records the files opened recently. But does VIM provide the command to display these file names? I think it's a useful function. Zheng Da wrote: > In the HOME directory, there is a file named .vimrecent, which records > the files opened recently. Is it? I don't have this file.. (using vim 7.0 on Linux). > But does VIM provide the command to display these file names? I think > it's a useful function. There are a few plugins that do the job. I never have used any, but a script seach at www....

Which function displays this save dialog or how is this save dialog called?
I want to run a file. Obviously ShellExecute can do that. But before the file is run I want Windows to show this kind of dialog: http://i55.tinypic.com/2ljss2b.png This example shows Outlook Express on Windows XP opening a file. But this is not a OE unique custom dialog but something from Windows because Internet Explorer shows very similar dialog when downloading files. So... which Win32 call/function displays this type of dialog or how is this kind of dialog called? I found something: ShellExecuteEx has in SHELLEXECUTEINFO a fMask flag called SEE_MASK_NOZONECHECKS...

How to open file dialog in Ruby, and get open FileName? :-(
This is a pop MessaheBox example, but I don't know how to open fiel dialog? shell = Win32API.new('user32','MessageBox',['L', 'P', 'P', 'L'],'I') shell.Call(0,"hello world","ShadowZ",0) -- Posted via http://www.ruby-forum.com/. I find an example from http://www.java2s.com , but pop error: main.rb:21:in `initialize': failed to create WIN32OLE object from `MSComDlg.CommonDialog' (WIN32OLERuntimeError) HRESULT error code:0x80040112 cd = WIN32OLE.new("MSComDlg.CommonDialog"...

could not open display
Hi all, I am trying to get wmsetbg to change my background. However whether I try it in a script or try it on a command line I keep getting errors. bhorne@Slacker:bhorne, 12:32 AM, Sat Aug 28]>wmsetbg -display localhost /usr/X11R6/share/WidowMaker/Background/Images/Heather/plain.jpg wmsetbg fatal error: could not open display [bhorne@Slacker:bhorne, 12:31 AM, Sat Aug 28]>wmsetbg -display 127.0.0.1 /usr/X11R6/share/WidowMaker/Background/Images/Heather/plain.jpg wmsetbg fatal error: could not open display [bhorne@Slacker:bhorne, 12:32 AM, Sat Aug 28]>wmsetbg...

Opening a directory...
I'm using RO 3.70. I'm sure, well fairly sure, that in the past I've select-double-clicked (or even adjust-double-clicked) on directory icons with Ctrl held down and the directory viewer has then been opened without booting the apps inside - and the viewer shows bog-standard application icons for the apps there. But I've just noticed that if I do this now, so long as I hold the Ctrl key down the viewer keeps its bog-standard icons (and other wimp apps manage to keep on running eg the iconbar clock keeps updating), but as soon as I release Ctrl there's a frenzy of applicat...

Open/not open ?
HI, I got something weird the database said it is open and not open in the same time ... any lights ? Thanks in advance Oracle 9.2.0.6/AIX U13:oracle:/prd/app/system/exploit/shell#sqlplus /nolog SQL*Plus: Release 9.2.0.6.0 - Production on Fri Nov 30 09:45:09 2007 Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved. SQL> connect / as sysdba Connected. SQL> SQL> select status from v$instance; STATUS ------------ OPEN SQL> alter database close; Database altered. SQL> select status from v$instance; STATUS ------------ MOUNTED SQL> alter tablespace tem...

Web resources about - Open dialog to display directory only (D4) - comp.lang.pascal.delphi.misc

Wikipedia:Quick directory - Wikipedia, the free encyclopedia
This page is a handy directory to various locations of interest in Wikipedia. Only dynamic pages should be listed here, no policy pages etc. ...

Telephone directory - Wikipedia, the free encyclopedia
"Phone book" and "White pages" redirect here. For a contact list, see Contact list . For other uses, see White pages (disambiguation) . Subscriber ...

Business Directory Listings: Eight Smart Tips for You to Get Started
If you are considering a business directory listing for your small business, congratulations – you are on the right track. Local SEO, local customers, ...

LinkedIn Lookup iOS app aims to replace your company’s awful intranet employee directory
... continue reading at 9to5Mac . What do you think? Discuss "LinkedIn Lookup iOS app aims to replace your company’s awful intranet employee directory" ...

Atlas Partner Directory Launched
... just for Facebook and Instagram –advertising platform Atlas has one, as well. On that note, Atlas Tuesday introduced the Atlas Partner Directory ...

Slack announces App Directory store
... create more apps for the store, and a new framework called Botkit which should simplify the process of creating apps. The Slack App Directory, ...

The British Library’s ‘Save Our Sounds’ Program Creates Directory of UK Sound Collections
The long-feared deterioration of the world's sound collections is a coming to a head with the British Library's last-ditch initiative called ...

First look: Microsoft Azure Active Directory Domain Services puts it all in the cloud
On Oct. 14, Microsoft announced the preview release of Azure Active Directory Domain Services or, as I like to call it, a domain in a cloud. ...

Security Recruiter Directory
To find the right security job or hire the right candidate, you first need to find the right recruiter. CSO's security recruiter directory is ...

Slack's App Directory proves it's more than just a chatroom
... are about to get a little easier to find and integrate within your team and over 160 of them live within the company's new Slack App Directory. ...

Resources last updated: 1/25/2016 10:46:54 AM