Just got back from the store with your shiny new external hard drive, or you just tackled the UPS guy to rip open your brand new backup solution… you plug it in to your awesome Windows 7 box and!….
If you’re like me, it probably doesn’t detect your drive and you start cursing at your cat, flailing wildly and vowing to never buy another *insert manufacturer here*’s product again!
well calm down.. I have the solution!
If you don’t like to read, here is the entire project available for download:
|Download the Project Files||Download Setup Files|
If you want to see how it works, here you go:
I knew I was going to need to utilize the Windows API to be able to interact with Device Manager, so, being not so API-inclined, I turned to my friends over on www.vbforums.com where Chris128 so graciously provided the API declarations and test code.
First, open a new project and add a new Class file to the project. Name it “WindowsApi.vb”.
In it will be the following API code:
Public Class WindowsApi System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential) _ Public Structure SP_DEVINFO_DATA Public cbSize As UInt32 Public ClassGuid As Guid Public DevInst As UInt32 Public Reserved As IntPtr End Structure Public Const CM_LOCATE_DEVNODE_NORMAL As UInt64 = 0 Public Const CR_SUCCESS As Integer = 0 Public Const CM_REENUMERATE_NORMAL As UInt64 = 0 System.Runtime.InteropServices.DllImportAttribute(Cfgmgr32.dll, EntryPoint:=CM_Reenumerate_DevNode) _ Public Shared Function CM_Reenumerate_DevNode(ByVal dnDevInst As UInt32, ByVal ulFlags As UInt64) As Integer End Function System.Runtime.InteropServices.DllImportAttribute(Cfgmgr32.dll, EntryPoint:=CM_Locate_DevNode) _ Public Shared Function CM_Locate_DevNode(ByRef PdnDevInst As UInt32, ByVal pDeviceID As Integer, ByVal ulFlags As UInt64) As Integer End Function End Class
I have added a button that lets me launch “My Computer” once it’s found, merely for convenience sake.
Here is a screenshot of the small UI that I came up with:
Get creative with it! I know this was a very annoying issue for myself, and if it’s a bug in Windows 7, hopefully it will be patched soon. But until that day comes, hopefully this will relieve a bit of the frustration!