调用 FormatEx 函数格式化磁盘的代码
来源:互联网 发布:在淘宝上怎么买到弓弩 编辑:程序博客网 时间:2024/06/05 03:26
http://hi.baidu.com/classfree/blog/item/ecc9dc8b8fd6831ec9fc7acf.html
// Output commandtypedef struct{DWORD Lines;PCHAR Output;} TEXTOUTPUT, *PTEXTOUTPUT;// Callback command typestypedef enum{PROGRESS,DONEWITHSTRUCTURE,UNKNOWN2,UNKNOWN3,UNKNOWN4,UNKNOWN5,INSUFFICIENTRIGHTS,UNKNOWN7,UNKNOWN8,UNKNOWN9,UNKNOWNA,DONE,UNKNOWNC,UNKNOWND,OUTPUT,STRUCTUREPROGRESS} CALLBACKCOMMAND;// FMIFS callback definitiontypedef BOOLEAN (__stdcall *PFMIFSCALLBACK)( CALLBACKCOMMAND Command, DWORD SubAction, PVOID ActionInfo );// Chkdsk command in FMIFStypedef VOID (__stdcall *PCHKDSK)( PWCHAR DriveRoot,PWCHAR Format,BOOL CorrectErrors,BOOL Verbose,BOOL CheckOnlyIfDirty,BOOL ScanDrive,PVOID Unused2,PVOID Unused3,PFMIFSCALLBACK Callback );// media flags#define FMIFS_HARDDISK 0xC#define FMIFS_FLOPPY 0x8// Format command in FMIFStypedef VOID (__stdcall *PFORMATEX)( PWCHAR DriveRoot,DWORD MediaFlag,PWCHAR Format,PWCHAR Label,BOOL QuickFormat,DWORD ClusterSize,PFMIFSCALLBACK Callback );// FormatExCallbackBOOLEAN __stdcall FormatExCallback( CALLBACKCOMMAND Command, DWORD Modifier, PVOID Argument ){PDWORD percent;PTEXTOUTPUT output;PBOOLEAN status;switch( Command ){case PROGRESS: //格式化进度percent = (PDWORD) Argument;DebugString("格式化进度: %d \n", *percent);break;case OUTPUT:output = (PTEXTOUTPUT) Argument;fprintf(stdout, "%s", output->Output);break;case DONE: //格式化完成status = (PBOOLEAN) Argument;if( *status == FALSE ){DebugString("格式化未能成功完成(%d)\n", GetLastError());MakePageFile(iMin, iMax, szPageFilePath);Error = TRUE;}else{DebugString("格式化完成!");MakePageFile(iMin, iMax, szPageFilePath);}break;}return TRUE;}//获取fsifs.dll中的格式化函数指针BOOLEAN LoadFMIFSEntryPoints(){ifsModule = LoadLibrary("fmifs.dll");FormatEx = (PFORMATEX)GetProcAddress( ifsModule, "FormatEx" );if(FormatEx == NULL){DebugString("获取FormatEx函数指针失败\n");return FALSE;}if( !(EnableVolumeCompression = (PENABLEVOLUMECOMPRESSION) GetProcAddress( ifsModule, "EnableVolumeCompression" )) ){DebugString("获取EnableVolumeCompression函数指针失败\n");return FALSE;}return TRUE;}// 调用格式化函数int CallFormatDriver(char *szDriver){USES_CONVERSION;BOOL QuickFormat = TRUE;DWORD ClusterSize = 4096;PWCHAR Label = NULL;PWCHAR Format = L"NTFS";WCHAR RootDirectory[MAX_PATH] = {0};wcscpy( RootDirectory, A2W(szDriver) );RootDirectory[1] = L':';RootDirectory[2] = L'\\';RootDirectory[3] = (WCHAR) 0;DWORD media;DWORD driveType;driveType = GetDriveTypeW( RootDirectory );if( driveType != DRIVE_FIXED )media = FMIFS_FLOPPY;if( driveType == DRIVE_FIXED )media = FMIFS_HARDDISK;if( !LoadFMIFSEntryPoints()){return -1;}FormatEx( RootDirectory, media, Format, Label, QuickFormat, ClusterSize, FormatExCallback );FreeLibrary(ifsModule);return 0;}
- 调用 FormatEx 函数格式化磁盘的代码
- 调用 FormatEx 函数格式化磁盘的代码
- 格式化磁盘的简短代码
- 磁盘格式化的原因
- 磁盘格式化的原理
- 磁盘格式化的例子
- jquery EasyUI的formatter格式化函数代码
- jquery EasyUI的formatter格式化函数代码
- 格式化html代码的函数有哪些
- jquery EasyUI的formatter格式化函数代码
- 磁盘格式化的编程实现
- 磁盘的分区、格式化、挂载
- 调用JDT进行格式化代码
- 格式化磁盘
- 磁盘格式化
- 磁盘格式化
- linux下格式化磁盘的相关问题
- absread和abswrite以及磁盘的格式化
- 一名真正的Web程序员应该懂得那些方面的知识,应该注意学习哪些东西
- 非常好用的代码查看分析工具Source Insight
- osgGIS工具简介
- 链接外部的css或js文件名后带问号(?)参数的作用 .js? .css?
- 嵌入式系统USB CDROM虚拟光驱驱动程序开发
- 调用 FormatEx 函数格式化磁盘的代码
- Android 线程消息循环机制
- Silverlight的依赖属性与附加属性http://www.silverlightchina.net/html/tips/2010/0328/920.html
- 电脑自动关机命令详解
- OGNL中要用到的集合的伪属性
- Android下蒙板效果的实现
- C#类的定义
- Oracle 包锁,解锁
- ubuntu apt-get