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

查看:19
本文介绍了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?

如何在没有这个繁重的命令行实用程序的情况下捕获 VM 屏幕或在那里发送键盘或鼠标命令?哪种语言更好?是否可以使用 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/下的源存储库中VBox/前端/VBoxManage.您要查找的代码位于 VBoxManageControlVM.cpp 条件下 if (!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:

是否可以从爪哇?

谷歌搜索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天全站免登陆