不VBoxManage.exe使用什么样的API? [英] What API does VBoxManage.exe use?

查看:223
本文介绍了不VBoxManage.exe使用什么样的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

VBoxManage.exe 是Oracle的VirtualBox伴侣工具,它允许通过命令行来控制虚拟机。它可以做很多业务,包括启动/停止和屏幕捕获。

VBoxManage.exe is an Oracle VirtualBox companion utility, which allows to control VMs via command line. It can do numerous operations, including start/stop and screen capturing.

我很感兴趣,其使用的API?

I am interested, which API it uses?

我怎样才能捕捉到虚拟机屏幕或者有送键盘或鼠标命令没有这个沉重的命令行工具?哪种语言是更好吗?是否可以使用Java访问此API?

How can I capture VM screen or send keyboard or mouse commands there without this heavy commandline utility? Which language is better? Is is possible to access this API with Java?

推荐答案

的优点之一,使用一个开源项目应该是,你可以通过查看源回答这些问题。

One of the advantages to using an open source project is supposed to be that you can answer such questions by looking at the source.

VBoxManage位于源代码库 / src目录/垂直框下/前台应用/ VBoxManage 。你要找的code为 VBoxManageControlVM.cpp 的情况下如果(STRCMP(A->!ARGV [1] screenshotpng))

VBoxManage is located in the source repository under /src/VBox/Frontends/VBoxManage. The code you're looking for is in VBoxManageControlVM.cpp under the condition if (!strcmp(a->argv[1], "screenshotpng")):

ComPtr<IDisplay> pDisplay;
CHECK_ERROR_BREAK(console, COMGETTER(Display)(pDisplay.asOutParam()));

ULONG width, height, bpp;
CHECK_ERROR_BREAK(pDisplay, 
        GetScreenResolution(displayIdx, &width, &height, &bpp));

com::SafeArray<BYTE> saScreenshot;
CHECK_ERROR_BREAK(pDisplay, TakeScreenShotPNGToArray(displayIdx, 
        width, height, ComSafeArrayAsOutParam(saScreenshot)));

RTFILE pngFile = NIL_RTFILE;
vrc = RTFileOpen(&pngFile, a->argv[2], RTFILE_O_OPEN_CREATE | RTFILE_O_WRITE |
    RTFILE_O_TRUNCATE | RTFILE_O_DENY_ALL);

if (RT_FAILURE(vrc))
{
    RTMsgError("Failed to create file '%s'. rc=%Rrc", a->argv[2], vrc);
    rc = E_FAIL;
    break;
}
vrc = RTFileWrite(pngFile, saScreenshot.raw(), saScreenshot.size(), NULL);
if (RT_FAILURE(vrc))
{
    RTMsgError("Failed to write screenshot to file '%s'. rc=%Rrc",
        a->argv[2], vrc);
    rc = E_FAIL;
}
RTFileClose(pngFile);

所以,它通过一个COM API做的,你可以看看:

So it's done via a COM API, and you can look at:

是否有可能调用COM API从Java的?

谷歌搜索 TakeScreenShotPNGToArray 找到的显示界面:

Googling for TakeScreenShotPNGToArray finds the display interface:

https://www.virtualbox.org/sdkref/interface_i_display.html

从那里你可以找到所有其他的东西像鼠标和键盘名单:

From there you can find the list of all the other things like mouse and keyboard:

https://www.virtualbox.org/sdkref/annotated.html

这篇关于不VBoxManage.exe使用什么样的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