Last active
August 29, 2015 14:09
-
-
Save 8q/2ef0e34bb23e973e6717 to your computer and use it in GitHub Desktop.
ROMドライブがポンって
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<windows.h> | |
#pragma comment (lib, "winmm.lib") | |
int main(){ | |
//TCHAR buf[128]; | |
//UINT bufsiz = 128; | |
//mciGetErrorString( | |
// mciSendString(TEXT("open F:\ type cdaudio alias romdrive"), NULL, 0, 0), | |
// buf, bufsiz); | |
//printf("%s", buf); | |
mciSendString(TEXT("open F:\ type cdaudio alias romdrive"), NULL, 0, 0); | |
mciSendString(TEXT("set romdrive door open"), NULL, 0, 0); | |
mciSendString(TEXT("close romdrive"), NULL, 0, 0); | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
using System.Runtime.InteropServices; | |
namespace EjectCSharp | |
{ | |
class Program | |
{ | |
[DllImport("User32.dll")] | |
extern static int MessageBox(IntPtr hWnd, string lpText, string lpCaption, uint uType); | |
[DllImport("winmm.dll")] | |
extern static uint mciSendStringA(string lpszCommand, StringBuilder lpszReturnString, uint cchReturn, IntPtr hwndCallback); | |
[DllImport("winmm.dll")] | |
extern static bool mciGetErrorStringA(uint fdwError, StringBuilder lpszErrorText, uint cchErrorText); | |
static void Main() | |
{ | |
//StringBuilder buf = new StringBuilder(256); | |
//mciGetErrorStringA( | |
// mciSendStringA(@"open F:\ type cdaudio alias romdrive", null, 0, IntPtr.Zero), | |
// buf, (uint)buf.Capacity); | |
//MessageBox(IntPtr.Zero, buf.ToString(), "メッセージ", 0x00 | 0x40); | |
mciSendStringA(@"open F:\ type cdaudio alias romdrive", null, 0, IntPtr.Zero); | |
mciSendStringA(@"set romdrive door open", null, 0, IntPtr.Zero); | |
mciSendStringA(@"close romdrive", null, 0, IntPtr.Zero); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.sun.jna.Library; | |
import com.sun.jna.Native; | |
import com.sun.jna.Platform; | |
import com.sun.jna.Pointer; | |
public class Eject { | |
public interface Winmm extends Library { | |
Winmm INSTANCE = (Winmm) | |
Native.loadLibrary("winmm", Winmm.class); | |
long mciSendStringA( | |
String lpszCommand, | |
byte[] lpszReturnString, | |
int cchReturn, | |
Pointer hwndCallback); | |
boolean mciGetErrorStringA( | |
long fdwError, | |
byte[] lpszErrorText, | |
int cchErrorText); | |
} | |
public static void main(String[] args) throws Exception { | |
if(!Platform.isWindows()) | |
return; | |
// byte[] message = new byte[128]; | |
// Winmm.INSTANCE.mciGetErrorStringA( | |
// Winmm.INSTANCE.mciSendStringA("open F:\\ type cdaudio alias romdrive", null, 0, null), | |
// message, 128); | |
// System.out.println(new String(message)); | |
Winmm.INSTANCE.mciSendStringA("open F:\\ type cdaudio alias romdrive", null, 0, null); | |
Winmm.INSTANCE.mciSendStringA("set romdrive door open", null, 0, null); | |
Winmm.INSTANCE.mciSendStringA("close romdrive", null, 0, null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment