system("format D: /q /x /y")
需要声明头文件stdlib.h!
--------------------------
format命令后跟盘符,format命令还用其它一些比较有用的参数:-q 快速格式化,-x 强制执行
format d: /q /x //强制将D盘快速格式化
满足case DRIVE_REMOVABLE USB 的 盘符 是你所要。
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
void find_U()
main( )
{
find_U()
return 0
}
void find_U()
{
char szDriver[3]="A:"
int i,n=0
UINT uType
for (i = 'C'i <= 'Z'i++)
{
szDriver[0] = i
uType = GetDriveType(szDriver)
switch (uType)
{
case DRIVE_UNKNOWN: printf("%c uType=%d -- Unknown\n",i,uType)break
case DRIVE_REMOVABLE:
printf("%c uType=%d -- Removable USB\n",i,uType)n++break
default: break
}// switch
}// for
if (n == 0) printf("not find\n")
}