[RESOLVED] Regarding assigning a drive letter to a partition
Hi all,
Do anyone is having any idea how to use DefineDosDevice in regarding drive letter assignment. My main purpose is to first delete the existing drive letter of a partition then assign my own drive letter without restarting in windows Vista.
Please guide me if anybody have any idea.
Re: Regarding assigning a drive letter to a partition
This zip file is having just an exe file. What does this do? I am looking for some coding help through which I can delete the existing drive letter of a partition and assign it a new one.
actually what happening, when I am moving the partitions of the hard drive from one location to the other, to bring the unallocated space in the end of the disk the partition becomes unaccessible. And when I successfully moves that the windows doesnt recognize the moved partition and the partition stops working, but as soon as I open the "diskmgmt.msc" windows assign a new drive letter to that moved partition and it starts working normally.
Re: Regarding assigning a drive letter to a partition
Originally Posted by mayank_3103
actually what happening, when I am moving the partitions of the hard drive from one location to the other, to bring the unallocated space in the end of the disk the partition becomes unaccessible. And when I successfully moves that the windows doesnt recognize the moved partition and the partition stops working, but as soon as I open the "diskmgmt.msc" windows assign a new drive letter to that moved partition and it starts working normally.
Is there any solution to my problem??
There is ALOT more involved there than assigning the letter.
I am VERY curious as to any use-case where something like this needs to be done on any type of regular basis, such that using the provided GUI (or command line) tools is insufficient....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!) 2008, 2009,2010 In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Re: Regarding assigning a drive letter to a partition
Please can you tell me why it happens that only when I open the disk management service the window assigns the new drive letter to that partition otherwise it dont even recognize that?
Is there any alternate way to move my partition without losing the drive letter, well I am using "ReadFile"&"WriteFile" SDK functions to relocate my partitions.
Please help with some guidelines.
Thanks.
Last edited by mayank_3103; July 15th, 2008 at 06:17 AM.
Re: Regarding assigning a drive letter to a partition
Originally Posted by mayank_3103
when I am moving the partitions of the hard drive from one location to the other, to bring the unallocated space in the end of the disk the partition becomes unaccessible. And when I successfully moves that the windows doesnt recognize the moved partition and the partition stops working, but as soon as I open the "diskmgmt.msc" windows assign a new drive letter to that moved partition and it starts working normally.
Is there any solution to my problem??
First of all, I think you need to reassure us that you know what you're doing and that you have a VERY good reason for doing it - because I fear that you're making the (all too common) mistake of assuming that your program is more important than everybody else's.
Suppose that some other programs have files open on those partitions and you unexpectedly start moving them around and changing their drive letters? How are the other programs expected to know what's going on?
Windows is a co-operative multitasking OS (note: 'co-operative' not 'dog-eat-dog'). A big part of being co-operative is that you don't do things that are going to screw up every other running program. In fact, it's doubtful that Windows will let you change the drive letters anyway. The best you can probably hope for is that the letter will get changed at next boot-up.
But even that is inherently unsafe. Suppose that some other programs have saved vital path information in the registry or in a config file. Is your program going to go around helpfully updating all that information or will you just be leaving those other apps to fend for themselves?
"A problem well stated is a problem half solved.” - Charles F. Kettering
Re: Regarding assigning a drive letter to a partition
It's easy to do.
I wrote a program (of which I posted the exe here) that did just this, using those drive API's. Worked like a charm and Microsoft in Redmond bought a license.
The only thing you need to watch out for is you don't swap the systemdrive.
Unfortunately I am not permitted to share the code with you.
All I can say is you're on the right track with DefineDosDevice and related API's.
Re: Regarding assigning a drive letter to a partition
No-one's saying it's not easy - but the fact that it's easy to do doesn't make it safe to do, nor sensible. The vast majority of Windows programs will have been written with the assumption that a drive letter, once assigned, will remain constant. Therefore, as TheCPUWizard stated earler, it's very difficult to think of a justifiable reason why an app should need to do something like this - especially in view of the havoc that it's likely to cause for everything else.
"A problem well stated is a problem half solved.” - Charles F. Kettering
Re: Regarding assigning a drive letter to a partition
Ya, the reason for doing this that I am working on a project of Disk partitioning, there I need to shrink, extend and move partitions. Everything else is working fine except move.
After moving the partitions windows doesnt recognize the partition until i dont open the disk management utility. I dont have any open files.
I just want to know that is this happening? is there any function here through which windows can recognize my moved partition??
Re: Regarding assigning a drive letter to a partition
Originally Posted by fransn
Justifiable reasons? network administrators want this kind of functionality.
Ah - that makes some snese.... in my experience, the sworn aim of every network administrator is to cripple everyone's PC to the maximum extent possible..!
"A problem well stated is a problem half solved.” - Charles F. Kettering
Re: Regarding assigning a drive letter to a partition
Hey Guys if you have any confusion regarding my problem then please let me know.
I have nothing to do with the system drive. I am relocating the other partitions. Do you have any idea or technique of moving partitions apart from ReadFile and WriteFile functions.
Or is there any technique of opening this "diskmgmt.msc" service at the background of my application just for 2 sec. But it shld not be visible to the user.
Re: Regarding assigning a drive letter to a partition
Thanks fransn,
I understand that you cant share the code but can you please give any idea regarding the API's which I can use. Is there any fast and effective method to move partition to other place at cluster level apart from writeFile() function?
Re: Regarding assigning a drive letter to a partition
I already told you you are on the right track with DefineDosDevice.
There are 4 other functions that you will need that are part of the same API as DefineDosDevice. Writefile is not one of them.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.