Thread View: comp.os.msdos.programmer
3 messages
3 total messages
Started by erik.rasmussen
Mon, 02 Mar 1998 00:00
Q: How to read a diskette's ID-No. (Volume Serial Number)
Author: erik.rasmussen
Date: Mon, 02 Mar 1998 00:00
Date: Mon, 02 Mar 1998 00:00
10 lines
860 bytes
860 bytes
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
Re: Q: How to read a diskette's ID-No. (Volume Serial Number)
Author: Fred Smith
Date: Tue, 03 Mar 1998 00:00
Date: Tue, 03 Mar 1998 00:00
47 lines
1759 bytes
1759 bytes
erik.rasmussen@leo.dk wrote:
: 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
A hack:
#include <stdio.h>
int main (int argc, char ** argv)
{
FILE * infile;
char buf[128];
sprintf (buf, "dir %s > delete.me\n", argv[1]);
system (buf);
if ((infile = fopen ("delete.me", "r")) == NULL)
{
printf ("oops\n");
exit (0);
}
while (1)
{
if (fgets (buf, sizeof (buf), infile) != buf)
{
break;
}
if (strstr (buf, "Volume in drive") != NULL)
{
printf ("%s\n", buf);
break;
}
}
fclose (infile);
unlink ("delete.me");
}
--
---- Fred Smith -- fredex@fcshome.stoneham.ma.us -----------------------------
The eyes of the Lord are everywhere,
keeping watch on the wicked and the good.
----------------------------- Proverbs 15:3 (niv) -----------------------------
Re: How to read a diskette's ID-No. (Volume Serial Number)
Author: Joe Hagen
Date: Wed, 04 Mar 1998 00:00
Date: Wed, 04 Mar 1998 00:00
106 lines
2966 bytes
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
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