Open CD Rom from Java ?

Declare Function mciSendString Lib"winmm.dll" Alias"mciSendStringA" (ByVal lpCommandString As String, ByVal lpReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim retval As Long

retval = mciSendString("set CDAudio door open","", 0, 0)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim retval As Long

retval = mciSendString("set CDAudio door closed","", 0, 0)

End Sub

This is the VB Code first we need to convert it into VC++ and then call from java !!

[892 byte] By [speed_of_lighta] at [2007-11-26 20:54:23]
# 1

Hi,

You do not need to write C/C++ code.

for example :

public static int operateTray(boolean open) {

JNative mciSendString = new JNative("winmm.dll", "mciSendStringA");

mciSendString.setRetVal(Type.INT);

mciSendString.setParameter(0, open ? "set CDAudio door open" : "set CDAudio door closed");

mciSendString.setParameter(1, 0);

mciSendString.setParameter(2, 0);

mciSendString.invoke();

return mciSendString.getRetValAsInt();

}

You can do this with JNative (a free LGPL native bridge).

--Marc (http://jnative.sf.net)

mdentya at 2007-7-10 2:21:15 > top of Java-index,Java HotSpot Virtual Machine,Specifications...