Board index » delphi » Problems using API-FUNCTION "GETVOLUMEINFORMATION"

Problems using API-FUNCTION "GETVOLUMEINFORMATION"

Problems using API-FUNCTION "GETVOLUMEINFORMATION"
Hello,
is there someone who can help me.
I need to get the Volume - SerialNumber.
For this i used the function getVolumeInformation but on WIN NT 4.0 i get
the error 234.

Here is my Function:

procedure TForm1.Button1Click(Sender: TObject);
var
  vVolumeNameBuffer     : PChar;
  vVolumeNameSize       : Integer;
  vSerialNumber                 : PdWord;
  vLength               : Integer;
  vFlagType             : dWord;
  vFileSystemNameBuf    : PChar;
  vFileSystemNameSize   : Integer;
begin
  vVolumeNameBuffer     := '';
  vFileSystemNameSize   := 0;
  vSerialNumber                 := NIL;
  vLength               := 0;
  vFlagType             := 0;
  vFileSystemNameBuf    := '';
  vVolumeNameSize       := 0;

  if GetVolumeInformation('C:\',vVolumeNameBuffer,vVolumeNameSize,
                                vSerialNumber,vLength,vFlagType,
                                vFileSystemNameBuf,vFileSystemNameSize) then
    ShowMessage(IntToStr(vSerialNumber^))
  else
  begin
    ShowMessage('ERROR : '+IntToSTr(getlasterror));
  end;
end;

 

Re:Problems using API-FUNCTION "GETVOLUMEINFORMATION"


Error 234 is "More data is available."  (BTW if you want to know what an error
code means in NT, use "net helpmsg ERRCODE" as in "net helpmsg 234")

I think the problem is passing '' instead of nil for volumenamebuffer.  Also,
be aware that you must pass a DWORD pointer _to_ windows.  Windows doesn't
allocate the memory, you do.

var
  serial_number, mcl, fsf : DWORD;
begin
  if GetVolumeInformation('c:\', nil, 0, @serial_number, mcv, fsf, nil, 0) then
    ShowMessage('Serial Number: ' + IntToStr(serial_number));
end;

In article <01bd3590$b47b1590$03841fc3@pers>, hcm...@tin.it says...

Quote

>Problems using API-FUNCTION "GETVOLUMEINFORMATION"
>Hello,
>is there someone who can help me.
>I need to get the Volume - SerialNumber.
>For this i used the function getVolumeInformation but on WIN NT 4.0 i get
>the error 234.

>Here is my Function:

>procedure TForm1.Button1Click(Sender: TObject);
>var
>  vVolumeNameBuffer     : PChar;
>  vVolumeNameSize       : Integer;
>  vSerialNumber                 : PdWord;
>  vLength               : Integer;
>  vFlagType             : dWord;
>  vFileSystemNameBuf    : PChar;
>  vFileSystemNameSize   : Integer;
>begin
>  vVolumeNameBuffer     := '';
>  vFileSystemNameSize   := 0;
>  vSerialNumber                 := NIL;
>  vLength               := 0;
>  vFlagType             := 0;
>  vFileSystemNameBuf    := '';
>  vVolumeNameSize       := 0;

>  if GetVolumeInformation('C:\',vVolumeNameBuffer,vVolumeNameSize,
>                                vSerialNumber,vLength,vFlagType,
>                                vFileSystemNameBuf,vFileSystemNameSize) then
>    ShowMessage(IntToStr(vSerialNumber^))
>  else
>  begin
>    ShowMessage('ERROR : '+IntToSTr(getlasterror));
>  end;
>end;

--
Chris Hill
hil...@cs.purdue.edu

Other Threads