Widgets Windows 7


I dream in code

About the author

Robert Williams is an internet application developer for the Salem Web Network.
E-mail me Send mail
Go Daddy Deal of the Week: 30% off your order at! Offer expires 11/6/12

Recent comments




Code Project Associate Logo


The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

'No device drivers found' during Windows 7 installation on Mac using Bootcamp

Apple provides some tools along with detailed step by step guides to help you install Windows for a dual boot setup on your Mac, but even if you follow them completely, you may find yourself stuck (as I was) very early in the process because the Windows Setup program can't find the drivers it needs to continue, even though they were so carefully prepared by the Bootcamp assistant. I tried preparing my bootable USB drive with 3 separate Windows 7 x64 ISO files, and could never get past this 'No Device Drivers found' error. In retrospect this could have been because the only USB stick I had that was big enough was a USB 3.0 stick and the USB 3.0 drivers needed to access it were on the stick, so in true Chicken and egg fashion Windows setup needed the drivers in order to find the drivers... So using a USB 2.0 stick might have resolved my issue.

However, while I didn't think of that at the time, I was still able to get Windows up and running: By inserting the original Windows 7 install DVD, rebooting the mac, holding down the option key to boot from the windows disc I was able to install Windows successfully. Of course, most of the hardware wasn't working due to missing drivers, so after windows setup completed, I returned to my Windows PC and burned the entire contents of that USB stick to a DVD-R. Inserting that disc I was finally able to run the Bootcamp setup that had been so lovingly prepared by Apple, and installed all of the drivers I needed to make Windows actually work.

