Why does the class name for Explorer change depending on whether you open it with /e?

Raymond Chen

Raymond

I noted some time ago that Explorerā€™s original name was Cabinet, and that the name lingers in the programmatic class name: CabinetĀ­WClass. A commenter with a rude name points out that Explorer uses the class name ExplorerĀ­WClass if you open it with the /e command line switch, adding, ā€œThis is rather strange since you can toggle the folder pane on/off in the UI either way.ā€

In Windows 95, the window class names for Explorer were CabinetĀ­WClass for plain Explorer windows and ExplorerĀ­WClass for windows opened in Explore mode with the folder tree view thingie on the left hand side. This was not strange at the time because there were two different types of Explorer windows, and there was no way to change between them. The UI to toggle the folder pane on/off did not exist.

Internally, the two types of Explorer windows were handled by different frame window classes, and naturally the two different classes got different names. The plain Explorer window frame hosted a view window, an address bar, and a status bar, whereas the fancy Explorer window frame hosted those components plus a folder tree. It wasnā€™t until some time later that the ability to toggle the folder pane on and off was added. To do this, the two window classes were merged into a single implementation that dynamically added in or removed the folder tree.

Great, we can get rid of ExplorerĀ­WClass and just use CabinetĀ­WClass for everything.

And then the application compatibility bug reports came in.

Because even though it wasnā€™t documented, application relied on the implementation detail that plain Explorer windows could be found by doing a FindĀ­Window for CabinetĀ­WClass, and that fancy Explorer windows could be found by doing a FindĀ­Window for ExplorerĀ­WClass. They would do things like launch explorer.exe /e C:\some\folder, wait a few seconds, and then do a FindĀ­Window("ExplorerĀ­WClass", ...) and expect to find a window. (Just do a Web search for CabinetĀ­WClass and ExplorerĀ­WClass if you donā€™t believe me.)

For compatibility, therefore, Explorer windows still use the old class names from Windows 95. If you open the window with the folder pane hidden, the class name is CabinetĀ­WClass, and if you open it with the folder pane visible, the class name is ExplorerĀ­WClass. The two classes are functionally identical, but people who rely on undocumented behavior expect to see the same names from 1995.

Raymond Chen
Raymond Chen

Follow Raymond