Windows 7

Bluetooth Service Connector

Posted in Bluetooth, Software, Windows 7 on October 20th, 2011 by Mr. Bungle – Be the first to comment

Bluetooth is still a relatively new technology when it comes to Windows. Although Windows 7 now has a reasonably decent bluetooth stack baked-in, it’s certainly not bug-free. It is not straightforward to control connection of bluetooth services, such as AudioSink, HeadSet, RemoteControl etc. And depending on how ‘dumb’ your bluetooth device is, your only option to get it connected to Windows in some cases (e.g. your device was last connected to a different host, such as your phone) is to completely uninstall and re-discover the device, as discussed on this thread. Weeeak.

I’ve written a small utility that may help with issue (it works for me, but I’ve only tested on my own bluetooth headphones – Sony DR-BT50). It works in conjunction with another utility I recently posted (that allows a program to set the default audio device), and provides control over connecting / disconnecting the available bluetooth services for all your paired bluetooth devices in Windows. It also provides a shortcut specifically for bluetooth audio devices which automates the process of getting a frustratingly silent pair of headphones / speaker to spring into life with a single click.

Download the utility here. I hope it works for you!

Setting default audio device in Windows

Posted in Programming, Software, Windows 7 on October 17th, 2011 by Mr. Bungle – 5 Comments

Since the audio revamp in Windows Vista, many things that were possible to do in code in the past (i.e. XP) are now difficult or impossible. One of those tasks that was easy in XP was setting the default audio device for playback. In XP this just required a registry change, but in Vista & Windows 7, Microsoft decided that developers should not have access to change the default audio device, so they locked down the registry and provided no documented API to achieve this. Their reasoning was that if two programs both wanted to set the default audio device, they would end up fighting each other for it, which of course is bad. But I believe this is a very short-sighted decision, since there are plenty of legitimate cases where a program needs to do this. These are discussed on this amazingly long-living thread (started in 2006 and still going).

The end result is that, no thanks to Microsoft, we finally have a way to do this, and I’ve created a console application in case others would like to control this as well:

Usage: SetDefaultAudioDevice.exe [deviceID] [role]
Where:
[deviceID] is a GUID including braces
[role] is either ‘console’, ‘multimedia’ or ‘communications’.

Example: SetDefaultAudioDevice {24dfc80a-680f-4748-8627-c340cb14f187} multimedia

Your audio device IDs can be found in the registry under HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\MMDevices\Audio\Render.

Feel free to download this utility here, source code is in my SVN repo.

Thank-you to EreTIk and Jonny Best and everyone else on the above forum post!

Error when opening Word documents

Posted in Software, Windows 7 on June 15th, 2011 by Mr. Bungle – Be the first to comment

OS: Windows 7 64-bit
Office: 2010 Premium

When double-clicking a .doc/x file in Windows Explorer, or launching it via a different explorer, such as FreeCommander, you may see this error message:

Many, many people have seen this issue. I tried several solution, including deleting the word Data key, as recommended by Microsoft, checking that ‘Run this program as an administrator’ is not checked and renaming normal.dotm, but all failed to fix the error. Finally, here’s what fixed it for me:

  1. Right-click a .doc/x file -> Open With -> Choose program
  2. Select Word 2007 and hit OK.

After doing that, I could open word documents from outside word successfully.

Interop.ComAdmin exception when using IIS on a 64-bit OS

Posted in Networking, Programming, Windows 7 on May 25th, 2011 by Mr. Bungle – Be the first to comment

If you install IIS on a 64-bit operating system, you may get the following error when navigating to your website locally:

Could not load file or assembly ‘Interop.COMAdmin’ or one of its dependencies. An attempt was made to load a program with an incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.BadImageFormatException: Could not load file or assembly ‘Interop.COMAdmin’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

The clue here is the BadImageFormatException, which hints that this is a 32/64 bit issue. To fix it, in IIS Services Manager, go to Application Pools, select the application pool under which your website/application is running, and choose ‘Advanced Settings’. Change ‘Enable 32-bit Applications’ from False (the default) to True. Recycle your app pool, and reload your browser page, no more error!

PicasaPhotoViewer.exe staying in memory

Posted in Programming, Software, Windows 7 on May 3rd, 2011 by Mr. Bungle – 2 Comments

