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.
Add the source file and give a suitable name.
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 ? Lsucceeded : Lfailed, argv[1]);
return (bFlag);
}
Build and run the project. The following screenshot is an output sample without any argument.
The following sample outputs show un-mounting the previous mounted drive.