Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/124.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何恢复默认图标?(WinXP和Win7)_C++_Firefox Addon_Icons_User32_Jsctypes - Fatal编程技术网

C++ 如何恢复默认图标?(WinXP和Win7)

C++ 如何恢复默认图标?(WinXP和Win7),c++,firefox-addon,icons,user32,jsctypes,C++,Firefox Addon,Icons,User32,Jsctypes,告诉我: 如果hinst参数为NULL,而fuLoad参数省略了LR_LOADFROMFILE值,则lpszName指定要加载的OEM映像。OEM映像标识符在Winuser.h中定义,并具有以下前缀 但我很难弄明白 我正在尝试,但它在var hIconBig=LoadImage…和var hIconSmall=LoadImage…行上抛出了各种错误 Cu.import('resource://gre/modules/ctypes.jsm'); var user32 = ctypes.open(

告诉我:

如果hinst参数为NULL,而fuLoad参数省略了LR_LOADFROMFILE值,则lpszName指定要加载的OEM映像。OEM映像标识符在Winuser.h中定义,并具有以下前缀

但我很难弄明白

我正在尝试,但它在
var hIconBig=LoadImage…
var hIconSmall=LoadImage…
行上抛出了各种错误

Cu.import('resource://gre/modules/ctypes.jsm');

var user32 = ctypes.open('user32.dll');
var SendMessage = user32.declare('SendMessageW', ctypes.winapi_abi, ctypes.uintptr_t, ctypes.int32_t, ctypes.unsigned_int, ctypes.int32_t, ctypes.voidptr_t );
var LoadImage = user32.declare('LoadImageA', ctypes.winapi_abi, ctypes.voidptr_t, ctypes.int, ctypes.char.ptr, ctypes.unsigned_int, ctypes.int, ctypes.int, ctypes.unsigned_int);

var IMAGE_BITMAP = 0;
var IMAGE_ICON = 1;
var LR_LOADFROMFILE = 16;

var basewindow = window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShellTreeItem).treeOwner.QueryInterface(Ci.nsIInterfaceRequestor).nsIBaseWindow;
var nativeHandle = basewindow.nativeHandle;
var targetWindow_handle = parseInt(nativeHandle);

var hIconBig = LoadImage(null, 'C:\\Documents and Settings\\SONY VAIO\\My Documents\\Downloads\\puzzle.ico', IMAGE_ICON, 256, 256);
var hIconSmall = LoadImage(null, 'C:\\Documents and Settings\\SONY VAIO\\My Documents\\Downloads\\puzzle.ico', IMAGE_ICON, 16, 16);

var successSmall = SendMessage(targetWindow_handle, 0x0080 /** WM_SETICON **/ , 0 /** ICON_SMALL **/ , hIconSmall);
var successBig = SendMessage(targetWindow_handle, 0x0080 /** WM_SETICON **/ , 1 /** ICON_BIG **/ , hIconBig);

var me = Services.wm.getMostRecentWindow(null);
me.alert(successSmall);
me.alert(successBig);

user32.close();
要恢复正确的图标,您必须在设置自己的图标并将其保留在周围之前,先使用
WM_GETICON
HICONs。然后,当您要恢复图标时,请使用保存的图标来恢复图标

我也是


旁白:
nsIBaseWindow
现在有一个可编写脚本的
nativeHandle
?耶!我还不知道。当没有
nativeHandle

时,是时候扔掉我的旧标题hack了,但是MSDN文档将
hinst
设置为
null
并省略
LR_LOADFROMFILE
参数意味着什么呢?哈哈,是的,感谢@paa的帮助,
nativeHandle
真是太棒了:你知道这有没有文档记录吗MDN?OEM图像上的任何地方都是完全不同的。这些是Windows附带的默认图标。啊,我明白了!因此,如果我将其更改为OEM图像,那么我可以使用null和omit技术来恢复原始图标?不可以。您可以使用MSDN工具将图标替换为图标,但这完全不是您想要的。Dong
parseInt
nativeHandle。