Google’s Picasa Photo Viewer is one of the best photo preview applications, it loads quickly, and is easy to exit. Unfortunately, Google introduced a bug recently that causes the PicasaPhotoViewer.exe process to remain in memory even after you close the application. Several posts on google forums and elsewhere have reported this:

Why does PicasaPhotoViewer.exe stay resident in memory
Multiple picasaphotoviewer.exe ghosts in Task Manager
Memory Loss from orphaned PhotoViewer Processes
PicasaPhotoViewer Process Doesn’t Terminate

This appears to only occur when you open a photo on a network location, such as a network drive. This is a pretty normal usage scenario, such as storage of photos on a RAID server or NAS, and is actually pretty nasty, because it means you can’t rename/delete/move any directory in which you viewed an image including any parent directory (due to the still-running PicasaPhotoViewer.exe locking the directory). It doesn’t take long for this to get seriously annoying when you find yourself having to open Process Explorer/Task Manager to kill off all the orphaned PicasaPhotoViewer.exe processes when you are working with directories.

Orphaned PicasaPhotoViewer.exe processes.

Until Google fixes this, I solved this with a small C# application. It monitors for orphaned instances of PicasaPhotoViewer.exe (i.e. those that are running but have no window) and kills them. This is the complete code:

static void Main(string[] args)
{
   while (true)
   {
      var picasaProcesses =
         (from p in Process.GetProcessesByName("PicasaPhotoViewer")
          where p.MainWindowHandle == IntPtr.Zero && !p.HasExited
          select p);

      foreach (var process in picasaProcesses)
      {
         process.WaitForInputIdle();
         if (process.MainWindowHandle == IntPtr.Zero)
         {
            process.Kill();
            process.WaitForExit();
         }
      }

      Thread.Sleep(1000);
   }
}

Feel free to download the utility, and launch it on Windows startup using a logon script such as described here. Note: The program requires admin rights to run, so you can’t just place a shortcut to it in your ‘Startup’ folder if you are using Vista/7 with UAC switched on.

Update: Ok, it appears this issue has been fixed by Google in Picasa build > 117.38. Updating to the latest version (build 117.43 at the time of writing) fixed the issue for me, so my program should no longer be needed :)

Update 2: According to the comment below, the issue may still be occurring for some people. So I have made the program to fix this available for download again.

A2DP on Windows 7

Posted in Bluetooth, Windows 7 on April 17th, 2011 by Mr. Bungle – Be the first to comment

When I bought a pair of bluetooth stereo headphones, I wanted to make sure they would work on Windows 7, however when I searched for A2DP (Advanced Audio Distribution Profile – the protocol for streaming stereo audio to a bluetooth device), I mostly found posts relating to how A2DP support was missing from Windows 7 RTM.

So when I bought a bluetooth dongle, I went ahead and immediately installed the ancient version of BlueSoleil that came with it. This is an awful piece of software, but it does get your headphones working. However, I started getting random blue-screens which identified BlueSoleil as the culprit. So I investigated my options:

