LicenseManager.UsageMode
DOES work, but that's not what it's for.
Try this:
System.Diagnostics.Process process = System.Diagnostics.Process.GetCurrentProcess();
bool res = process.ProcessName.ToUpper().Contains("VSHOST");
process.Dispose();
Caveat: I don't think this will work for web apps, but I'm not really a web developer, so I have no real interest in finding out.