资源简介
微软官方的实例,使用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图像查看软件
- 下一篇:支付宝在线支付视频教程
相关资源
- apit定位算法
- 关于交织器VHDL代码
- RedisDesktopManager 最新到0.9.9-Windows版-包
- AutoCAD .NET API进行AutoCAD二次开发基础代
- zh-hans_windows_xp_professional_with_service_p
- Windows 7 OEM证书
- windows系统运行的scp,实现从Linux系统
- MATROX_G200eR 64位驱动 for windows2003 x64
- windows下用到的cp命令
- arduino avrdude 5.11.1 for Windows with JesseJ
- windows7镜像文件
- elf转换为bin脚本工具
- byshell
- Windows Server 2008上安装Exchange Server 20
- 百兆以太网MAC和MII的VHDL源码,我也是
- Dom4j-1.6.1 API文档
- A first book of Ansi C Solutions to Exercises (
- RXTX的API文档.chm
- windows 7 操作系统教程
- 50MHz逐步分频器VHDL代码
- Windows server 2008 R2 M5210e、m5210阵列卡驱
- vhdl汽车尾灯控制
- Windows光盘隐藏文件查看器
- arcgis api for js +json 实现热力图
- arcgis api for js 自定义弹出专题图(饼
- 通信系统中卷积码编解码器的VHDL实现
- 基于VHDL语言的贪吃蛇设计
- Windows Service 通信- 消息队列
- windows\\centos\\suse\\rhel的ZABBIX_agent安装
- windows cmd 下对文件的操作
评论
共有 条评论