Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There is a small bug in Windows that I would like to create a small application as a solution for. So, in my company we have several network drives ( F:\, G:\, H:\, I:\ etc.) and sometimes if I connect an external USB device such as a card reader, windows will assign an already used drive letter. So for example, I have a network drive F:\, and I connect my card reader which windows will also assign F:\ to this device, so I cant use that USB device, until I change it's drive letter.

So my question's are:

  • How can I detect these devices or drive letters when they are assigned twice?
  • How can I detect which one of them is a USB device?
  • How can I reassign a drive letter to that device?

I want to do this in C.


share|improve this question

migrated from Aug 24 '11 at 9:36

This question came from our site for professional and enthusiast programmers.

Admin issue -- redirecting. – pst Aug 24 '11 at 6:04
@pst What do you mean with admin issue? I just want to know how to get those drive letters which are assigned twice. – kampi Aug 24 '11 at 6:18
What pst probably meant is that you can manually change the drive letter assignment. Surely it's quicker to reassign letters yourself than having to write up a program for such an extremely specific situation that you need to test. – In silico Aug 24 '11 at 6:32
@In silico - i know that, but the reason i want to create an application for this is, that a user cannot change it manually becasue they are not administrators, and that's why i want to make an application, so they can change it too. – kampi Aug 24 '11 at 6:36
@In silico: i know that too, but this is my problem. I will use CreateProcessWitLogonW for this, and then the users can use this application too. – kampi Aug 24 '11 at 6:41

most of what you want can be done with FindFirstVolume and its friends (the example here covers everything), to get the type, you would use GetDriveType, then finally SetVolumeMountPoint will rename a device drive letter.

share|improve this answer
SetVolumeLabel will just change the label of the drive not the assigned drive letter. – RedX Aug 24 '11 at 7:02
@RedX: correct, fixed – Necrolis Aug 24 '11 at 7:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .