Drive Names - Please reply
-
Hi Guys, This question I asked earlier, but I could nt continue, I want to make it clear, Is there any API by which we can know the local drives of our system ( A:, C:, D: etc )? Please do reply guys. Thanks in Advance Velayudhan
-
Hi Guys, This question I asked earlier, but I could nt continue, I want to make it clear, Is there any API by which we can know the local drives of our system ( A:, C:, D: etc )? Please do reply guys. Thanks in Advance Velayudhan
velayudhan_raj wrote:
This question I asked earlier, but I could nt continue, I want to make it clear, Is there any API by which we can know the local drives of our system ( A:, C:, D: etc )? Please do reply guys.
GetLogicalDriveStrings();
Nibu thomas A Developer Programming tips[^] My site[^]
-
velayudhan_raj wrote:
This question I asked earlier, but I could nt continue, I want to make it clear, Is there any API by which we can know the local drives of our system ( A:, C:, D: etc )? Please do reply guys.
GetLogicalDriveStrings();
Nibu thomas A Developer Programming tips[^] My site[^]
It is not completely successful. It is just returning a single drive's name Actually I want all the name's of all drives in my system. Thanks in Advance Velayudhan
-
It is not completely successful. It is just returning a single drive's name Actually I want all the name's of all drives in my system. Thanks in Advance Velayudhan
velayudhan_raj wrote:
It is not completely successful. It is just returning a single drive's name Actually I want all the name's of all drives in my system.
You should first read the documentation carefully :) Quote from MSDN... lpBuffer [out] Pointer to a buffer that receives a series of null-terminated strings, one for each valid drive in the system, that end with a second null character. The following example shows the buffer contents with representing the terminating null character. c:\d:\ End quote... I guess you are trying to assign to a string which terminates where it finds a null character, hence you are not able to get the whole drives.
Nibu thomas A Developer Programming tips[^] My site[^]
-
It is not completely successful. It is just returning a single drive's name Actually I want all the name's of all drives in my system. Thanks in Advance Velayudhan
Dear Velayudhan, I am Listing in LisBox, u can display it in any control. Here is the Code..... unsigned long driveList = GetLogicalDrives(); char drivePathName[] = " :\\"; CString drive; for(int i = 1;i<26; i++) //u can give no of drives in your system { if(0x01 & (driveList >> i)) { drivePathName[0] = 'A' + i; drive.Format("%c",drivePathName[0]); m_List.AddString(drive); } }
With Best Regards Vidya S/W Developer, AnnetSite,Mumbai
-
It is not completely successful. It is just returning a single drive's name Actually I want all the name's of all drives in my system. Thanks in Advance Velayudhan
How to use this function
char *m_Name=new char[256]; DWORD Lenght=255; GetLogicalDriveStrings(Lenght,m_Name); ... ...
-- modified at 10:25 Wednesday 6th September, 2006_**
**_
WhiteSky
-
How to use this function
char *m_Name=new char[256]; DWORD Lenght=255; GetLogicalDriveStrings(Lenght,m_Name); ... ...
-- modified at 10:25 Wednesday 6th September, 2006_**
**_
WhiteSky
WhiteSky wrote:
How to use this file
What file?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
-
It is not completely successful. It is just returning a single drive's name Actually I want all the name's of all drives in my system. Thanks in Advance Velayudhan
Each drive letter is separated by a
nul
character. Try:char szDrives[105] = {0};
GetLogicalDriveStrings(sizeof(szDrives), szDrives);char *pToken = szDrives;
while (*pToken != '\0')
{
cout << pToken << endl;
pToken += 4;
}
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
-
WhiteSky wrote:
How to use this file
What file?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
:-O function
_**
**_
WhiteSky
-
:-O function
_**
**_
WhiteSky
Fair enough. But the OP already knew how to use the function. He was troubling parsing the resulting buffer.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb