What does the SEE_MASK_UNICODE flag in ShellExecuteEx actually do?


Somebody with a rude name wonders what the SEE_MASK_UNICODE flag does.

It does nothing.

The flag was introduced when porting the Windows 95 shell to Windows NT. It happened further back in history than I have permission to access the Windows source code history database, but I can guess how it got introduced.

One of the things that the porting team had to do was make Unicode versions of all the ANSI functions that Windows 95 created. Sometimes this was done by creating separate A and W versions of a function. Sometimes this was done by having separate A and W versions of an interface. Sometimes by adding additional fields to the A version of a structure with a flag that says whether the ANSI or Unicode members should be used.

My guess is that the porting team initially decided to make Shell­Execute­Ex use that third model, where the SHELL­EXECUTE­INFO structure had a SHELL­EXECUTE­INFO­EX extension with Unicode strings, and the mask specified whether the caller preferred you to use the ANSI strings or the Unicode strings.

Presumably they decided to change course and switch to having separate SHELL­EXECUTE­INFOA and SHELL­EXECUTE­INFOW structures. But when they switched from one model to the other, they left that flag behind, probably with the intention of removing it once all existing callers had been updated to stop passing the flag, but they never managed to get around to it.

So the flag is just sitting in the header file even though nobody pays any attention to it.

Comments (15)
  1. WndSks says:

    I guess I can stop doing "mask = foo | bar | (sizeof(TCHAR)>1?SEE_MASK_UNICODE:0);" now.

    These almost lost to time tidbits are always interesting.

  2. jbw says:

    why do they limit how far back into the code history you can look?

  3. voo says:

    @jbw Oh we had that already. I even was so free to look it up for you because I wasn't too sure on the details anymore myself:

    [All history prior to Windows 2000 has been archived into a salt mine in Montana somewhere. I could probably get access if I had a valid business justification. -Raymond]

  4. Jason Warren says:

    This post is intereesting, though what interests me more is the original post (comment) was made nearly one and a half years ago. In all that time no one stumbled across the question and posted an answer. Even more interesting, is knowing Raymond's system of having a queue of posts over a year long makes me wonder if Raymond's answer was written a year and a half ago and only just now emerged.

  5. Joshua says:

    I agree that is a rude name to be using for every post here. I would have considered it acceptable if the name was chosen to go with the post content but otherwise is inflammatory without a point.

    @Jason Warren: Blog posts older than 2 weeks don't accept comments.

  6. Anon says:

    @Raymond

    I like to think a valid business justification is "Chen. Raymond Chen."

    @Joshua

    Don't worry about it. That blog is a hideous mish-mash of misunderstanding basic OS functionality.

  7. Myria says:

    @skSdnW: You can also just stop using TCHAR entirely.  If you're not compiling for Windows 9x, there's no reason to make a char build anymore.  Just always code for wchar_t.

  8. Cesar says:

    I wonder if, a hundred years from now, Microsoft will ressurrect the source code for the pre-2000 versions of MS-Windows and MS-DOS and donate them to a museum. Major versions of MS-Windows are important cultural artefacts of our era, and it would be good to be able to look back to the days when the computing landscape of the future was shaped and understand the reasons behind the decisions which will have left their mark on the whole of humanity.

  9. Danny says:

    @Cesar

    Right. Like we keep in a museum the source code of mainstreams from the 60's. Ever wondered to look at their OS's? Me neither. The future will say "You had to use fingers on a keyboard to type?" as same way we do to our fathers "You had to punch holes in papers to make it compute?". And remember, Apollo missions were all based on those punch holes!.

  10. yuhong2 says:

    @voo: Yea, as mentioned in the other thread, I think it is the move from SLM to SourceDepot, which AFAIK was done just before Win2000 RTMed.

  11. comparch says:

    @Danny, there's a whole bunch of people who call themselves "computer archeologists" and who absolutely love looking at old software, often with a special interest towards (but certainly not limited to) operating systems. And there already are museums of that kind, although because of the nature of software, most of them are accessed online rather than physically. http://os2museum.com is one example (don't be fooled by the name, it's far far more than OS/2 and given the apparent ratio of OS/2 to non-OS/2 stuff, by now I suspect that the name is just a relict). The Computer History Museum in Mountain View, on the other hand, is an example for a big and hugely popular museum that does host all kinds of older systems. Granted, it's mostly the physical machines, but they do have some software and some restored machines with (presumably) their original operating systems.

    Funny story, I started my computer archeology back when I was a little kid. My father's PC had the then recent MS-DOS 5.0 on it and I got a huge kick out of installing DOS 2.11 on a floppy disk and looking at the differences. Nowadays I install PC/IX and Xenix 86 in emulators.

    So, yes, as Cesar says, I absolutely think that yesterday's operating systems will be important cultural artifacts in the future, at least for some subset of humanity.

  12. Jonathan says:

    Windows 2000 was developer in SLM, the Source Depot transition happened right after it. Presumably, the transition included some form of history, but maybe that got archived in order to keep the size of the depots maintainable.

  13. Danny says:

    @comparch

    Picture me saying the following in Viola Davis voice, sitting with my hands crossed over the chest : "Mmmmmhhhhmmmm".

  14. yuhong2 says:

    @Jonathan: This email dates back to Dec 1999: http://www.tamersahin.com/…/Startup.htm

  15. yuhong2 says:

    BTW, I wonder when Office etc transitioned to SourceDepot.

Comments are closed.