Process Explorer in 64-Bit World

Illustration

Process Explorer is one of tools that get installed on any computer I get my hands on. One click on “Options”/“Replace Task Manager” and Ctrl+Esc shortcut becomes owned by it.

That is, it will replace task manager but only if you have 32-bit system. On 64-bit system it will seem to work until you exit it. As soon as you are out of program, system seems to forget that there is any task manager.

Using another great Sysinternals utility - Process Monitor - I found issue. Process Explorer hosts 64-bit version inside of it’s 32-bit process (procexp.exe). If it detects that it is running on 64-bit system it tries to unpacks procexp64.exe into current folder. If that folder is not writable, it extracts file to temporary folder and runs it from there. Process Explorer that you see is running from procexp64.exe.

When replacing task manager, it will point system to search for it’s currently executing copy. Unfortunately when you exit program it procexp.exe will delete that copy in attempt of cleaning after it self. Ctrl+Esc does not work since registry points to, freshly deleted, non-existing procexp64.exe file.

Solution that worked for me was to grant write rights to Process Explorer directory (to both Administrators and Users groups), start it and, while it is running, make copy of procexp64.exe. Once I secured copy of program, I went to “Options”/“Replace Task Manager”. All that is left to do then is exiting program (be sure it is not left in tray area).

Process Explorer will delete procexp64.exe upon exit. To overcome this I just rename program’s copy (made while Process Explorer was running) back to procexp64.exe. Now Ctrl+Esc can be used once more.

Slightly annoying aspect of this is fact that procexp.exe must not be started again to avoid triggering delete. You can solve this by deleting procexp.exe - procexp64.exe is all you need.

Slightly annoying fix, but it does work. And Process Explorer is easily worth all this trouble.

Aspect Ratio

I installed new TV for my dad. Part of installation was climbing roof and bunch of cabling 10 meters over splash surface, but that was not hard part. Hard part was teaching my dad about how TV should be used (he had 4:3 before).

In Croatia we still use 4:3 aspect ratio. Our national TV just cannot be bothered. Choice was simple for this… You must use 4:3 for everything to look properly but 16:9 can be tolerated if you hate vertical black bars and you like stubby people. Yes, you can zoom picture (three different ways to do it) and cut either people’s heads, or subtitles, or both, but this is not a real choice. That is, until they decide to show 16:9 movie. It is done in such manner that 16:9 picture is crammed into 4:3 frame with black bars on top and bottom. For this you need zoom.

Of course there is sport channel that has proper 16:9 support. If we switch to it, we should use proper aspect ratio. But that sport channel also has some shows that use 4:3. It’s switching time again.

To make things better, aspect ratio settings are common for all channels. That means that my father must switch aspect ratio every time he switches between “incompatible” channels. Tracking two football (proper football) games on two different channels could (and usually will) cause need to adjust aspect ratio.

Before today all choices were clear to me and I never gave it much thought. However, as I stood explaining this to my father it struck me how this can seem complicated and annoying to someone who just wants to watch TV. This whole system is just piece of shit.

Froyo and Calendar

I had application on market for quite a while and suddenly I started receiving “SQLiteException”. Quick look at stack trace showed little bit more details:

android.database.sqlite.SQLiteException: no such column: Calendars._id: , while compiling: SELECT _id, title, dtstart FROM view_events WHERE (1) AND (Calendars._id=1)

This clearly pointed toward code that fills calendar events. Generally it looked like this:

Uri calendarsUri;
Uri eventsUri;
if (android.os.Build.VERSION.SDK_INT <= 7) { //up-to Android 2.1 
    calendarsUri = Uri.parse("content://calendar/calendars");
    eventsUri = Uri.parse("content://calendar/events");
} else { //Android 2.2 (Froyo) and later
    calendarsUri = Uri.parse("content://com.android.calendar/calendars");
    eventsUri = Uri.parse("content://com.android.calendar/events");
}
...
Cursor cursor = resolver.query(eventsUri, new String[]{ "_id", "title", "dtstart" }, "Calendars._id=" + calendarId, null, null);
...

Exception pointed right to that last line with query. Froyo had no idea what it should do with Calendars._id.

To make long ranting short, correct code should be:

Cursor cursor;
if (android.os.Build.VERSION.SDK_INT <= 7) { //up-to Android 2.1 
    cursor = resolver.query(eventsUri, new String[]{ "_id", "title", "dtstart" }, "Calendars._id=" + calendarId, null, null);
} else {
    cursor = resolver.query(eventsUri, new String[]{ "_id", "title", "dtstart" }, "calendar_id=" + calendarId, null, null);
}

With this everything started working again and, since calendar code got first-class citizen treatment and it is finally documented in SDK, I doubt that there will be further breaking changes down the road.

Windows Mobile Developer in Android-land

Illustration

Best conference in these parts of world is almost upon us. Yes, I am talking about KulenDayz 2010.

Conference will be held (as usually) in Beli Manastir (near Osijek, in Croatia) at hotel Patria and attendance is completely free of charge although you do need to register. There is small additional fee if you wish to have dinner there but, trust me, it is well worth it.

This is first year when I will not give Microsoft centric talk - title says it all - “Windows Mobile developer in Android-land”. It will be about how well can Windows Mobile Developer adjust to new environment and how much it hurts. It will be experience and question driven so do not expect much of code.

As always, PowerPoint will be available for download.

P.S. Pun on Alice in Wonderland is quite intended. :)