- Install the latest version of BlueSoleil, and provided no further blue-screens occur within the trial period, buy it :(
- Install the Toshiba bluetooth stack, and buy if it does the job.
- Remove all 3rd party bluetooth software and try the Microsoft one.

I tried the toshiba bluetooth stack and the audio randomly cut out every few 1 or 2 seconds. So don’t bother with that.
Not wanting to pay for crap software, and spurred on by seeing mention that an update for A2DP support in Windows 7 was pushed out, I decided to give the Microsoft stack a go. Uninstalled Toshiba and Bluesoleil software, then after re-enabling the ‘Bluetooth Support Service’, my headphones were promptly discovered and connected. Audio quality is perfect (no drop-outs), and no need for any 3rd party software.

So, if you’re using Windows 7, don’t bother with BlueSoleil or Toshiba, stick with the Microsoft bluetooth stack.

‘Bluetooth Settings’ link missing in Windows 7 Control Panel

Posted in Bluetooth, Windows 7 on April 17th, 2011 by Mr. Bungle – 1 Comment

When attempting to add (pair) a new bluetooth device, if no devices are detected it may be that the ‘Bluetooth Support Service‘ is disabled or stopped. Check this by going to:

Start->Run->compmgmt.msc->Services and Applications->Services

Make sure the status for service ‘Bluetooth Support Service’ is ‘Started’ and the startup type is ‘Automatic’. After starting this service, you should now be able to add bluetooth devices to Windows. Starting this service also enables display of the bluetooth settings dialog, which the Windows help points out should be visible in the Control Panel when you search for ‘bluetooth’. Another symptom that this service is not running is that when you right-click the bluetooth system tray icon and choose ‘settings’, nothing happens (i.e. no dialog appears).

To Microsoft: Surely it would have been simple to check whether this service is running before doing bluetooth device discovery or opening the settings dialog, and at least report to the user that they need to start the service (or do it for them ideally) rather than just failing silently.

Muting Bluetooth Headphones

Posted in Bluetooth, Programming, Software, Windows 7 on March 11th, 2011 by Mr. Bungle – 1 Comment

After much research, I recently purchased a pair of Sony BT-50 Bluetooth headphones. They are AWESOME!!!! The only problem is, there’s no way to mute them! In fact, there’s no way to mute any bluetooth headphones except from the ‘mute’ button on the bluetooth device. If you’re listening to music on a PC, volume up/down keys work (from a multimedia keyboard), but not mute. So I’ve written a utility that enables muting of your headphones with a global hotkey, and you can download it for free here.

Note: The program will only work on Windows 7, and you’ll need .Net 4 installed. So you know you’re on the bleeding edge of technology using this. Who knew a feature such as mute was so high-tech :D

The program uses the CoreAudioAPI library by Ray Molenkamp, and the global hotkey class by Max Bolingbroke. They made this possible.

Btw, the BT-50 headphones don’t come with a USB Bluetooth adaptor, so if you want to use with with a PC (as opposed to a bluetooth-enabled phone), you’ll need to purchase one. I’d advise against going with the $1.00 bluetooth adaptors from China (even with free shipping, wtf?), and instead do your research and find an adaptor that has drivers for Windows 7 and A2DP support.

For Aussies, I can confirm that the Dick Smith Bluetooth 100M USB adapter (not listed on the Dick Smith website, but I found them in the Macquarie park store in Sydney) will work with these headphones, after you wrestle a bit with BlueSoliel (worst usability in software I’ve seen in a while – see below for how to automate connection of the Advanced Audio Service). And you’ll need to swap out the American power supply with an Aussie one – again Dick Smith has the goods. Just make sure the polarity is right: The engraving “CEN” on the jack with the yellow tip should be on the positive side of the connector.

Update: To avoid using BlueSoliel every time you switch on your headphones, you can save the connection as a shortcut. It is placed on your desktop without telling you:

Display file diffs from Visual Studio in foreground

Posted in Programming, Software, Windows 7 on October 11th, 2010 by Mr. Bungle – Be the first to comment

A great shortcut for viewing pending changes in Visual Studio is to hold SHIFT and then double-click the file in the Pending Changes window.  Unfortunately there is a bug in Visual Studio that means the resulting diff program’s window (assuming you are using an external diff program) is shown behind the Visual Studio window, requiring you to click it’s icon in the taskbar in order to bring it to the foreground.  This happens about 3 in 4 times, and totally negates the speedup of SHIFT double-clicking.

So I have written a small utility to solve this (until it’s solved in Visual Studio itself), called ActivateDiff, which you can download from here.

Usage

  1. Save ActivateDiff.exe to your computer.
  2. Open Visual Studio->Tools->Options->Source Control->Visual Studio Team Foundation Server->Configure User Tools.
  3. Copy the operation’s command, paste it at start of the arguments field and enclose it in double quotes.
  4. Change the operation’s command to point to ActivateDiff.exe.
  5. Ok-on-out.

Happy diffing!

Starting programs with administrator rights at login

Posted in Windows 7 on June 25th, 2010 by Mr. Bungle – 3 Comments

With the introduction of UAC in Vista, launching a program that requires administrative rights on Windows startup (when you first log in) has become more difficult. One solution that has been doing the rounds is to use the Task Scheduler as a workaround. What a mess! Provided you are not running a 'home' edition of Windows Vista/7, I have found what I believe is the cleanest and easiest way to achieve this (for all users only):

1. Start->Run-> "gpedit.msc"

2. User Configuration->Windows Settings->Scripts (Logon/Logoff)

3. Double-click 'Logon', and add entries for each of the applications you want launched.

Group Policy Logon

The applications you define in here will be launched with administrator rights when anyone logs on without any UAC dialogs being displayed.  

Note: This method cannot be used for specific users, it applies to all users.