Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

Thanks.

share|improve this question

migrated from stackoverflow.com 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
show 11 more comments

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.