Archive for November, 2007

Introducing CardSharkV

November 25, 2007 1:06 am

Check out this program I’ve developed, called CardSharkV. It’s a digital picture storage card/camera “downloader” with a twist.

It’s a bit of an experiment, and I’m looking for some real-world “beta” testers. My plan is to try my hand at charging for the program. But to see if word will spread, I’m planning to give out 50 or so licenses without charge while I work out any kinks that might be in the program.

If you’re interested in trying it out, download the program, install and run it, and then click the “Request License” button.

Read more about it on the CardSharkV page.

Update (2007-11-25): CardSharkV depends on the .NET Framework 3.0. It’s thus meant to be installed on Vista systems only. If you have XP and the .NET Framework 3.0, it should still work. Also, since I posted the whole thing Saturday night after a whole day of re-shaping my first, never published version, I didn’t test the install too well. I’ve since had a little time to test and found some issues, especially with the license mechanism. I’ve posted version to correct those issues and to improve the installer as well.

Microsoft deprecates support for XBAP WPF apps in version 5.3 of the Media Center SDK

November 19, 2007 10:02 pm

I downloaded and installed the latest version of the Media Center SDK just now, and was a bit surprised to see that WPF apps are now officially deprecated as a supported way of extending Windows Media Center on Vista. There’s no big announcement around this so far, it’s almost just a footnote in the “What’s New” section:

Deprecated features

The following features have been deprecated:

  • Hosting for Microsoft .NET Framework 3.0 Extensible Application Markup Language (XAML) browser applications (XBAPs).
  • The Triple-tap/Soft-keyboard ActiveX control for hosted HTML applications.
  • Support for using alternative shells to run and host HTML applications.

The reason I’m surprised is that Microsoft announced the support for WPF based extensibility apps at PDC05 with some fanfare.

I guess interest among developers just hasn’t been there for WPF-based Media Center apps, and Microsoft needs to make judgment calls on where to invest in their extensibility platform. The rest of the deprecated features seem to have been made for the same reason: limited interest among developers for these features. In addition I think there might be issues of an architectural nature that just make the three things that got dropped too expensive to maintain or improve.

I’m sad about this development, mostly because I still don’t see a great set of development and design tools around for MCML. WPF seems to me to have a whole lot more momentum than MCML (WPF has the Expression suite of tools and has been billed as the “GDI for the next 20 years”), but who knows what may be coming for Windows 7, or even an earlier interim update for Media Center?

How to parse "special" .lnk files, aka. MSI shortcuts aka. Windows Installer advertised shortcuts using C#

9:21 pm

[Update 2012-02-04: Jonathan pointed out a few additional things in the comments.]

[Update 2010-01-20: It looks like the calls to MsiGetShortcutTarget() and MsiGetComponentPath() only work correctly on Windows 7 if you make them from a thread that has STA apartment state. So if you do a lengthy operation like iterating through the entire Start menu on a background thread, make sure to use the Thread class for that (remember to call SetApartmentState() before kicking it off) and not BackgroundWorker. BackgroundWorker threads are taken from a thread pool and are always MTA (they can't be forced to STA in any way). Thanks to the folks on stackoverflow for discussing and figuring this out, especially Arnout.]

This is a problem that’s been bugging me for about a year and I finally found time to dig in and work on how to solve it. A big thank you goes to Aaron Stebner for pointing me in the right direction. Thanks Aaron!

Anyway, for various reasons I’ve wanted to display a list of applications the user has installed on the computer. Getting at the All Programs folder in the Start Menu is not too big a problem. You can get parts of it via Environment.GetFolderPath(SpecialFolder.Programs) and other parts of it (for all users) via a bunch of P/Invoke incantations that I’m not going into here. Iterating through all subfolders and picking out the .lnk files is not a problem either.

What is a problem (at least it was for me) is what to do with those .lnk files that you can’t get parsed correctly via WshShell.CreateShortcutFile() after adding a reference to the Windows Script Host Object Model to your project. The .TargetPath will usually return something down in a C:\Windows\Installer\{GUID} directory.

I had noticed that the Windows Installer XML 3.0 project creates shortcuts like that, and since Aaron is involved in that project, I asked him about it. He graciously told me that those shortcuts are “advertised” shortcuts, a kind of Windows Installer shortcut that enables putting a link in the Start Menu (or elsewhere) while not necessarily installing the whole product that the link points to. So I started digging in with Google. A CodeProject article contained a comment about two functions that can be used in combination to find the real target of and advertised shortcut: MsiGetShortcutTarget() and MsiGetComponentPath(). After some more digging, I had P/Invoke declarations for both of these from this SourceForge project.

I ended up with this bit of code, which I use first on any shortcut file I need to interpret; then if it returns null, I use the WshShell way instead.

public static string ParseShortcut(string file) { 
 StringBuilder product = new StringBuilder(MaxGuidLength +1);
 StringBuilder feature = new StringBuilder(MaxFeatureLength +1);
 StringBuilder component = new StringBuilder(MaxGuidLength +1);
 MsiGetShortcutTarget(file, product, feature, component);
 int pathLength = MaxPathLength;
 StringBuilder path = new StringBuilder(pathLength);
 InstallState installState = MsiGetComponentPath( product.ToString(), component.ToString(), path, ref pathLength);
 if (installState == InstallState.Local) 
 return path.ToString();
 return null;

If you’re interested, you can download the class with the rest of the needed declarations.

Get Satisfied: How Twenty People Like You Found the Satisfaction of Enough – a short review

November 11, 2007 12:28 am

I got my copy of “Get Satisfied” this Tuesday night. I began reading it Friday night and found it very interesting. There are stories from every part of the country, written by people from, it seems, every walk of life. I finished it this evening.

The one story that made the book worth reading for me, was Erik Richardson’s story “The Economics of Time”. He lays out how lessons of economics, such as scarcity, opportunity cost, diminishing marginal utility, depreciating assets and investment versus consumption relate to the ideas of simple(r) living. Here’s just one paragraph from it:

By spending your time – from the declining bank account – on something other than just making more money, or getting more “stuff”, which translates into the same thing, you are investing in an asset that is becoming more and more scarce every year. That’s the very essence of a good, profit-maximizing investment. We don’t need to switch to some different way of thinking; we just need to do a better job of following through on the type of thinking that’s already built into our modern way of life.

I really appreciate how he ties together traditional economic principles with the principles of simpler living. It’s probably the best argument for simple living I’ve read. I wish I had come up with it myself.

If you have the slightest bit of interest in these kinds of ideas, I recommend to you to read this book. It’s published by Easton Studio Press for Simple Living America, and the companion website is