home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!warwick!uknet!mcsun!Germany.EU.net!nixpbe!news.sni.de!fam168!frank
- From: fh.pad@sni.de (Frank Hoffmann)
- Newsgroups: comp.os.msdos.programmer
- Subject: Re: Obtaining the volume label
- Message-ID: <frank.720964912@fam168>
- Date: 5 Nov 92 12:01:52 GMT
- References: <114@complex.complex.is>
- Organization: Siemens Nixdorf Informationssysteme AG, Paderborn, Germany
- Lines: 207
- NNTP-Posting-Host: fam168.ap.pdb.sni.de
-
- Actually this is a crosspost from alt.msdos.programmer, so if you already
- know it -- forgive me :-)
-
-
- Path: news.sni.de!fam168!frank
- From: Frank Hoffmann <fh.pad@sni.de>
- Newsgroups: alt.msdos.programmer
- Subject: Re: Setting volume labels..
- Date: 2 Nov 92 09:03:45 GMT
- Organization: Siemens Nixdorf Informationssysteme AG, Paderborn, Germany
- Lines: 180
- Message-ID: <frank.720695025@fam168>
- References: <92299.041830MBT3@psuvm.psu.edu>
- NNTP-Posting-Host: fam168.ap.pdb.sni.de
-
- Mike Tierney <MBT3@psuvm.psu.edu> writes:
-
- >Hi all!
- > Does anyone out there have any sample source code demonstrating how
- >to set/remove disk volume labels? I've tried to come up with a method on
- >my own, however, I can't seem to find a way to remove a volume label that
- >has no other file attribute set (e.g. if a volume label also has the
- >Archive attribute set, I can work with it, otherwise not). The source can
- >be in any language (C, Pascal, Asm). Thanks for any help you can give,
- > -Mike
-
- >------------------------------------------------------------------------
- >Mike Tierney "..what would be 'beautiful' if the contradiction had
- >mbt3@vm.psu.edu not first become conscious of itself, if the ugly had
- >mbt@ecl.psu.edu not first said to itself, 'I am ugly'?"
- >mbt@eclu.psu.edu - Nietzsche
-
- All right ... here we go.
-
- Once i was pretty upset with *MS* handling of the "label" command. I wanted to
- delete or change volume labels without any online input by the user. So i
- wrote the following 'C' code. Anyway, it doesn't ever work. (Dunno why)
- So without any warranty and using the standard disclaimer :
-
- regards
- frank
-
- [cut here]
-
- /*-------------------------------------------------------------------*/
- static char *xchngvol_id =
- " @(#) [xchngvol.c] Ver.: 01/00 910618 fh ";
- /*-------------------------------------------------------------------*/
- /* */
- /* History: */
- /* */
- /* Release date comment */
- /* */
- /* 01/00 fh 910618 Original release */
- /* */
- /*-------------------------------------------------------------------*/
-
-
- #ifdef MSDOS
-
-
-
- #include <dos.h>
- #include <errno.h>
- #include <string.h>
-
-
- /********************************************************************/
- xchngvol (drive, label)
- /********************************************************************/
-
- char drive; /* a, b, c ... */
- char *label; /* ... */
-
- {
-
- struct fcb
- {
- /*------ start of 'extended' FCB ------*/
- char ext_flag; /* extended FCB, if FFh */
- char rsvd_1[5]; /* reserved */
- char ext_attrib; /* attribute of extended FCB */
- /*------ start of 'normal' FCB ------*/
- char drive; /* drive number. 0=default, 1=A ... */
- char name[8]; /* blank padded file name */
- char ext[3]; /* blank padded extension */
- int curr_block; /* current block number */
- int log_rec; /* logical record size */
- long size; /* files size */
- int date; /* date of last write */
- int time; /* time of last write */
- char rsvd_2[8]; /* reserved */
- char rec_in_block; /* record in current block */
- long rnd_acc_rec; /* random access record number */
- };
-
- struct find_t file; /* find structure */
- struct fcb myfcb; /* our file control block */
-
-
- char find[7]; /* string for find_first */
- char help[13]; /* destination label help */
- char dlabel[16]; /* destination label */
- int ddrive; /* destination drive */
- char *p1;
- int i;
- int create; /* creation flag */
-
-
- create = 0; /* default = just delete */
-
- ddrive = toupper (drive);
-
- sprintf (find, "%c:\\*.*", (char) ddrive);
-
- for (i = 0; i < 13; i++) help[i] = 0x00;
-
- if (label != (char *) 0) /* copy user label */
- {
- strncpy (help, label, 8); /* first 8 chars */
- if (strlen (label) > 8) /* more ? ... */
- {
- help[8] = '.'; /* separated by dot, 'cause its a file */
- label += 8;
- strncpy (&help[9], label, 3);
- help[12] = 0x00;
- }
- sprintf (dlabel, "%c:\\%s", (char) ddrive, help);
- dlabel[15] = 0x00;
- create = 1;
- }
-
- ddrive -= 64; /* convert to 1, 2, 3 ... */
-
- p1 = (char *) &myfcb; /* points to an extended FCB */
-
- /* search for existing volume name */
- if (_dos_findfirst (find, 0x28, &file) == 0)
- {
- strcpy (myfcb.name, file.name); /* copy old volume name */
- for (i = strlen (myfcb.name); i < 8; i++)
- {
- myfcb.name[i] = 0x20; /* blank out unused parts */
- }
- strcpy (myfcb.ext, "???");
- myfcb.ext_flag = 0xff; /* extended FCB */
- myfcb.ext_attrib = 0x28; /* attributes: VOLID+ARCHIVE */
- myfcb.drive = ddrive; /* drive ID */
- _asm mov ax, byte ptr p1
- _asm mov dx, ax /* address of FCB */
- _asm mov ax, 1300h
- _asm int 21h /* delete file. INT 21h, func: 13h */
- _asm jnc ok1
- return (-1);
-
- ok1:
- ; /* label MUST contain a statement! */
- }
-
- if (! create)
- {
- return (0); /* our job is done */
- }
-
- p1 = dlabel; /* ASM is really too dumb ! */
-
- _asm mov ax, byte ptr p1
- _asm mov dx, ax /* file name */
- _asm mov cx, 28h /* attributes */
- _asm mov ax, 5b00h
- _asm int 21h /* create file. INT 21h, func: 5Bh */
- _asm jnc ok2
-
- return (-1);
-
- ok2:
- return (0);
-
- } /* end of xchgngvol */
-
-
- #endif /* MSDOS */
-
- [cut here]
- <EOT>
-
- -------------------------------------------------------------------------------
- __________ Frank Hoffmann
- / / Siemens-Nixdorf Info. Systems Voice: [49] 5 251 812 209
- /__ / Dept: AP 52 / SW-Production Fax: [49] 5 251 811 599
- /' _ _ __ // Fuerstenallee 7 USA: fh.pad@sni-usa.com
- __/__/__(_(_/ /_/^\__ W-4790 Paderborn / Germany !USA: fh.pad@sni.de
- -------------------------------------------------------------------------------
- My opinion ?? waaaaaaaaaaaaaaaaaaaaahahahahahahahahahahahahahahah
- -------------------------------------------------------------------------------
-
-
-
- -------------------------------------------------------------------------------
- __________ Frank Hoffmann
- / / Siemens-Nixdorf Info. Systems Voice: [49] 5 251 812 209
- /__ / Dept: AP 52 / SW-Production Fax: [49] 5 251 811 599
- /' _ _ __ // Fuerstenallee 7 USA: fh.pad@sni-usa.com
- __/__/__(_(_/ /_/^\__ W-4790 Paderborn / Germany !USA: fh.pad@sni.de
- -------------------------------------------------------------------------------
- My opinion ?? waaaaaaaaaaaaaaaaaaaaahahahahahahahahahahahahahahah
- -------------------------------------------------------------------------------
-