Jump to content
angusj

FileOpen dialog not showing all files

Recommended Posts

I recently received an email informing me that not all files were appearing in a FileOpen dialog in one of my applications**. 

And this dialog had absolutely no filtering applied (at least when selecting *.* 😜).

The folder given as an example was: 

C:\Windows\System32\fr-FR

And I too wasn't seeing all the files in this folder.

 

Using Delphi 10.4 Update 2 ...

I first tried a completely new VCL application with just a TOpenDialog control (without success).

I then tried a bare bones console application that's a Delphi translation of this C++ code:

https://learn.microsoft.com/en-us/windows/win32/learnwin32/example--the-open-dialog-box

 

program Project2;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  Windows, SysUtils, ActiveX, ShlObj;

var
  hr: HRESULT;
  fileOpen: IFileOpenDialog;
  item: IShellItem;
  path: LPWSTR;
begin
  hr := CoInitializeEx(nil, COINIT_APARTMENTTHREADED or
        COINIT_DISABLE_OLE1DDE);
    if (SUCCEEDED(hr)) then
    begin
        // Create the FileOpenDialog object.
        hr := CoCreateInstance(CLSID_FileOpenDialog, nil, CLSCTX_ALL,
          IID_IFileOpenDialog, fileOpen);

        if (SUCCEEDED(hr)) then
        begin
            // Show the Open dialog box.
            hr := fileOpen.Show(0);

            // Get the file name from the dialog box.
            if (SUCCEEDED(hr)) then
            begin
                hr := fileOpen.GetResult(item);
                if (SUCCEEDED(hr)) then
                begin
                    hr := item.GetDisplayName(SIGDN_FILESYSPATH, path);

                    // Display the file name to the user.
                    if (SUCCEEDED(hr)) then
                    begin
                      MessageBoxW(0, path, 'the path', MB_OK);
                      CoTaskMemFree(path);
                    end;
                    //item._Release;
                end;
            end;
            //fileOpen._Release;
        end;
        CoUninitialize();
    end;

end.

 

And this problem persists with only about half the files in the folder (mentioned above) being displayed.

However, when I compile the C++ code from the link above in MSVC, the console app. does show all the files (as expected). 

 

Any suggestions?

 

 

**Resource Hacker

Edited by angusj

Share this post


Link to post

Reproduced.

Not only does the file open dialog not show all files. It refuses to accept the names of the files it doesn't show.

 

I have reproduced with both Delphi applications ** and notepad++ (which presumably isn't written in Delphi). Notepad.exe can see the files.

 

Intriguing...

 

**) Resource Editor 🙂

Edited by Anders Melander

Share this post


Link to post
1 minute ago, Lars Fosdal said:

Are there any special attributes on the files not listed?

No. (That was the very first thing I checked.)

Share this post


Link to post

32 bit programs show contents of C:\Windows\SYSWOW64, when looking at C:\Windows\SYSTEM32.

64 bit programs show contents of C:\Windows\SYSTEM32, when looking at C:\Windows\SYSTEM32.

Basic 64 bit Windows thing.

Share this post


Link to post
2 minutes ago, Virgo said:

32 bit programs show [...rewrite of what was just posted...]

Basic 64 bit Windows thing.

ChatGPT, is that you?

 

Okay, now I've had too much coffee.

Share this post


Link to post
23 hours ago, Anders Melander said:

Well done finding that.

But I still don't understand why the different compilers show different folder content when it's virtually the same code. 

Edit: Arh, it's the application's 32bit vs 64bit (not the OS). Sorry, a bit slow tonight.

Edited by angusj

Share this post


Link to post

And I managed to miss, that Anders Melander had already posted link to explanation....

Share this post


Link to post
2 minutes ago, angusj said:

But I still don't understand why the different compilers show different folder content when it's virtually the same code.

One compiles a 32-bit application, the other a 64-bit.

Share this post


Link to post
4 hours ago, Fr0sT.Brutal said:

Just curious. What did they do in system folder?

What do you mean?

Share this post


Link to post
13 hours ago, Remy Lebeau said:

What do you mean?

What were users trying to find in that system folder? I personally can't tell when I was visiting Windows\System last time. The mentioned folder contains translated resources for system apps, as I understood. That's why the question.

Edited by Fr0sT.Brutal

Share this post


Link to post
6 hours ago, Fr0sT.Brutal said:

What were users trying to find in that system folder? 

I did ask because I was also curious. And a very brief part of the reply was that this user has written an add-on for anther program and states that "I want, eventually, to support multiple languages in the UI". I've really no idea how he plans to do that, and how accessing these files will help. Nevertheless in the past I have used Resource Hacker to glean dialog control ids, menus etc which I've altered dynamically from my own applications (via Windows' messaging system). And on rare occasions I've even altered application resources (modified the files) to better suit my needs - change a menu shortcut, enable a menu item, it tweak a dialog.

Edited by angusj

Share this post


Link to post
1 hour ago, Fr0sT.Brutal said:

BTW, is that you an original author?

Yep, the only author 😁.

Edited by angusj

Share this post


Link to post

How do I have version 5.1.8.360 installed when your own link above is only to 5.1.7 ?

Share this post


Link to post
12 hours ago, timfrost said:

How do I have version 5.1.8.360 installed when your own link above is only to 5.1.7 ?

Don't believe the version number stated on Angus's website, the version downloadable from there is 5.1.8.360.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×