<p>Let's say I've got a website that works better if a client has installed and logged into a desktop application.  I'd like to be able to do 2 things:</p>

<ul>
<li>Alter the website if they haven't installed the app (to make it easy for them to find a link to the installer)</li>
<li>If they've installed the app on a couple of machines, determine which machine they are browsing from</li>
</ul>

<p>I'd like something that works on Windows and OSX, on any of the major browsers.  Linux is a bonus.  </p>

<p>A few thoughts:</p>

<ul>
<li>Websites can detect if you've got Flash installed.  How does that work and could it be used for both of my goals?  </li>
<li>Could I just let the client serve HTTP on localhost and do some javascript requests to fetch a local ID?  I know google desktop search did something like this at one point.  Is this a standard practice?  </li>
</ul>

<p>Thanks!</p>

You can have a browser plugin (activex for IE or Netscape plugin for the rest of the browsers) that can communicate with the application. When the webpage is loaded, it can try to instantiate the plugin and if it succeeded, it can use it as a proxy to the application. If it fails, then either the app is not installed or the plugin was explictly disabled by the user. Either way, your website should degrade its functionality accordingly.
Update
: Forgot to answer your questions:
Flash does it exactly this way. Flash is a browser plugin that is created by the web pages.
You can have a machine ID generated at the application/plugin install time and your plugin can pass that machine ID to the webpage when it is created.
On the topic of using local webserver
:
I would stay away from having a local webserver, mainly because of security considerations. It takes quite a lot of work to make sure your local webserver is locked down sufficiently and there are no XSS vulnerabilities that other malicious websites can exploit to make it do stuff on their behalf.
Plus, having a webserver means that either it has to run as a system-wide process, or if it runs as the user, you can have the website interact with only one user's instance of the application, even though multiple users can be logged on and running it at the same time.
Google Desktop Search suffered from both the XSS security vulnerability (though they fixed it) and the limitation of only one user being able to use it on a machine (I don't know if they fixed this one yet, though chances are they did).