Hotel International

Illustration

Malfunctioning plane was all it took to ground me once more and to award me free stay in hotel, early wake up to catch next flight and feeling awful for whole next day.

I got free ride to hotel (courtesy of Croatia Airlines) and I got free bus pick-up at 05:00. Standard bus ride this early is not something you see too often.

Room was quite fine but real gem was free wireless Internet access through-out hotel. This is something every hotel should have!

Best surprise was dinner. While mighty Sheraton only offered me stale meal, here I could choose what I wish to eat from six three-course menus. To make it even better, you could mix-and-match them to get your favorite combination.

Although I didn’t pay dime for this stay, I felt welcomed and like a proper guest. What more can one ask?

Microsoft Connect

Illustration

Microsoft started Connect site a while ago and I understood it as central hub for all bug reports. If came handy for taking bug reports for Windows 7 (now closed) and Visual Studio. Interface was simple and you could be sure that you would get some response. Even if that response is “Won’t Fix”.

This is probably why I am so furious on Microsoft Office team. Only thing they did is to include link to page full of marketing. Microsoft already has full infrastructure in place for reporting bugs but they decide not to use it.

Yes, I know that there is Send-a-Smile program available for Office 2010 and I am aware that it may be easier for most of people. However, this should not be an excuse. Windows 7 team managed to include their stand-alone utility with Connect without big issues.

Now you must excuse me since I need to reboot my computer in order to boot into another Windows instance with Office 2010 beta in order to report a bug. Only if there was a web interface for that… :)

We're Sorry, but the Clip You Selected Isn't Available From Your Location

Illustration

As I live in Croatia, I am used to videos being blocked.

With all this Conan vs. Leno controversy, I decided to check what exactly is going on. One of videos I tried to watch was on The Jay Leno Show page. It featured standard “We’re sorry”, but only after giving me advertisement message before.

If they decide not to offer their program in my country, I can live with this. But how can one in straight face say that while actual program may not be available for me, advertisements are fine.

And it is not only videos. It apply when you are buying stuff too. It is books on Amazon, audio books on Audible, and quite a few other places.

I hate when I need to download content from unauthorized source (e.g. torrents) just because they do not want my money. If you do not consider my money “green” enough, it is fine, but then do not complain that piracy is wide-spread when you are one that is forcing it.

GetLastWin32Error

static void Main(string[] args) {
    if (!NativeMethods.DeleteFileW(@"X:\NonExisting.txt")) {
        throw new Win32Exception(Marshal.GetLastWin32Error().ToString());
    }
}

private static class NativeMethods {
    [DllImportAttribute("Kernel32.dll", EntryPoint = "DeleteFileW", CharSet = CharSet.Unicode)]
    [return: MarshalAsAttribute(UnmanagedType.Bool)]
    public static extern bool DeleteFileW([InAttribute()] [MarshalAsAttribute(UnmanagedType.LPWStr)] string lpFileName);
}

This code looks quite straightforward. Function should delete file and in case of failure exception will be raised. In this particular case one would be expect either 2 (ERROR_FILE_NOT_FOUND) or 3 (ERROR_PATH_NOT_FOUND) as raised exception’s text.

However this example will most probably return 0. You can already guess from highlight that problem is in DllImport line. To make function behave properly, one parameter needs to be added:

[DllImportAttribute("Kernel32.dll", EntryPoint = "DeleteFileW", CharSet = CharSet.Unicode, SetLastError = true)]

When SetLastError is set to true, .NET will make all necessary plumbing in order to catch and store error code. This code will be available to you in GetLastWin32Error() function until some other P/Interop call overwrites it.

Although I knew all of that, I fell as a pray to this annoying bug. Reason lies in great tool - PInvoke Interop Assistant. It will generate all necessary P/Interop signatures and it is just too easy to rely on it’s judgement. At least until you find out that all those API signatures are generated without SetLastError parameter set.

If this little issue goes unnoticed, you have quite a big bug on your hands. Worse still, since GetLastWin32Error() will almost always return 0, bug will probably go unnoticed and it will manifest itself somewhere far away from function. Catching that one can be tricky.

Safely Remove Hardware

Illustration

I hate when new version of program removes one feature that I use, no matter how insignificant it may seem. Once you get used to something, it is always hard to let it go.

When you go to “Safely remove” your USB disk in Windows XP this will also close any Explorer window that has drive listed.

Then Windows Vista came. In Windows Vista you will get an error if any program is currently accessing drive that is being removed. This includes also simple viewing of content. I can understand reasoning - this was “proper” way to do things - no special behavior for any program.

It came to me as a surprise that Windows 7 brought “old” behavior back. It just feels much more humane when computer does obvious things for you. And it definitely shows problem with Windows Vista - lot of small annoying things.