Search This Blog

Loading...

Program to Delete a specified Directory using Interrupt 21h

 # include <stdio.h>
 # include <conio.h>
 # include   <dos.h>
 constint DeleteDirectory(constchar*);

 int main( )
 {
    char* Directory=NULL;

    clrscr( );

    printf(" Enter the Directory Path to delete = ");
    scanf("%s",Directory);

    if(DeleteDirectory(Directory))
       printf("\n Error : Unable to delete the Directory.");
    else
       printf("\n The Directory is deleted sucessfully.");

    getch( );
    return 0;
 }

 /*DeleteDirectory( ) */

constint DeleteDirectory(constchar* Dir)
 {
    union REGS InReg;
    union REGS OutReg;
    union SREGS SegReg;

    InReg.h.ah=0x3A;
    InReg.x.dx=FP_OFF(Dir);

    SegReg.ds=FP_SEG(Dir);
    int86x(0x21,&InReg,&OutReg,&SegReg);
  

  return OutReg.x.cflag;
 }

No comments:

Post a Comment