Why does the class name for Explorer change depending on whether you open it with /e?
I noted some time ago that Explorer’s original name was Cabinet, and that the name lingers in the programmatic class name: CabinetWClass. A commenter with a rude name points out that Explorer uses the class name ExplorerWClass 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 CabinetWClass for plain Explorer windows and ExplorerWClass 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 ExplorerWClass and just use CabinetWClass 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
FindWindow for CabinetWClass, and that fancy Explorer windows could be found by doing a
FindWindow for ExplorerWClass. They would do things like launch
explorer.exe /e C:\some\folder, wait a few seconds, and then do a
FindWindow("ExplorerWClass", ...) and expect to find a window. (Just do a Web search for CabinetWClass and ExplorerWClass 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 CabinetWClass, and if you open it with the folder pane visible, the class name is ExplorerWClass. The two classes are functionally identical, but people who rely on undocumented behavior expect to see the same names from 1995.