-4

How can i use Windows API functions in Java? I'm searching for a reference to guide me about using the Windows API in my Java application on Windows.

For example, I want to control a DVD drive in my Java application. How would I go about doing that?

Any help is appreciated.

Ben Barkay
  • 5,473
  • 2
  • 20
  • 29

1 Answers1

0

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.

Ben Barkay
  • 5,473
  • 2
  • 20
  • 29
  • So which commands and codes shoud I use? – saiad8866 May 27 '18 at 14:11
  • After adding JNA as a dependency library, you should call `Kernel32.DeviceIoControl` to control the DVD drive (open or close). Perhaps another answer will also include a snippet, I'm a little too busy for that kind of investment right now :) – Ben Barkay May 27 '18 at 14:13