Skip to content

Instantly share code, notes, and snippets.

@teramako
Last active December 11, 2015 01:39
Show Gist options
  • Save teramako/4524819 to your computer and use it in GitHub Desktop.
Save teramako/4524819 to your computer and use it in GitHub Desktop.
const EXPORTED_SYMBOLS = ["eject"];
Components.utils.import("resource://gre/modules/ctypes.jsm");
const UINT = ctypes.unsigned_int;
const DWORD = ctypes.uint32_t;
const LPCWSTR = ctypes.jschar.ptr;
if (ctypes.size_t.size == 8) {
var WinABI = ctypes.default_abi;
} else {
var WinABI = ctypes.winapi_abi;
}
var dll = "winmm.dll";
function eject () {
var winmm = ctypes.open(dll);
var mciSendStringW = winmm.declare("mciSendStringW", WinABI, DWORD, LPCWSTR, DWORD, UINT, DWORD);
return mciSendStringW("set cdaudio door open", 0, 0, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment