Busy doing what I'm supposed to be doing

by Matt 30. December 2006 17:27

My mother got a digital picture frame for Christmas. It's rather nice. I'm a little bit jealous. But I had to bite my tongue when I noticed one feature it shouldn't have. Occasionally, before displaying the next photo, it would overlay a large hourglass cursor - showing it was busy.

What on earth for?

If it takes longer than expected to display the next photo, it's not holding anything up; it just means the next photo will get displayed a little late. And the designers, in their wisdom, decided that the best thing to do would be to draw attention to this by sticking an ugly great big hourglass over your pictures.

They're actually telling you that while you're watching a slideshow, the device is working on a slideshow.

It's like driving your car with a little voice telling you that the engine is running every now and then.

What were they thinking?


Obsession With Detail

Top Christmas tip

by Matt 23. December 2006 04:46

If you want to win the little toy in a Christmas cracker, simply hold the cracker a little further into the body (but not so much that it's obvious) - this makes it less likely to tear at the perforations on your side. Use this knowledge wisely.

Merry Christmas.


New desktop search plugins

by Matt 21. December 2006 18:56

Microsoft have recently released a bunch of plugins for Windows Desktop Search. And these support WDS 2.x on XP, 3.x on XP and WDS on Vista, which is a bit nifty.

From Brandon Paddock's blog:

Today we released updated Add-ins for Windows Desktop Search.  Most notable among the changes is that they now support Windows Vista.  This includes the UNC Protocol Handler which allows you to index remote network shares (without using Offline Files).

Add-in for Files on Microsoft Networks (UNC and mapped drives)

Add-in for Internet Explorer history

Add-in for .msg files

Add-in for Lotus Notes

I'm not going to use the .msg or Lotus Notes versions, but the network share one looks interesting, and I'll definitely give the IE history one a go. I'll let you know if it turns out useful (I'll have to update my list of programs what I run).

And it appears that Adobe Reader 8 includes a PDF filter that works on Vista (or WDS 3 on XP). Unfortunately, it looks like you can only get it bundled with the reader software, and I'm not sure I'm ready to trust Adobe to have built something that isn't bloated and overweight, especially when you see how lightweight FoxIt Reader is. And I'm not a big PDF user. Maybe I'll give it a go. Install it. Take one for the team.


Windows Desktop Search

A .net framework bug

by Matt 19. December 2006 17:56

Yep. I've found an honest-to-goodness bug in the framework. And it's genuine, too. Not one of your "my code's not working, .net's broken" bugs. Nope. I've got proof.

Uri.IsHexEncoding checks for the pattern %hexhex is at a particular offset in a string. So you can write something like this to check if a string is uri encoded:

public bool IsUriEncoded(string uri)
	for(int i=0;i<uri.Length;i++)
			return true;
	return false;

For a string such as "/path/%2f/hello", it will return true. For a string such as "/path/%xx/hello", it will return false.

Fancy finding a bug? Get your mince pies round this - it's the source for Uri.IsHexEncoding (this snippet brought to you by the letter "Reflector"):

public static bool IsHexEncoding(string pattern, int index)
	if(((pattern.Length - index) >= 3)
		&& ((pattern[index] == '%') 
		&& (Uri.EscapedAscii(pattern[index + 1],
			pattern[index + 1]) != 0xffff)))
		return true;
	return false;

Spotted it yet? Try the string "%2y". It returns true.

The second parameter to Uri.EscapedAscii should be "pattern[index + 2]", not "pattern[index + 1]".

My feeling is that this method would be mostly used in a security checking context, so it's really important it works correctly.

So, a proper bug. I've reported it as a bug on Microsoft Connect (log in required). I've even added a comment to the msdn docs page (which is a really rather cool feature). I couldn't be more helpful even if I went round everyone's computers and fixed their code for them.

PS. It's dead easy to work around. You'll probably call it in a loop like the one above. Just change the line calling Uri.IsHexEncoding to:

if(uri[i]=='%' && Uri.IsHexDigit[i+1] && Uri.IsHexDigit[i+2)
	return true;



The programs what I run

by Matt 16. December 2006 18:45

I've recently installed Vista, and as such have had to reinstall all the apps and tweaks that I'm used to having. In the spirit of Scott Hanselman's Ultimate List of Every Program Ever Released, here's a slightly more manageable (shorter) list of tools that I actually find useful. This is as much for my benefit as anyone else's. I always forget what I've got installed.

Internet Tools

Developer/Power User Tools

  • Visual Studio 2005. Not yet at the just released SP1 - I'm probably going to jump in with the Vista specific beta SP1 Update (when it lands). Should hopefully fix some of the many issues with Vista (pretty much all of which I've somehow managed to dodge). SP1 will include built in support for Web Application Projects. Not sure about Web Deployment Projects. If not, I'll need to install that.
  • Team Explorer. Team Foundation System client. Messy install. Had to disable UAC, then found a better way of kicking of the install that might not have needed that. Got there in the end.
  • .net 3 Visual Studio extension bits - WCF & WPF and WF.
  • Windows SDK. If you want to develop for Vista, you'll need this (and it's RTM now)
  • Platform SDK for Windows Server 2003 R2. The SDK previous to the Windows SDK. I think you can build for downlevel OS versions with the Vista Windows SDK - get this for paranoia's sake (but I think you can only install one...)
  • WTL. If you're doing traditional C++ Windows programming, you really want this. Rather a steep learning curve (it extends ATL) but it's very good.
  • TestDriven.net. A program with the same name as it's website. Good marketing. Running tests from within Visual Studio is the future.
  • Resharper. I'm still undecided on this one. It eats resources, slows down VS and remaps all of the keystrokes I've got trained into me from years of use. Seems incredibly powerful, but I only ever seem to scratch the surface with it. The latest 2.5 release supposedly gives performance increases.
  • Reflector. The single best app for programming .net ever.
  • Sysinternal's Process Monitor (saves me some typing. I was going to have to link to RegMon, FileMon and Process Explorer)
  • Virtual PC 2007 beta. It's got hardware virtualisation support. Need I say more?
  • Virtual CloneDrive. I'm disappointed that Microsoft's super-simple virtual CD control panel app no longer works on Vista. The best alternative I could find is this. It only maps a single drive and runs all the time, but it does the job.

Shell Extensions

I'm a massive shell extension fan (shell extensions extend Windows Explorer) so it's kind of surprising that I don't have many installed.

  • .net assembly shell extensions. Adds a nice little ".net" overlay to any .dll files that just happen to be .net assemblies. It also adds custom columns that appear in Explorer, but this bit doesn't work in Vista. It's worth it for the overlays.
  • IsoRecorder. Once you've got an ISO image, this makes it dead easy to burn straight to CD. Not sure if it supports Vista RTM at the moment (RTM ATM?)
  • CopyUrl. I really like this one, but haven't yet got it working in Vista. Adds a couple of new items to Internet Shortcut's context menu - copy URL, copy name (of item) and copy link (html formatted link of url and name). Dead useful, but not working for me right now.
  • Silurian Inspect Exe. Rather useful set of property sheet extensions for .exe files (and .dll, etc). Shows imported dlls and functions, exported functions, resources and so on.

Day-to-day Tools

  • Windows Live Writer. Annoyingly, you have to have IE's language set to en-us to be able to download Live Writer or plugins.
  • Blog This for Live Writer in IE. A very nice IE toolbar icon for blogging about web pages.
  • Syntax Highlighter for Live Writer.
  • iTunes. Purely for my iPod. All my music is ripped into Windows Meida Player 11 as part of my Media Centre PC Plan. Bit of a pain, though.
  • FoxIt Reader. A better alternative to Adobe Acrobat Reader, although I haven't tried the new version 8. It's fast and small, but it apes Adobes interface just a little too much for my liking. I'd like to see a PDF viewer that's just like Microsoft's XPS viewer - a simple, unobtrusive IE plugin.
  • Office 2007. And disappointingly, haven't had to do anything with it yet, so don't know if this ribbon thing is any good or not.
  • Windows Desktop Search. Of course. (But not on Vista.)

