🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
5 messages
5 total messages Started by hpl Sun, 04 May 2003 15:44
Problem with GetVolumeInformation
#16662
Author: hpl
Date: Sun, 04 May 2003 15:44
17 lines
1353 bytes
Hi folks,

I do have a problem with the win32-function GetVolumeInformation. With the
following line I try to get the VolumeLabel from my CD-ROM D:-Drive;
char vlabel [32]; //* buffer for VolumeLabel
unsigned int vlabellength;
GetVolumeLabel ("D:\\", vlabel, vlabellength, NULL, NULL, NULL,NULL)

Nevertheless I always get
a) nonsens in vlabel and
b) a totally irrelevant length of the buffer vlabel?

What is going wrong here?

Thanks in advance.

hpl
Re: Problem with GetVolumeInformation
#16664
Author: Sam Mildener
Date: Sun, 04 May 2003 17:52
23 lines
1665 bytes
hpl wrote:
> Hi folks,
>
> I do have a problem with the win32-function GetVolumeInformation.
> With the following line I try to get the VolumeLabel from my CD-ROM
> D:-Drive;
> char vlabel [32]; //* buffer for VolumeLabel
> unsigned int vlabellength;
> GetVolumeLabel ("D:\\", vlabel, vlabellength, NULL, NULL, NULL,NULL)
>
> Nevertheless I always get
> a) nonsens in vlabel and
> b) a totally irrelevant length of the buffer vlabel?
>
> What is going wrong here?

Missing ampersand:

GetVolumeLabel ("D:\\", vlabel, &vlabellength, NULL, NULL, NULL,NULL)

--

Sam Mildener
Re: Problem with GetVolumeInformation
#16665
Author: Sam Mildener
Date: Sun, 04 May 2003 18:00
27 lines
1844 bytes
hpl wrote:
> Hi folks,
>
> I do have a problem with the win32-function GetVolumeInformation.
> With the following line I try to get the VolumeLabel from my CD-ROM
> D:-Drive;
> char vlabel [32]; //* buffer for VolumeLabel
> unsigned int vlabellength;
> GetVolumeLabel ("D:\\", vlabel, vlabellength, NULL, NULL, NULL,NULL)
>
> Nevertheless I always get
> a) nonsens in vlabel and
> b) a totally irrelevant length of the buffer vlabel?
>
> What is going wrong here?

Please ignore my previous message (I was confusing GetVolumeLabel with
something else).

Here's the modification needed:

unsigned int vlabellength=32;


--

Sam Mildener
Re: Problem with GetVolumeInformation
#16666
Author: Remy Lebeau (TeamB)
Date: Sun, 04 May 2003 19:48
30 lines
1988 bytes
"hpl" <hpl.muc@web.de> wrote in message
news:3eb5353d$1@newsgroups.borland.com...

> unsigned int vlabellength;
> GetVolumeLabel ("D:\\", vlabel, vlabellength, NULL, NULL, NULL,NULL)

There is no GetVolumeLabel() function.  Please always copy/paste your actual
source code, do not re-type it by hand.

Now then, with that said, you didn't initialize your 'vlabellength' variable
before passing it in to the function.  You need to do that, otherwise the
value will be initialized with a random value from the memory it occupies,
and you will end up with undefined results.  That variable tells the
function how large your buffer is.  If it gets initialized with a random
value, then the function will think your buffer is a different size then it
really is.

    char vlabel[32] = {0};
    unsigned int vlabellength = 32;
    GetVolumeInformation("D:\\", vlabel, vlabellength, NULL, NULL, NULL,
NULL, 0);

Or simply:

    char vlabel[32] = {0};
    GetVolumeInformation("D:\\", vlabel, 32, NULL, NULL, NULL, NULL, 0);


Gambit
Re: Problem with GetVolumeInformation
#16670
Author: hpl
Date: Mon, 05 May 2003 05:34
17 lines
1341 bytes
"Remy Lebeau (TeamB)" <gambit47@yahoo.com> schrieb im Newsbeitrag
news:3eb56e26$1@newsgroups.borland.com...

> (...) Please always copy/paste your actual  source code, do not re-type it
by hand.

Agreed, sorry for my mistake.

>     (...)
>     unsigned int vlabellength = 32;
>     GetVolumeInformation("D:\\", vlabel, vlabellength, NULL, NULL, NULL,
NULL, 0);

It works, thanks very much !

HPL
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads