Home Delphi 7 Windows 7 Can't set active direcory, when a dpr file is opened from windows explorer
Reply: 1

Delphi 7 Windows 7 Can't set active direcory, when a dpr file is opened from windows explorer

Lim IG
1#
Lim IG Published in 2017-09-11 10:43:02Z

I used to open Delphi 7 dpr files from windows explorer. Delphi used to update current save directory.

But from windows 7 and on this doesnt work. I open dpr from windows explorer, add a new form. When I try to save new unit, delphi tries to save file to last known directory.

Is there a solution to this problem?

Remy Lebeau
2#
Remy Lebeau Reply to 2017-09-11 15:23:33Z

Delphi 7 uses the older Common Dialog Box API for opening/saving files (GetOpenFileName() and GetSaveFileName() functions). That API was replaced with the newer Common Item Dialog API (IFileOpenDialog and IFileSaveDialog interfaces) in Vista.

The behavior you describe is simply how the old API works in modern Windows versions.

Per the OPENFILENAME structure documentation:

lpstrInitialDir
Type: LPCTSTR

The initial directory. The algorithm for selecting the initial directory varies on different platforms.

Windows 7:

  1. If lpstrInitialDir has the same value as was passed the first time the application used an Open or Save As dialog box, the path most recently selected by the user is used as the initial directory.

  2. Otherwise, if lpstrFile contains a path, that path is the initial directory.

  3. Otherwise, if lpstrInitialDir is not NULL, it specifies the initial directory.

  4. If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.

  5. Otherwise, the initial directory is the personal files directory of the current user.

  6. Otherwise, the initial directory is the Desktop folder.

Windows 2000/XP/Vista:

  1. If lpstrFile contains a path, that path is the initial directory.

  2. Otherwise, lpstrInitialDir specifies the initial directory.

  3. Otherwise, if the application has used an Open or Save As dialog box in the past, the path most recently used is selected as the initial directory. However, if an application is not run for a long time, its saved selected path is discarded.

  4. If lpstrInitialDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.

  5. Otherwise, the initial directory is the personal files directory of the current user.

  6. Otherwise, the initial directory is the Desktop folder.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.341003 second(s) , Gzip On .

© 2016 Powered by cudou.com design MATCHINFO