Stuff Still To Sort Out

This is stuff I need to install or configure, but haven't got round to it yet.

  • IIS7. Not your father's IIS. Need to spend some time on this one, I think.
  • Subsystem for Unix based applications. This is several blog posts in itself. This is Unix running on Windows, with all the tools you know and love (including the absurdly user-friendly awk). And the best thing? It's not Cygwin. (Ask me about Cygwin's thread local storage sometime, won't you?)
  • Xming. If you need to run X Windows System programs (such as SUA programs above), Xming is a great way of displaying them.
  • PowerShell. Just as soon as there's a Vista installer...
  • SDP. When you want to save a media stream, this free program seems to do the trick. Not sure if it only supports the mms: protocol (Microsoft), or whether it can handle Real and others too.


Ooops. Msdn goes south

by Matt 16. December 2006 18:04

Just browsing msdn, heading for the Web Deployment Projects page:

Someone's forgotten to set customErrors to "RemoteOnly".

Nice call stack.


Implementing IFilter

by Matt 12. December 2006 18:54

Last time on the Windows Desktop Search show, IUrlAccessor was dishing out IFilter interfaces.

The good news is this is the last of the core interfaces a protocol handler has to implement - that's right, the theory is almost over. There'll be a test later, though.

IFilter is the work horse of desktop search - it's how WDS supports lots of different file formats. Here's the interface:

interface IFilter: IUnknown
    SCODE Init([in] ULONG grfFlags,
               [in] ULONG cAttributes,
               [in, size_is(cAttributes), unique] FULLPROPSPEC const * aAttributes,
               [out] ULONG *pFlags);
    SCODE GetChunk([out] STAT_CHUNK *pStat);
    SCODE GetText([in, out] ULONG *pcwcBuffer,
                  [out, size_is(*pcwcBuffer)] WCHAR *awcBuffer);
    SCODE GetValue([out] PROPVARIANT **ppPropValue);
    SCODE BindRegion([in] FILTERREGION origPos,
                     [in] REFIID riid,
                     [out] void ** ppunk);

BindRegion's the easiest method - it's reserved. Just return E_NOTIMPL.

