资源简介
微软官方的实例,使用windows api操作vhd,可以正常运行。

代码片段和文件信息
/****************************** Module Header ******************************\
Module Name: CppVhdAPI.cpp
Project: CppVhdAPI (VHD API demo)
Copyright (c) Microsoft Corporation.
Demonstrates various VHD API usage such as VHD creation attaching
detaching and getting and setting disk information.
This source is subject to the Microsoft Public License.
See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
All other rights reserved.
THIS CODE AND INFORMATION IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND
EITHER EXPRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
\***************************************************************************/
#include
#include
#define DEFIND_GUID
#include
#include
#pragma comment(lib “VirtDisk.lib“)
#define PHYS_PATH_LEN 1024+1
GUID GUID_TEST = {12345678-1234-5678-1234-000000000000};
GUID zGuid = GUID_NULL;
void PrintErrorMessage(ULONG ErrorId)
{
PVOID Message = NULL;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS
NULL
ErrorId
0
(LPWSTR)&Message
16
NULL);
wprintf(L“%s\n“ Message);
LocalFree(Message);
}
void usage()
{
printf(“CppVhdAPI.exe -[cxaomdgpe] -f -s \n“);
printf(“-c CreateVirtualDisk............input: -f -s \n“);
printf(“-a AttachVirtualDisk............input: -f \n“);
printf(“-d DetachVirtualDisk............input: -f \n“);
printf(“-g GetVirtualDiskInformation....input: -f \n“);
printf(“-p GetVirtualDiskPhysicalPath...input: -f -- note: must be attached\n“);
printf(“-e SetVirtualDiskInformation....input: -f -u \n“);
printf(“Examples:\n“);
printf(“ Create a 3.6 Gb VHD named ‘mytest.vhd‘\n“);
printf(“CppVhdAPI.exe -c -f c:\\testdir\\mytest.vhd -s 3600\n\n“);
printf(“ Attach a VHD named ‘mytest.vhd‘\n“);
printf(“CppVhdAPI.exe -a -f c:\\testdir\\mytest.vhd\n\n“);
printf(“ Set VHD GUID ‘mytest.vhd‘\n“);
printf(“CppVhdAPI.exe -e -f c:\\testdir\\mytest.vhd -u {12345678-1234-5678-1234-000000000000}\n“);
}
BOOL ValidateActionAndParameters(wchar_t action PCWSTR pszFilename ULONG sizeInMb PCWSTR pszGuid)
{
HRESULT hr;
switch (action)
{
case L‘c‘: // CreateVirtualDisk
case L‘x‘: // ExpandVirtualDisk
{
// Validate file name and size
return (wcslen(pszFilename) && (sizeInMb));
}
case L‘e‘: // SetVirtualDiskInformation
if (wcslen(pszFilename) && wcslen(pszGuid))
{
// Validate filename and size
hr = CLSIDFromString(pszGuid &zGuid);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 12415 2014-06-06 06:55 desc
文件 1670 2014-06-06 06:55 desc
文件 0 2014-06-06 06:55 desc
文件 0 2014-06-06 06:55 desc
文件 10457 2014-06-06 06:55 desc
文件 1727 2014-06-06 06:55 desc
文件 71647 2014-06-06 06:55 desc
文件 3369 2014-06-06 06:55 desc
文件 12978 2014-06-06 06:55 desc
文件 14808 2014-06-06 06:55 license.rtf
文件 894 2014-06-06 06:55 C++\CppVhdAPI.sln
文件 21904 2014-06-06 06:55 C++\CppVhdAPI\CppVhdAPI.cpp
文件 3990 2014-06-06 06:55 C++\CppVhdAPI\CppVhdAPI.vcxproj
文件 1024 2014-06-06 06:55 C++\CppVhdAPI\CppVhdAPI.vcxproj.filters
文件 3570 2014-06-06 06:55 C++\CppVhdAPI\ReadMe.txt
- 上一篇:ezdicom图像查看软件
- 下一篇:支付宝在线支付视频教程
相关资源
- 用友NC开发API字典
- AE开发Windows最短路径分析
- Web Api 通过文件流 文件到本地
- Spire API文档
- ectouch最新版JSAPI微信支付V3插
-
Windows em
bedded Compact 2013 应用开发调 - 黑苹果硬件兼容检测和查询软件
- Uninstall_Cortana_WINCLIENT.CN.rar
- Servlet API中文文档
- jstl-api-1.2和jstl-impl-1.2
- 八三编码器设计 VHDL代码 简单,包附
- 数字频率合成dds正弦波基于FPGA的DDS产
- VMware65_SLP_DeLLSLIC2.1
- 3人表决器 QuartusII
- Windows异步套接字网络编程
- WINDOWS98启动盘镜像Win98.IMA
- 仿windows记事本
- 六路智能抢答器VHDL语言
- hidusage.h hidpi.h 等USB开发用头文件
- windows7用的,非常漂亮的透明计时器
- vhdl与lcd1602实现的多控制电子钟
- OpenGL文档,api大全,可直接查询函数
- nVidia 控制面板 API
- IpHlpApi.h&IpHlpApi.lib
- verilog的PCI源代码,非常详细,顶层模
- windows下制作macOS安装U盘,绝对简单好
- keil vcom windows 7 64bit 驱动
- windows ce 系统的GPIO驱动程序
- TCP 发包工具(windows)
- 应用接口支持库1.1版eAPI
评论
共有 条评论