Win32 Windows Volume Program and Code Example 18

 

 

 

 

 

Deleting a Mounted Folder Program Example

 

The following program example shows you how to delete a mounted folder by using the DeleteVolumeMountPoint() function.

Create a new Win32 console application project and give a suitable project name.

 

Deleting a Mounted Folder Program Example - creating a new Win32 console project using Visual Studio

 

Add the source file and give a suitable name.

 

Deleting a Mounted Folder Program Example - adding a new C++ source file

 

Add the following source code.

 

#include <windows.h>

#include <stdio.h>

 

void Syntax(WCHAR *argv)

{

   wprintf(L"%s unmounts a mounted volume\n", argv);

   wprintf(L"     Example: \"%s c:\\mnt\\fdrive\\\"\n", argv);

}

 

int wmain(int argc, WCHAR *argv[])

{

   BOOL bFlag;

 

   // Verify the arguments

   if (argc != 2)

   {

      Syntax(argv[0]);

      return (-1);

   }

  

   // We should do some error checking on the path argument, such as

   // ensuring that there is a trailing backslash

   bFlag = DeleteVolumeMountPoint(

              argv[1] // Path of the volume mount point

           );

 

   wprintf(L"\n%s %s in unmounting the volume at %s\n", argv[0], bFlag ? L"succeeded" : L"failed", argv[1]);

 

   return (bFlag);

}

 

Build and run the project. The following screenshot is an output sample without any argument.

 

Deleting a Mounted Folder Program Example - a sample output without argument

 

The following sample outputs show unmounting the previous mounted drive.

 

Deleting a Mounted Folder Program Example - sample output on dismounting the mounted drive

 

 

 

  < Windows Volume 17 | Win32 Programming Index | Windows Volume Index | Windows Volume 19 >