Init is surprisingly complex. The flags value can modify some of the behaviour of the filter. If cAttributes is non-zero, the aAttributes array contains the list of properties to retrieve - the caller isn't interested in any others. If neither flags nor attributes are specified, the default PSGUID_STORAGE set of property attributes should be returned. These are a default set that include things such as modified time, size and contents. They're defined in stgprop.h in the Platform SDK (it looks like it's missing from the lately released Windows SDK, which replaces the Platform SDK - we might need this later). It returns a flag to say whether or not the file has OLE properties attached to it. This is only really relevant for structured storage files (like Word documents), so we will probably always return 0 here.

The remaining methods are called in a loop. GetChunk is called to continue parsing the file until it finds the next interesting "chunk", and it returns what it's found in the STAT_CHUNK parameter. This structure is rather busy, so we'll just look at the edited highlights; there's a chunk type - text or value. A text chunk is the main content, the body of the document. If it's one of those, GetText is called, and the text is returned back in a Unicode buffer. If it's a value chunk, the STAT_CHUNK will have a FULLPROPSPEC member which will contain a property set id and a property index. The property set id is a GUID which describes a set of properties, like a category. The index is just an integer value that represents a property within the property set. An example of a FULLPROPSPEC is the PSGUID_STORAGE property set and the PID_STG_SIZE index. No prizes for guessing what this represents. The value of the property is returned as a PROPVARIANT in the call to GetValue - this allows data types other than strings to be returned, such as dates and numbers. Both GetText and GetValue always work on the current chunk, which means the object has state, which means it's apartment threaded. (I have a feeling we're going to have to take a look at threading soon enough). Once the whole file is parsed, GetChunk returns FILTER_E_END_OF_CHUNKS.

There's actually quite a bit more to this interface than I've just described. Each method has a couple of different return codes, and GetText and GetValue can be called multiple times, depending on the size of the content or the number of properties (e.g. keywords). I don't intend this to be an exhaustive guide to writing an IFilter, just an overview. Pay MSDN a visit and Google is always your friend. And then you need to know what the standard property sets are. You can find these in the Windows SDK (WDS v3) and the Platform SDK (WDS v2) as defines beginning with PSGUID or FMTID - shlguid.h has loads.

And then there's a great big question that especially relates to protocol handlers - what if the item you're trying to parse isn't a document? What if it's a directory?


Windows Desktop Search

Slicing and dicing Explorer

by Matt 9. December 2006 19:31

A little while ago, Long Zheng wrote a post about one of the nice little "experience" points of Windows Vista - a feature he christened "dynamic multi-dimensional scrolling", which is just a fancy way of saying that the tree view of the folders in Windows Explorer automatically scrolls so that the majority of the view isn't whitespace (go see his post for the picture/1000 words type thing).

I like it, and I agree with Long - it's not really a feature, but it does have a good, positive image on the end user's experience with Windows. I'd like to add another: the ubiquitous use of the "sorting/filtering/grouping/stacking drop down task pane from a header in Explorer's list view". (Might not be as fancy, but it's definitely a longer name than Long's.)

XP allowed you to sort items, by date, file type, whatever. You could even group on these attributes. But it was really awkward to set; a menu option buried in a sub menu on the right click. Vista's brought it front and centre, and it's a great way to slice and dice your file views.

One of the simplest yet most effective changes is to make this functionality far more discoverable by keeping the header bar visible at all times - in XP, it was only visible in details mode (which made sorting all the harder).

The feature set it exposes is terrific. It really augments the search functionality with filtering, sorting, grouping and stacking, but that's not my favourite bit. That would be finding it in places I wasn't expecting, the most surprising of which was the add/remove programs dialog. Once you've got more than a few applications installed, that list isn't the most friendly to work with. Being able to sort, group and filter (no stacking, but it's no big loss) all of my applications is brilliant. Looking for that application you just installed that's a pile of rubbish? Just filter the "installed on" date as today.

It just makes it so easy to get at your data.


Obsession With Detail | Vista

AmbientClock. Less is more.

by Matt 7. December 2006 17:58

Now this is just lovely. A prototype for a (physical) desktop clock that wirelessly syncs with Google Calendar to show you your upcoming appointments.

Big deal, huh?

The difference, as ever, is in the details. It's (going to be) made by the people behind the Ambient Orb (you know, the one that's been hacked to show continuous integration build status. There, see. Now you remember). The background colour of the device changes to show that you're free, you've got 10 minutes before an event or you're in the middle of one. Nice.

But the really nice thing is the amount of information it displays on the screen without words. Two icons around the outside of the clock face show you when your work day starts and ends (e.g. 8am - 8pm). A black segment of the clock dial represents an event. And if you enter the location of the event in Google Calendar, the device will use Google Maps to work out how long it will take you to get there and display dots around the dial before the event to show when you should leave.

It's just lovely.

There's an online version, too, not that I've tried it. And there's a gallery of alternative designs to vote on, but none of them have the simplicity of the design on the homepage.


Obsession With Detail

iPods are great

by Matt 5. December 2006 10:29

I don't know why I get surprised when a good song randoms it's way on to my iPod. I mean, it's my iPod. I'm not going to put rubbish on it. Still makes me smile.


Month List


Comment RSS