Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / @Paul, ANR when calling SHBrowseForFolder() from plugin.

Author
Message
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 2nd Sep 2017 17:23
Hi Paul, I am getting AppNotResponding error when calling SHBrowseForFolder() with BIF_USENEWUI flag from v2017.08.16, I rolled back to v2017.07.19 (before the addition of visual styles and GetMemblockPtr()) when I was sure this function called worked error free and indeed it does, something in the last update is preventing my plugin from calling SHBrowseForFolder() with BIF_USENEWUI or BIF_EDITBOX | BIF_NEWDIALOGSTYLE flags set.

After a headache and much research I tracked the problem down to a call to CoInitializeEx() that is not closed with a call to CoUninitialize(), my plugin does not open any COM interfaces directly so I am pretty sure its not on my end, if I call CoUninitialize() before SHBrowseForFolder() then it works as expected, as like I say it worked in previous versions of AppGameKit I can only imagine the CoInitializeEx() call is AppGameKit side?

I experimented by calling CoInitializeEx_(0, #COINIT_MULTITHREADED) (which would block out SHBrowseForFolder) and CoUninitialize_() to close the interface I just opened and still ANR, only a second call to CoUninitialize will free up the interface and allow the function call, I got it working but I worried now that something down the line is not going to work.

my point of reference
Quote: "BIF_NEWDIALOGSTYLE (0x00000040)

0x00000040. Version 5.0. Use the new user interface. Setting this flag provides the user with a larger dialog box that can be resized. The dialog box has several new capabilities, including: drag-and-drop capability within the dialog box, reordering, shortcut menus, new folders, delete, and other shortcut menu commands.
Note If COM is initialized through CoInitializeEx with the COINIT_MULTITHREADED flag set, SHBrowseForFolder fails if BIF_NEWDIALOGSTYLE is passed."


and

Quote: "BIF_USENEWUI

Version 5.0. Use the new user interface, including an edit box. This flag is equivalent to BIF_EDITBOX | BIF_NEWDIALOGSTYLE.
Note If COM is initialized through CoInitializeEx with the COINIT_MULTITHREADED flag set, SHBrowseForFolder fails if BIF_USENEWUI is passed."

Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 2nd Sep 2017 22:27
AGK calls CoInitializeEx(NULL, COINIT_MULTITHREADED) once at the beginning of the app, and CoUninitialize() when the app closes, it is used for MP3 playback, video playback, and XInput controllers. I don't know the implications of temporarily uninitializing it and then reinitializing it whilst the dialog box is visible, but if all three of those features still work with the hack then it might be ok.
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 2nd Sep 2017 23:29
Ok, well I'm assuming that if I can deinitialize from my dll then I can also reinitialize for the main process when I'm done, I am not using those features in my app so it should not be an issue but one of my other public plugins uses SHBrowseForFolder with the offending flags so it will warrant some further testing on my part, this is a typical WinAPI gotcha!

Thanks for the conformation and quick response.

Login to post a reply

Server time is: 2024-11-24 09:44:57
Your offset time is: 2024-11-24 09:44:57