DeleteVolumeMountPoint() - Unmount the disk from a folder
Compiler: Visual C++ Express Edition 2005
Compiled on Platform: Windows XP Pro SP2
Target platform: none, just for learning
Header file: Standard and Windows
Additional library: Windows Platform SDK
Additional project setting: Set project to be compiled as C
Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C Code (/TC)
Other info: non-CLR or unmanaged
To do: Unmount the logical drive from a folder
To show: Using the DeleteVolumeMountPoint() C function
// Unmounting disk or tape to a drive or folder...
#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <stdio.h>
// Run at the command prompt, all based on the wide character/unicode program...
int wmain(int argc, wchar_t *argv[])
{
BOOL bFlag;
// If the argument for the mount point is not given...
if(argc != 2)
{
printf("%S command unmounts a volume from the volume mount point.\n", argv[0]);
printf("Usage: \"%S <the_mount_point>\n", argv[0]);
printf("Example: \"%S c:\\mymnt\\gdrive\\\"\n", argv[0]);
// Just exit
return (1);
}
// Do some verification, error checking. The argv[1] is a path of the volume mount point
bFlag = DeleteVolumeMountPoint(argv[1]);
if(!bFlag)
{
printf("Unmounting the volume at %S failed!\n", argv[1]);
exit(2);
}
else
printf("Unmounting the volume at %S successfully done!\n", argv[1]);
return (bFlag);
}
Output example:
(This program run at the command prompt)
F:\vc2005project\cplus\debug>cplus
cplus command unmounts a volume from the volume mount point.
Usage: "cplus <the_mount_point>
Example: "cplus c:\mymnt\gdrive\"
F:\vc2005project\cplus\debug>cplus C:\mymount\
Unmounting the volume at C:\mymount\ successfully done!
F:\vc2005project\cplus\debug>
Note:
String Data Type ------------ String Literal
------------------------------------------------
char - standard/ANSI--------"string"
TCHAR - generic--------------TEXT("string")
WCHAR/Unicode--------------L"string"