Bob Moore's Coding Tips

This site is intended to help fellow developers, and also to explain a little about me (go to the "Your Host" pages to find out more). It exists as somewhere I can refer people to, rather than having to cut and paste the same code into UseNet or Stack Overflow messages a zillion times over. The site contains over 70 useful code fragments and tips for Windows programmers, and also links to related sites which fellow sufferers at the forge of Microsoft might find interesting : see the buttons on the left.

Note - the MFC samples on this site are no longer actively maintained as I am now working mainly in Delphi and C#. My work in C++/MFC will continue, but at a fairly low level. Feel free to refer others here, the site will be maintained at its current URL to function as an FAQ, so others can refer to it in UseNet and Stack Overflow postings.

The C# code is all new. It would be all trendy and fashionable... if I went in for that kind of thing. You kids and your "rock" music... bah. :)

The C++ code is quite old, so don't expect to see much in the way of proper Unicode text handling etc. It's not necessary to demonstrate the principles, and I can't be bothered to update this much code, so let's just both pretend it's there, OK?

What's New: 

Dec 22nd 2016 Moved entire site to its new domain. Please click the link and re-create your bookmark ASAP. The existing site will become unavailable at the end of Jan 2017.
Feb 25th 2016 Added native code tip 80: Cannot access private member declared in class 'CObject'... WTF?
Feb 17th 2016 Added Wellington Bomber porter to the gluten-free beer list.
Oct 26th 2014 Updated .Net Tip 4 to make the use of the CallingConvention attribute clearer.
Dec 20th 2013 Added a general Visual Studio performance tip: My Visual Studio .Net IDE runs very slowly. Why?
July 28th 2013 Complete site redesign using Twitter Bootstrap.
July 20th 2013 Added a downloadable sample for Tip 79.
10th Jan 2013 Updated my office screenshots.
7th July 2012 Added Tip 79, Why does the MFC CString::Tokenize method ignore blank fields?.
28th Mar 2012 Added .Net tip 7, How do I retrieve the current Windows user account name in C#?.
19th Jan 2012 Updated .Net tip 6, How do I create a single-instance C# application?.
12th Nov 2011 Updated Win32 tip 9 with information about DLL shared sections and sessions under a service hardened environment (NT6+).

You can contact me by mailing bobm at Please let me know if the site has been of assistance to you, or if you've found a bug in the HTML (or a bug in a code sample), or if you would like to see additional features or samples.

But.... if you have a specific programming problem, post it publicly on one of the following Usenet newsgroups :

(or post it to Stack Overflow)

because I never respond to direct unsolicited email.

Oh and by the way - I do NOT work for Microsoft. Never have done. Those MVPs who went to work for Microsoft had to give up their membership of the program, and now I'm not an MVP any longer (eight years was long enough anyway), I probably won't get the chance. I didn't take the chance of an interview when it was offered : mostly because I wouldn't give up being a developer to be a support person, but partially because I don't like what Microsoft has become. If you don't understand that comment, see this posting made by Joel Spolsky years ago, with particular reference to the "two forces" section. I always counted myself as being in the Raymond Chen camp.