how to change drive name??

Dec 2, 2011 at 2:10am
I am working on making virtual drive(which is showen like a real drive like local disk). when i run my project, the drive name is always "Local disk".
I want to change it to like "TEST" or something.

I am pretty sure that I can change it cuz windows has this function.

I can change the name manually. right?

Actually, I used SetVolumeLabel('virtual drive letter', 'new drive name") function, but
it failed. I couldn't find any reason.

anyone has any ideas??

Help me. Thanks in advance.
Last edited on Dec 2, 2011 at 3:06am
Dec 2, 2011 at 6:48am
You can set volume label from within windows explorer ? Your virtual file system must support this.
Dec 2, 2011 at 6:15pm
Did you bother to capture the error with GetLastError and figure out what it was?
Dec 4, 2011 at 4:38pm
O dont know what you are talking about because I cant change my drive names, and Im on XP
Dec 6, 2011 at 1:18am
Generally, drive name is set to "Local Disk".
You can change the name manually from within windows explorer. Added, It doesn't matter
what sort of OS you use.

And I posted it "I used SetVolumeLabel function, but it failed." which didn't mean
it has a complie error or run time error.
The function returns 0 or something when it fails to change the VolumeLabel(Drive Name).

I need some method to change it. Thanks :)
Last edited on Dec 6, 2011 at 1:21am
Dec 6, 2011 at 8:56pm
Whenever you are calling SetVolumeLabel() if it returns 0 (failure) immediately call GetLastError() and print out the result:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <windows.h>

int main()
{
  int result = SetVolumeLabel("G:\\","Foobar");
  if(!result)
  {
    DWORD ErrNo = GetLastError();
    LPSTR ErrMsg = 0;
    FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,0,ErrNo,MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),(LPSTR)&ErrMsg,0,0);
    MessageBox(0,ErrMsg,"Last Error Message Received",0);
    LocalFree(ErrMsg);
  }
}


In my case the G: drive doesn't exist so it returned "The system cannot find the path specified"
Dec 7, 2011 at 12:25am
Thanks Texan!!
I got an error msg saying, "not found path".
And I solved the problem. Thanks again.
Topic archived. No new replies allowed.