java创建vhd,用于Windows VHD API的Java库

I need to mount and navigate a Windows VHD from Java. Anyone know of a Java library that wraps the Windows Virtual Hard Drive API or is there perhaps source code that uses JNA that I can look at. My google searches did not give me much.

Even some sample code on how to convert the OpenVirtualDisk function to JNA structures would give me enough to do the rest I believe.

解决方案

The VHD APIs are on MSDN. Here is a link to one of the APIs.

Here is a JNA usage example to load the VHD library with JNA (adjust/define types as necessary):

public interface VHDLibrary extends Library {

VHDLibrary INSTANCE = (VHDLibrary) Native.loadLibrary("VirtDisk", VHDLibrary.class);

DWORD AttachVirtualDisk(HANDLE p1, Pointer p2, int p3, long p4, Pointer p5, Pointer p6);

}

And to invoke the function via JNA (adjust/define params as necessary):

VHDLibrary.INSTANCE.AttachVirtualDisk(null, null, 0, 0, null, null);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
VhdManager.exe VhdManager.ini ; Generated (13.09.2015 18:44:54) by Simple Vhd Manager v1.0 ; www.sordum.org [Main] Language=Auto WinSetOnTop=0 GridLines=1 NewVhdSize=2,5 NewVhdOpt=0 [VirtualDiskFiles] 1=C:\20180619_034757.vhd [Language_English] 01="BlueLife" 02="Attach marked and detach unmarked files" 03="Add file to list" 04="Remove file from list" 05="Refresh list" 06="Disk Management" 07="Action\n Location\n Attached\n Boot Menu\n Virtual Size" 08="&File;\n &Edit;\n &Options;\n Tools \n &Help;" 09="&Add; File" 10="&Create; and Attach VHD" 11="&Attach; Marked Files" 12="&Detach; All Files" 13="&Remove; Entries In Boot Menu" 14="&Exit;" 15="&Attach;" 16="&Detach;" 17="&Read;-Only" 18="&Add; to Boot Menu" 19="&Remove; From Boot Menu" 20="&Paste; File" 21="&Remove;" 22="&Remove; All" 23="&Check; - Uncheck" 24="&Check; All" 25="&Uncheck; All" 26="&Open; Location" 27="&File; Properties" 28="&Disk;" 29="&Cd;-Rom" 30="&Refresh;" 31="&Open; With Explorer" 32="&Change; Drive Letter" 33="&Remove; Letter" 34="&Drive; Properties" 35="&Attach; Marked To System Startup" 36="&Disable; Autorun" 37="&Always; On Top" 38="&Show; Grid Lines" 39="&Add; to Context Menu" 40="&Show; Hidden Files" 41="&Show; File Extensions" 42="Disk &Management;" 43="Diskpart &Command; Prompt" 44="&Msconfig;" 45="&Restart; Windows Explorer" 46="&Donate;" 47="&HomePage;" 48="&Contact;" 49="&About;" 50="Please Wait ..." 51="Select Virtual Disk File\n Virtual Disk Files\n All Files" 52="Enter boot menu name\nOk\nCancel" 53="Added" 54="Unable to write file!" 55="File not found!" 56="The file path must not contain any spaces. Please correct it and try again." 57="Virtual hard disk size \nVirtual hard disk format \n Virtual hard disk type \nDynamically expanding \n Fixed" 58="%drive% not enough free space!\n Do you wish to continue?" 59="An error occurred. Check your settings and try again! \nError Code:%error%" 60="Mount &Options;\n &Mount; \n &Unmount; \n &Open; With Simple VHD Manager\n VHD Mount \n V

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值