🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #8118

Re: How to read a diskette's ID-No. (Volume Serial Number)

#8118
From: Joe Hagen
Date: Wed, 04 Mar 1998 00:00
106 lines
2966 bytes
Erik,

   Here is a Win32 console app that accepts the drive
letter as a parameter, and prints the volume ID as a
DWORD.

/***************************************************************************
*
   File:    GETVOL32.C
   Type:    Win32 Console Application
   Purpose: Reads volume serial number ID of a drive.

   COMPILED WITH MSVC 5.0 (CL v11.00.7022):

         CL /W3 /Oxb2 /ML /GX GETVOL32.C

****************************************************************************
/

#include <stdio.h>
#include <windows.h>

int GetVolumeID(char *pstr,DWORD *lpID)
/***************************************************************************
*
   Functional description:

   Determine volume ID of drive specified.

   Returns:
            0 on sucess (lpID will contain volume ID #)
            non-zero for error.

****************************************************************************
/
{
   int status=0;
   char volbuff[256],namebuff[256];
   DWORD dwSer;
   DWORD dwMaxFileLen;
   DWORD dwFileFlags;

   if (GetVolumeInformation( pstr,volbuff,sizeof(volbuff),
                                 &dwSer,
                                 &dwMaxFileLen,
                                 &dwFileFlags,
                                 namebuff,
                                 sizeof(namebuff)))
   {

      *lpID=dwSer;
   }
   else
   {
      status=GetLastError();
   }


   return status;

}

int main(int argc,char *argv[])
{
   DWORD dwSer;
   int status;
   char *pdrvstr=" :\\";

   if (argc < 2)
   {
      printf("Usage: %s drive:\n",argv[0]);
      printf("       Returns volume ID of specified drive.\n");
      return 1;
   }

   *pdrvstr=*argv[1];

   status=GetVolumeID(pdrvstr,&dwSer);

   if (status)
   {
      printf("Error %d\n",status);
   }
   else
   {
      printf("Volume Serial Number for %s is %lX\n",argv[1],dwSer);
   }

   return status;
}


Joe
jdhagen@itis.com

erik.rasmussen@leo.dk wrote in message ...
>How do I write a C++ (MSVC++ v.5)  program that retrieves the unique
>ID-number (i.e. the 'Volume Serial Number' as shown by a 'DIR A:'
>command) on a floppy disk?
>I prefer an MFC solution.
>
>Kind regards
>Gustav Sporon-Fiedler,
>LEO Pharmaceutical Products, Denmark
>e-mail: gustav.sporon-fiedler@leo.dk
Technical Details
Message-ID: <6disrj$7iq$1@news.itis.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <MPG.f649d74f5abdf7398969a@balder>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10f6aa,b5c1243e77fb9c8b
X-Google-Attributes: gid10f6aa,public
X-Google-Thread: fa6f6,b5c1243e77fb9c8b
X-Google-Attributes: gidfa6f6,public
From: "Joe Hagen" <jdhagen@itis.com>
Subject: Re: How to read a diskette's ID-No. (Volume Serial Number)
Date: 1998/03/04
Message-ID: <6disrj$7iq$1@news.itis.com>
X-Deja-AN: 330665166
References: <MPG.f649d74f5abdf7398969a@balder>
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
Organization: IntraNet Inc: Madison, Wisconsin's ISP
Newsgroups: comp.os.msdos.programmer,dk.edb.programmering