首页 > 解决方案 > 如何通过在 Java 中调用 Windows API 来打开 DVD 驱动器?

问题描述

如何在 Java 中使用 Windows API 函数?我正在寻找一个参考来指导我在 Windows 上的 Java 应用程序中使用 Windows API。

例如,我想在我的 Java 应用程序中控制 DVD 驱动器。我该怎么做呢?

任何帮助表示赞赏。

标签: javawindowswinapijava-native-interfacejna

解决方案


You can do this by using either JNA (Java Native Access) or JNI (Java Native Interface).

With JNA you can use com.sun.jna.platform.win32.Kernel32 to call DeviceIoControl, which will allow you to control your DVD drive.


推荐阅读