Making the DVD-r bootable would have been even better, but since I'd already installed Windows by that point I didn't need to. (I used a $25 external USB 2.0 optical drive, since my Macbook Pro didn't come with an one).

Good luck!

Categories: Windows | Windows 7
Posted by Williarob on Thursday, April 03, 2014 11:04 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Prevent Skype calls from adjusting the volume of other applications


You are listening to music and receive a skype call. You pause the music, take the call and after you hang up you restart your music only to find that the volume has been turned way down and only closing the app (be it Winamp, Windows Media Player, Media Player Classic, etc,) and restarting it can the volume be restored.


Control Panel > Sound > Communications > Select "Do Nothing"


By default, Windows 7 will automatically reduce the volume of other applications by 80% when a skype (or other) call is detected, but it often fails to restore the volume when the call is completed.

Posted by Williarob on Tuesday, December 14, 2010 12:22 PM
Permalink | Comments (0) | Post RSSRSS comment feed

ISO to USB Flash Drive

If you have a laptop or a mini computer without a cd/dvd-rom drive, or your CD/DVD-ROM drive simply broke but you need to use a bootable cd, you can substitute a USB flash memory stick or pen drive in its place. Obviously, if you don't already have an ISO image of your disc, you will need to use another computer that has a functioning CD/DVD-ROM drive to create one. To do this, use some sort of CD Burning software such as Slysoft CloneCD, Nero Burning Rom, etc. to create your ISO image. Then all you need to do download a tool like UNetbootin or BootMyIso and follow the onscreen instructions to make your bootable Flash drive. These tools were designed to create Live versions of Linux, but they do work equally well with any bootable ISO image such as your Windows operating system disk, or Symantec Ghost Recovery disc. Just to be clear, they will not make Windows run live from a USB stick in the same way you can run Ubuntu from a flash drive, but they will allow you to boot your PC into the setup screens required to install Windows on your system in just the same way you could with the original CD and an optical drive.

Posted by Williarob on Monday, March 22, 2010 9:43 AM
Permalink | Comments (0) | Post RSSRSS comment feed

How to get the length (duration) of a media File in C# on Windows 7

If you have ever looked at a media file (audio or video) in the explorer window on a Windows 7 PC, you may have noticed that it displays additional information about that media file that previous versions of Windows didn't seem to have access to, for example the length/duration of a Quicktime Movie Clip:


Even right clicking the file and choosing Properties > Details does not give me this information on my Vista Ultimate PC. Of course, now that Windows has the ability to fetch this information, so do we as developers, through the Windows API (The DLL to Import by the way is "propsys.dll"):

















        [DllImport("propsys.dll", CharSet = CharSet.Unicode, SetLastError = true)]

        internal static extern int PSGetNameFromPropertyKey(

            ref PropertyKey propkey,

            [Out, MarshalAs(UnmanagedType.LPWStr)] out string ppszCanonicalName



        [DllImport("propsys.dll", CharSet = CharSet.Unicode, SetLastError = true)]

        internal static extern HRESULT PSGetPropertyDescription(

            ref PropertyKey propkey,

            ref Guid riid,

            [Out, MarshalAs(UnmanagedType.Interface)] out IPropertyDescription ppv



        [DllImport("propsys.dll", CharSet = CharSet.Unicode, SetLastError = true)]

        internal static extern int PSGetPropertyKeyFromName(

            [In, MarshalAs(UnmanagedType.LPWStr)] string pszCanonicalName,

            out PropertyKey propkey


However, before you rush off to play with these, you may be interested to know that Microsoft has created a great Library that showcases this and many of the other new API features of Windows 7. It's called the WindowsAPICodePack and you can get it here.

If you open the WindowsAPICodePack Solution and compile the Shell Project, it creates a nice wrapper around all the neat new system properties available through propsys.dll. Adding a reference to WindowsAPICodePack.dll and WindowsAPICodePack.Shell.dll in a console application will allow you to get the duration of just about any media file that Windows recognizes. (Of course the more codec packs you install, the more types it will recognize, I recommend The Combined Community Codec Pack to maximize your range of playable files.)

Here is a simple example showing how to get the duration of a media file in C# using this library:

namespace ConsoleApplication1


    using System;


    using Microsoft.WindowsAPICodePack.Shell;


    class Program


        static void Main(string[] args)


            if(args.Length < 1)


                Console.WriteLine("Usage: ConsoleApplication1.exe [Filename to test]");




            string file = args[0];

            ShellFile so = ShellFile.FromFilePath(file);

            double nanoseconds;

            double.TryParse(so.Properties.System.Media.Duration.Value.ToString(), out nanoseconds);

            Console.WriteLine("NanaoSeconds: {0}", nanoseconds);

            if (nanoseconds > 0)


                double seconds = Convert100NanosecondsToMilliseconds(nanoseconds) / 1000;





        public static double Convert100NanosecondsToMilliseconds(double nanoseconds)


            // One million nanoseconds in 1 millisecond, but we are passing in 100ns units...

            return nanoseconds * 0.0001;




As you can see, the System.Media.Duration Property returns a value in 100ns units so some simple math will turn it into seconds. Download the Test Project which includes the prebuilt WindowsAPICodePack.dll and WindowsAPICodePack.Shell.dll files in the bin folder: (218.76 kb)

For the curious, I tested this on Windows XP and as you'd expect, it didn't work:

Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'propsys.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

On Vista Ultimate SP2, it still didn't work - nanoseconds was always 0, though it didn't throw any exceptions.

For the older systems I guess we are limited to using the old MCI (Media Control Interface) API:

        using System.Runtime.InteropServices;



        public static extern int mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwndCallback);



        private static extern int mciGetErrorString(int l1, StringBuilder s1, int l2);


        private void FindLength(string file)


            string cmd = "open " + file + " alias voice1";

            StringBuilder mssg = new StringBuilder(255);

            int h = mciSendString(cmd, null, 0, 0);

            int i = mciSendString("set voice1 time format ms", null, 0, 0);

            int j = mciSendString("status voice1 length", mssg, mssg.Capacity, 0);



Which works fine for .mp3 and .avi and other formats that play natively in Windows Media Player, but even with a codec pack installed, it doesn't work on Quicktime or .mp4 files, where the new Windows 7 API did.

Categories: C# | CodeProject | Windows | Windows 7
Posted by Williarob on Wednesday, October 21, 2009 12:14 PM
Permalink | Comments (0) | Post RSSRSS comment feed