From: Frank Hoffmann <fh.pad@sni.de>
Subject: Re: Volume label's
Keywords: volume labels
Organization: Siemens Nixdorf Info.Sys. AG, Paderborn, Germany
Date: Thu, 13 Aug 1992 06:39:47 GMT

hvisage@rkw-risc.cs.up.ac.za (Hendrik Visage) writes:

>Hi net,
>	I need to change, create and delete volume labels in
> TP6.0, TC++ or TASM. under MS-DOS 5.00. If possible please send EMail.

>Thanx.
> -------------------------------------
> H.Visage
>  hvisage@rkw-risc.cs.up.ac.za
>  9121110@rkw-lan.cs.up.ac.za
> ------------------------------------- 

The following code (MSC 6.00) generates/deletes a volume label on the
requested drive. It works although the error return is not sure.

(Yup! we may could have written the same thing in ASM)

---cut-here---cut-here---cut-here---cut-here---cut-here---cut-here---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 <fh.h>
#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 really is 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---cut-here---cut-here---cut-here---cut-here---cut-here---cut-here-

Hope that helps a bit...

frank
-------------------------------------------------------------------------------
    __________                  Frank Hoffmann        Voice: [+49] 5251 812 209
     /             /    Siemens-Nixdorf Info. Systems  Data: [+49] 5251 812 207
    /__           /      Dept: AP 52 / SW-Production    Fax: [+49] 5251 811 599
   /' _  _   __  //            Fuerstenallee 7          USA: fh.pad@sni-usa.com
__/__/__(_(_/ /_/^\__    W-4790 Paderborn / Germany    !USA: fh.pad@sni.de
-------------------------------------------------------------------------------
( * )  <--- The green dot.  This mail is reusable. Copy to /dev/null instantly.
-------------------------------------------------------------------------------