0

I'm using GetOpenFilename to get some filenames

const int BUFFER_SIZE = 8192;
char* filenames = new char[BUFFER_SIZE];
filenames[0] = 0;

OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = ::GetActiveWindow();
ofn.lpstrFile = filenames;
ofn.nMaxFile = BUFFER_SIZE;
ofn.lpstrFilter =
   "Quotes\0*.json\0"
   "All\0*.*\0";
ofn.lpstrCustomFilter = NULL;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrTitle = "Web File Import";
ofn.lpstrInitialDir = "T:\\WebPending";
ofn.Flags = OFN_ENABLESIZING | OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_ENABLEHOOK;
ofn.lpstrDefExt = "json";
ofn.lpfnHook = DDWebImport::Hook;
bool rv = ::GetOpenFileName(&ofn);
// Check the error if you have copied this code to another dialog and it returns immediately without popping up a form
DWORD err = CommDlgExtendedError();

I'm using a core i7 with an SSD and this is taking over 8 seconds to just show the files. When I had a look in the debug output window,

'xxx.exe': Loaded 'C:\Windows\SysWOW64\propsys.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Program Files (x86)\Common Files\Microsoft Shared\Ink\tiptsf.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\edputil.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\policymanager.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\msvcp110_win.dll', Symbols loaded (source information stripped).
shell\comdlg32\fileopensave.cpp(9456)\COMDLG32.dll!76290750: (caller: 76283458) ReturnHr[PreRelease](1) tid(1664) 80070490 Element not found.
CallContext:[\PickerModalLoop\InitDialog\FileDialogInitEnterpriseData] 
'xxx.exe': Loaded 'C:\Windows\SysWOW64\WindowsCodecs.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\thumbcache.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\ntshrui.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\srvcli.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\cscapi.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\StructuredQuery.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\actxprxy.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\Windows.Storage.Search.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\DataExchange.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\dcomp.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\d3d11.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\dxgi.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\twinapi.appcore.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\apphelp.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Program Files (x86)\Common Files\TortoiseOverlays\TortoiseOverlays.dll', Cannot find or open the PDB file.
'xxx.exe': Loaded 'C:\Program Files\TortoiseGit\bin\TortoiseGitStub32.dll', Cannot find or open the PDB file.
'xxx.exe': Loaded 'C:\Program Files\TortoiseGit\bin\TortoiseGit32.dll', Cannot find or open the PDB file.
'xxx.exe': Loaded 'C:\Windows\SysWOW64\msvcp120.dll', Symbols loaded.
'xxx.exe': Loaded 'C:\Program Files\TortoiseGit\bin\gitdll32.dll', Cannot find or open the PDB file.
'xxx.exe': Loaded 'C:\Program Files\TortoiseGit\bin\libgit232_tgit.dll', Cannot find or open the PDB file.
'xxx.exe': Loaded 'C:\Windows\SysWOW64\msvcr120.dll', Symbols loaded.
'xxx.exe': Loaded 'C:\Program Files\TortoiseGit\bin\zlib132_tgit.dll', Cannot find or open the PDB file.
'xxx.exe': Loaded 'C:\Users\cup\AppData\Local\Microsoft\OneDrive\17.3.6302.0225_1\FileSyncShell.dll', Cannot find or open the PDB file.
'xxx.exe': Loaded 'C:\Windows\SysWOW64\wininet.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Users\cup\AppData\Local\Microsoft\OneDrive\17.3.6302.0225_1\Telemetry.dll', Cannot find or open the PDB file.
'xxx.exe': Loaded 'C:\Windows\SysWOW64\psapi.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Users\cup\AppData\Local\Microsoft\OneDrive\17.3.6302.0225_1\LoggingPlatform.dll', Cannot find or open the PDB file.
'xxx.exe': Loaded 'C:\Windows\SysWOW64\cabinet.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\wsock32.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\mssprxy.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Program Files (x86)\Microsoft Office\root\Office16\GROOVEEX.DLL', Cannot find or open the PDB file.
'xxx.exe': Loaded 'C:\Windows\SysWOW64\msvcp140.dll', Symbols loaded.
'xxx.exe': Loaded 'C:\Windows\SysWOW64\ucrtbase.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Windows\SysWOW64\vcruntime140.dll', Symbols loaded.
'xxx.exe': Loaded 'C:\Windows\SysWOW64\msi.dll', Symbols loaded (source information stripped).
'xxx.exe': Loaded 'C:\Program Files (x86)\Microsoft Office\root\Office16\1033\GrooveIntlResource.dll', Binary was not built with debug information

How do I stop GetOpenFilename from loading DLLs like directx, git, tortoise git, groove, onedrive. With so many of them, they take ages loading and aren't necessary for just viewing a bunch of filenames.

cup
  • 7,589
  • 4
  • 19
  • 42
  • You can't control what DLLs the shell decides it needs to load when calling the function. The loading of DirectX, Git, and the others are most likely related to thumbnail previews that the dialog can optionally show or icon overlays (particularly in the case of Tortoise Git, if it's anything like Tortoise SVN). – Ken White Jul 13 '16 at 22:06
  • For the record, I'm not the one that downvoted your question. I just left a comment. – Ken White Jul 13 '16 at 22:11
  • Is it possible to just show the filenames without any icons? At then end of the day, I'm only interested in choosing a bunch of files. It doesn't have to show any icons. – cup Jul 13 '16 at 22:20
  • Windows doesn't know what the *user* will decide to do. They can change the view to small/med/large icons, list, details, or thumbnail preview. – Ken White Jul 13 '16 at 22:34
  • It is slow, because **you** installed all those shell extensions and intergrations. If you want to speed things up, you need to stop doing this. – IInspectable Jul 13 '16 at 23:14
  • So I can't get it to load without shell extensions and integrations? Onedrive and groove come with the OS. http://stackoverflow.com/questions/10399627/prevent-all-non-system-shell-extensions-from-loading-in-a-getopenfilename-cfile couldn't figure out a fix for this one – cup Jul 14 '16 at 07:04
  • Found an answer in http://stackoverflow.com/questions/32770778/how-to-prevent-a-specific-dll-from-loading-into-my-process?answertab=active#tab-top - basically do not use OFN_EXPLORER or create dummy DLLs for the DLLs loaded. – cup Jul 16 '16 at 18:36

1 Answers1

0

The real answer I was looking for is in Slow loading of symbols during call to CoCreateInstance in VS 2012

Basically exclude the dlls from loading in Tools/Options/Debugging/Symbols Look for all the dlls that say Cannot find or open the pdb file and add them to the list

Community
  • 1
  • 1
cup
  • 7,589
  • 4
  • 19
  • 42