November 4, 2007

This blog has moved...

After becoming a freelancer, I ordered a new domain, and now moved my blog to this new domain:

Hopefully you will also be reading this blog…
It will start with various posting about the TechEd-Developer conference in Barcelona!

October 9, 2007

TechEd-Developer 2007 in Barcelona!

If you attend TechEd-Developer in Barcelona (5.11. 9.11.2007), you can meet me at the ATE (Ask The Expert) booth from Microsoft!

September 21, 2007

Addition to: How to write Textfiles with encoding in MFC

Martin Richter pointed me to a problem in my previous posted code-example regarding opening files with a specific encoding.
If you pass a FILE* stream to the CStdioFile constructor, then it will not auto-delete the file in the destructor!

To prevent this, you can use a derived class:

class CStdioFileWithClose : public CStdioFile { public: CStdioFileWithClose(FILE *pOpenStream) : CStdioFile(pOpenStream) { m_bCloseOnDelete = TRUE; } };

Then the example should look like:

// Open the file with the specified encoding FILE *fStream; errno_t e = _tfopen_s(&fStream, _T("test.txt"), _T("wt,ccs=UNICODE")); if (e != 0) return; // failed.. CStdioFileWithClose f(fStream); // open the file from this stream f.WriteString(_T("Test")); f.Close();

September 20, 2007

(Unmanaged) Profiler in VS2005 Team-Edition

With VS2005 Microsoft provided a very usefull and handy code-profiling tool. There is only one downside: It is only available in the “VS2005 Team Developer” or “VS2005 Team Suite” edition.

The profiler can be used with managed and unmanaged code!

Here are some screenshots for an unmanaged project:

September 14, 2007

How to write Textfiles with encoding in MFC

MFC only can handle ANSI-textfiles with CStdioFile, because it uses the default behaviour of the CRT.
But you can open the file-stream by yourself and then you can use the new encoding functionality in the CRT to specify the correct encoding.

The follwing example demonstrates this:

// Old-Style... do not use... //CStdioFile f; //f.Open(_T("\test.txt"), CFile::modeCreate | CFile::modeWrite); // Open the file with the specified encoding FILE *fStream; errno_t e = _tfopen_s(&fStream, _T("\test.txt"), _T("wt,ccs=UNICODE")); if (e != 0) return; // failed.. CStdioFile f(fStream); // open the file from this stream f.WriteString(_T("Test")); f.Close();

This example will create/open the file test.txt with UNICODE-Encoding. It will also write a UNICODE (UTF-16) BOM.

The following encodings are widely used:

  • “ccs=UNICODE” => UTF-16 (Big endian)
  • “ccs=UTF-8” => UTF-8
  • “ccs=UTF-16LE” => UTFS-16LE (Little endian)
  • “ccs=ANSI” => ANSI (default encoding of the OS)

If the text file aready exists, it will try to read an existing BOM and read the file with this encoding.

For more info see:

August 27, 2007

There will be no Release-Candidate (RC) of VS2008

After shipping VS2008-Beta2 in June 25th, Microsoft decided to skip RC versions. The next version will be RTM (expected in November 2007).
For more info see:
LINQ to SQL Beta2 to RTM Key Changes

Also foreign languages of VS are now available: For example German

May 30, 2007

Balloon-Tooltip with Close-Button

p. After reading several questions from people how try to create a “balloon tooltip with close button”, I digged a bit to find a solution. It seems that the try-notificaztion balloon-tip will always have this close-button on XP (maybe depending on the UI-style). But for normal balloon-tooltips it seems to be not possible. First I tried to look into the documentation of TTS_BALLOON. This was introduced with version 5.8 of the common controls (IE5). In the latest documentation for VS2003 (Jan 2006), I could not find any hint to get the close button into the balloon tooltip. Looking at the Vista-PSDK and documentation of TTS_BALLOON, you will see an “TTS_CLOSE” style! Ok, this seems to be the one I want to use! And wow, this TTS_CLOSE style is also availble in the PSDK which was shipped with VS2003! So it seems just the documentation is old.



Ok, after adding the style I tried the app and: nothing… no close-buttons…
Ok.. what next… I tried a new app in VS2005 and: the close button is there!
So: What is the difference between my VS2003 app and my new VS2005 app. The answer is simple: my new app has a manifest for the “Common Controls v6”!
So I tried to add a manifest to my “old” VS2003 and: voila: it also has the close buttons on the balloon tooltip.

Conlusion: If you want a close button, you need to

  • add TTS_CLOSE to you style
  • add a manifest for Common-controls-v6

May 29, 2007

InterOp seems to be very voluminous

After having a discussion with Ben Voigt, I got aware of the very voluminous support for InterOp in C++/CLI. Also the buildIn (C++ interop) seems to be very powerfull. I did not realized this until now. Thanks Ben for helping me in the right direction.
Here are just some links which helps to take a small look at C++ interop and P/Invoke:
Native and .NET Interoperability
Using C++ Interop
Using Explicit PInvoke in C++

March 9, 2007

HLP-Viewer now available for Vista

Several month ago I posted about the decision from MS to discontinue support for HLP-files in Vista . Also Vista RTM does not have the “winhlp32.exe” program.

But two days ago, MS put a download page for this”Vista-Aware” WinHlp32.exe:
Windows Help program (WinHlp32.exe) for Windows Vista
online. So it seems they changed their mind (again)...

March 3, 2007

Services and Vista (Session 0 isolation)

Starting with Vista MS has isolated the “session 0” from all other sessions and this session is specially reserved for services to separate it from the current logged on user and user-interface.

Now many servies which require inteaction with the user are not working anymore (or not as expected). To write “correct” services you need to follow the guidlines from MS:
Services in Windows Vista
Impact of Session 0 Isolation on Services and Drivers in Windows Vista

Just a small note to all developers who still want to use the “intercative service detection” in vista (which will display a message box that a service want to say somehting): This feature will be removed from the next version of windows! In the next version, all services must handle Session 0 isolation properly!