//获取窗口句柄
try {
var hWnd;
Components.utils.import("resource://gre/modules/ctypes.jsm");
var lib = ctypes.open("user32.dll");
var afterFx4 = ctypes.jschar ? true : false;
var winABI = afterFx4 ? (ctypes.size_t.size == 8 ? ctypes.default_abi : ctypes.winapi_abi) : ctypes.stdcall_abi;
var wstrType = afterFx4 ? ctypes.jschar.ptr : ctypes.ustring;
var winClass = afterFx4 ? "MozillaWindowClass" : "MozillaUIWindowClass";
var funcFindWindow = lib.declare("FindWindowW", winABI, ctypes.int32_t, wstrType, wstrType);
hWnd = funcFindWindow(winClass, document.title);
//alert(hWnd.toString(16));
} catch (ex) {
if(lib) {
alert(ex);
}
} finally {
if(lib) {
lib.close();
}
}
try {
var hWnd;
Components.utils.import("resource://gre/modules/ctypes.jsm");
var lib = ctypes.open("user32.dll");
var afterFx4 = ctypes.jschar ? true : false;
var winABI = afterFx4 ? (ctypes.size_t.size == 8 ? ctypes.default_abi : ctypes.winapi_abi) : ctypes.stdcall_abi;
var wstrType = afterFx4 ? ctypes.jschar.ptr : ctypes.ustring;
var winClass = afterFx4 ? "MozillaWindowClass" : "MozillaUIWindowClass";
var funcFindWindow = lib.declare("FindWindowW", winABI, ctypes.int32_t, wstrType, wstrType);
hWnd = funcFindWindow(winClass, document.title);
//alert(hWnd.toString(16));
} catch (ex) {
if(lib) {
alert(ex);
}
} finally {
if(lib) {
lib.close();
}
}