CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,867

    Re: Regarding assigning a drive letter to a partition

    Quote Originally Posted by fransn
    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.
    Fransn - are these 4 functions a secret? Why can't you just tell him what they are?
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #17
    Join Date
    Jul 2007
    Location
    Pune, INDIA
    Posts
    128

    Re: Regarding assigning a drive letter to a partition

    Well I very well know those 4 functions. But those doesnt solve my problem. coz those 4 functions are in regarding to the drive letters only. And I am looking for somthing that can move my partitions fast as well as efectively.

    And the problem is with the drive letters is that I am mentioning here:

    Suppose I am having 4 drives in my system naming "C,D,E,F,G"
    Now suppose I am moving (E drive to other location and after updating the partition table, windows generate a new drive letter and assign that in place of (E say suppose (L.

    Now programmatically How will I identify Which new drive letter is assigned to my recently moved partition? so that I can change back that to the previous Letter. I have the previous drive letter with me, but not the new one!!!

    This deleting and assigning the old drive letter can be done with "SetVolumeMountPoint","DeleteVolumeMountPoint". But for this I need to identify the new Drive letter.

    Hope you all must have understood my problem!!!!


    Thanks

  3. #18
    Join Date
    Jul 2001
    Location
    Netherlands
    Posts
    751

    Re: Regarding assigning a drive letter to a partition

    You could use QueryDosDevice and GetVolumeNameForVolumeMountPoint to iterate through your partitions until you find the new one and change that back to the old letter.

  4. #19
    Join Date
    Jul 2007
    Location
    Pune, INDIA
    Posts
    128

    Re: Regarding assigning a drive letter to a partition

    could you please elaborate your suggestion.
    See what happens that whenever I moves a partition, a new GUID as well as a new drive letter is generated at : "HKLM\SYSTEM\MountedDevices" . Now how can I find a new GUID with "QueryDosDevice" and "GetVolumeNameForVolumeMountPoint"?

    Should I keep all the guids with me before moving the partition so that to compare after moving the partition?

  5. #20
    Join Date
    Jul 2007
    Location
    Pune, INDIA
    Posts
    128

    Re: Regarding assigning a drive letter to a partition

    Well I know to get the list of current drive letters by using a function"GetLogicalDrives()"

    But it returns the value in the Dword.
    In my case the value its returning is 34780

    This also I know that to identify the drive letters first convert this digit to binary, then starting from the least significant bit towards its left i start reading the values. least significant bit is drive letter A,next to it is B: and so on. 0 represents non existing and 1 represents existing.

    Can anyone can show me how to convery this DWORD value to the assigned drive letters PROGRAMMATICALLY. I am not able to write code for this.

    Thanks

  6. #21
    Join Date
    Jul 2007
    Location
    Pune, INDIA
    Posts
    128

    Re: Regarding assigning a drive letter to a partition

    what my problem is suppose I have 2 hard disk connected in my PC
    They both having 4 partitions each.
    by using the function "GetLogicalDrives" I can get the drive letters of all the partitions. Say suppose C:,D:,E:,F:,G:,H:,I:,J:.
    Now the problem is how I am going to identify which drive letters belongs to which Hard drive?
    If I just want to have the drive letters of the "PhysicalDrive0" how I am going to differentiate. Is there any function through which I can get the Disk number from drive letters???

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured