Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


Open Dialog for directory name only (D4)

Open Dialog for directory name only (D4)

I am working on a new D4 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.

I also posted this on comp.lang.pascal.delphi.misc usenet newsgroup but it seems to have become inactive.



RE: Open Dialog for directory name only (D4)

If I interpret all this right, you want to find that particular directory on a user's system.


function GetCSIDLPath(PathID: Integer): string;
    pathstr: array[0..MAX_PATH] of char;
    SHGetFolderPath(0{Handle}, PathID,
                  0, SHGFP_TYPE_CURRENT, pathstr);
    Result := Pathstr;

For what you want, call it with (provided because you might not have it):


  CSIDL_LOCAL_APPDATA = $001C; // non roaming, user\Local Settings\Application Data 

So basically, your folder is:


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

The problem from there is determining the users that *should* be worked on, but you could list those in a listbox and then select the user and do the work if you are intending to act upon all files, completely bypassing the OpenDialog.

YMMV on some of this, of course, outside of the function, which I copied out of my reuse code library.

RE: Open Dialog for directory name only (D4)

That is very helpful. Thanks.

Since then I have progressed into actually making the application do what I wanted it to do, which is to remove duplicate emails from WLM folders (particularly the Inbox). Here is further explanation of what I've done and the problems I've encountered:

Sometimes my Windows Live Mail application in Win8 seems to forget that it had already downloaded several months worth of emails from the Verizon server, so it creates duplicates and even triplicates of emails. I tend to keep almost everything and I usually save my Inbox emails every quarter to storage folders like "Inbox_2014_Q1", but I haven't done it for a while and now my Inbox has almost 12,000 emails since 1/1/2015. I know how to set up "Rules" that move emails with a certain sender or subject or date to another folder, and I do have folders for more important business and personal emails. But there seems to be no way to remove duplicates except manually.

When I have noticed the extra download happening, I have been able to shut down WLM and then access my Verizon account, where I can delete all but very recent emails from the server. I also thought I had my email client set up to delete emails from the server after about a week, but I just checked and that was not so. Now it should only go back 10 days (which is still 500-1000 emails).

Anyway, I decided to create an application with Borland Delphi, which can navigate to my email folder, which is:


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

I made a directory called "ZAP", and I went to my Junk E-mail folder which had about 10 emails in it (including several duplicates), and I was able to recurse through the folder and copy the duplicates to the ZAP folder and then delete them from the Junk folder. However, the emails still remain in the listing of WLM. I messed around with the emails (which are all individual files with .EML extensions), renaming to text to examine and back to EML, and it seems like the file names changed and also the date-time stamp. I thought I could have WLM properly reflect the changed folder by closing it and re-opening, but when I tried, it was borked.

I did a restart and update and re-opened WLM, to find it still listed the duplicate emails, but when I tried to open them it produced an error. I was able to delete them, however. I found that WLM had created a new folder called ZAP(1) and the original ZAP folder contained only an email that I had converted to TXT. So apparently there is some sort of index that is manipulated when emails are moved in WLM and directly deleting or moving or copying the files creates problems. There are some files that might be used for the indexing, such as:


C:\Users\paul_000\AppData\Local\Microsoft\Windows Live Mail\edb003E1.log 

RE: Open Dialog for directory name only (D4)

Looking further at the WLM folder, I found this information:

1. The individual .LOG files edb003E1.log and such are binary files mostly filled with NUL characters, and each is 2048 kb in size. There are about 38 of them with sequential file names having hex values. There is also a edbtemp.log of similar non-text format.

2. There is a Mail.MSMessageStore file which is 147472 kb. I have not checked the format. There seems to be a copy of an earlier version in a Backup\new folder along with 3 log files and an empty Mail.pat file.

3. There is a WindowsLiveMail.log file of 4680 kb which is a text file containing stuff like this:


 * Log opened: 2015-07-18T20:05:45Z
 * Windows Live Mail 16.4.3528.0331
 [16:56:01.96] 17bc                 Mail:            Zone_MailChk ERROR: (booktree.cpp:8411), failed with 0x80040064  
 [16:56:02.02] 17bc                 Mail:            Zone_MailChk ERROR: (booktree.cpp:8411), failed with 0x80040064 
 [15:08:23.20] 0314                 Mail:            Zone_MailChk ERROR: (internat.cpp:309), failed with 0x800CCE05  
 [15:08:23.20] 0314                 Mail:            Zone_MailChk ERROR: (internat.cpp:237), failed with 0x800CCE05 

4. There are other small and sometimes empty files.

I think the WLM crash may have been due to some other problems with the computer, and it is probably safe to move and delete files from the folders. I'm sure I have done it before, and I have some compressed folders that I have used to store emails up to about a year ago. That is an effective way to archive emails, but the non-descriptive titles are not helpful. However, when unzipped, MS Explorer shows the "From", "Subject", and "Date Received" information.

Some additional information: (from 2008 but still valid)

The conclusion is that mucking with the email files and folders outside of WLM is not recommended and may cause WLM to get confused and borked, although it will usually recover to some extent. Perhaps there are VBA hooks in WLM that can be used to automate the duplicate detection and elimination process, using an OLE connection. But it seems that this is possible only with Outlook, and not WLM:

I would start a separate thread but I think there is little point, since it seems that the file and directory structure are too complex to afford a simple solution.

Thanks for the helpful response.

RE: Open Dialog for directory name only (D4)

Can I just mention that you have a very old version of Delphi there,(approx 17 versions behind) and and its even numbered!
It has none of the built in stuff for handling folders and stuff, that is present in more recent versions.
If at all possible consider moving to newer one, upgrading only as far as 7 would be a big help.

Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
That's just perfectly normal Paranoia everyone in the universe has that: Slartibartfast

RE: Open Dialog for directory name only (D4)

I know it's very old but it still seems to do everything I need it to do, and I don't really use it very often. I developed a couple of rather minor commercial applications for specific hardware and otherwise just some utilities like the one I did for this. I have heard that the odd numbered releases are better, but I have not had any major problems with D4, even running it on Win8. I have thought of upgrading, but the cost is rather high for the limited benefit I might get. I didn't see D7 on eBay but I found Delphi 2008 which seems reasonably priced ($130) if it will work for me:

I'm not interested in .NET and I want to have something that is quick and easy to use without a huge learning curve. I do other programming using PIC assembly and C, and occasionally JavaScript and PHP and VBA, and it's difficult to switch around so many languages.

Thanks for the suggestion.

It looks like I would qualify for the XE8 starter edition download from Embarcadero, for $165:

Then I could upgrade to the full professional version for under $1000, which is higher than I'd like but within reason.

The ability to make Android apps might be a good selling point. I have been unable to get very far with the usual Android Developer Studio.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close