Suggestions for bug in VOLUMENAME function

Suggestions for bug in VOLUMENAME function

Postby MaxP » Fri Apr 24, 2020 3:16 pm

Hello,

If the function GetVolumeInformation fails (harddisk.c), a random buffer is returned

Code: Select all  Expand view  RUN
HB_FUNC( VOLUMENAME )
{
   DWORD dwVolumeSerialNumber;
   BYTE VolumeNameBuffer[ 256 ];
   BYTE FileSystemNameBuffer[ 256 ];
/*****
   GetVolumeInformation( hb_pcount() ? hb_parc( 1 ): "C:\\",
                         ( char * ) VolumeNameBuffer, sizeof( VolumeNameBuffer ),
                         &dwVolumeSerialNumber, 0, 0,
                         ( char * ) FileSystemNameBuffer,
                         sizeof( FileSystemNameBuffer ) ); */

/*****/
   if ( ! GetVolumeInformation( hb_pcount() ? hb_parc( 1 ): "C:\\",
                         ( char * ) VolumeNameBuffer, sizeof( VolumeNameBuffer ),
                         &dwVolumeSerialNumber, 0, 0,
                         ( char * ) FileSystemNameBuffer,
                         sizeof( FileSystemNameBuffer ) ) )
          VolumeNameBuffer[0] = '\0' ;            
/*****/

   hb_retc( ( char * ) VolumeNameBuffer );
}


Regards
Massimo
User avatar
MaxP
 
Posts: 88
Joined: Thu Jul 12, 2007 2:02 pm

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 75 guests