Shell_NotifyIconW
関数タスクトレイの通知アイコンを追加・変更・削除する。
シグネチャ
// SHELL32.dll (Unicode / -W)
#include <windows.h>
BOOL Shell_NotifyIconW(
NOTIFY_ICON_MESSAGE dwMessage,
NOTIFYICONDATAW* lpData
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| dwMessage | NOTIFY_ICON_MESSAGE | in |
| lpData | NOTIFYICONDATAW* | in |
戻り値の型: BOOL
各言語での呼び出し定義
// SHELL32.dll (Unicode / -W)
#include <windows.h>
BOOL Shell_NotifyIconW(
NOTIFY_ICON_MESSAGE dwMessage,
NOTIFYICONDATAW* lpData
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool Shell_NotifyIconW(
uint dwMessage, // NOTIFY_ICON_MESSAGE
IntPtr lpData // NOTIFYICONDATAW*
);<DllImport("SHELL32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function Shell_NotifyIconW(
dwMessage As UInteger, ' NOTIFY_ICON_MESSAGE
lpData As IntPtr ' NOTIFYICONDATAW*
) As Boolean
End Function' dwMessage : NOTIFY_ICON_MESSAGE
' lpData : NOTIFYICONDATAW*
Declare PtrSafe Function Shell_NotifyIconW Lib "shell32" ( _
ByVal dwMessage As Long, _
ByVal lpData As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
Shell_NotifyIconW = ctypes.windll.shell32.Shell_NotifyIconW
Shell_NotifyIconW.restype = wintypes.BOOL
Shell_NotifyIconW.argtypes = [
wintypes.DWORD, # dwMessage : NOTIFY_ICON_MESSAGE
ctypes.c_void_p, # lpData : NOTIFYICONDATAW*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
Shell_NotifyIconW = Fiddle::Function.new(
lib['Shell_NotifyIconW'],
[
-Fiddle::TYPE_INT, # dwMessage : NOTIFY_ICON_MESSAGE
Fiddle::TYPE_VOIDP, # lpData : NOTIFYICONDATAW*
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "shell32")]
extern "system" {
fn Shell_NotifyIconW(
dwMessage: u32, // NOTIFY_ICON_MESSAGE
lpData: *mut NOTIFYICONDATAW // NOTIFYICONDATAW*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll", CharSet = CharSet.Unicode)]
public static extern bool Shell_NotifyIconW(uint dwMessage, IntPtr lpData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_Shell_NotifyIconW' -Namespace Win32 -PassThru
# $api::Shell_NotifyIconW(dwMessage, lpData)#uselib "SHELL32.dll"
#func global Shell_NotifyIconW "Shell_NotifyIconW" wptr, wptr
; Shell_NotifyIconW dwMessage, varptr(lpData) ; 戻り値は stat
; dwMessage : NOTIFY_ICON_MESSAGE -> "wptr"
; lpData : NOTIFYICONDATAW* -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHELL32.dll" #cfunc global Shell_NotifyIconW "Shell_NotifyIconW" int, var ; res = Shell_NotifyIconW(dwMessage, lpData) ; dwMessage : NOTIFY_ICON_MESSAGE -> "int" ; lpData : NOTIFYICONDATAW* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHELL32.dll" #cfunc global Shell_NotifyIconW "Shell_NotifyIconW" int, sptr ; res = Shell_NotifyIconW(dwMessage, varptr(lpData)) ; dwMessage : NOTIFY_ICON_MESSAGE -> "int" ; lpData : NOTIFYICONDATAW* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL Shell_NotifyIconW(NOTIFY_ICON_MESSAGE dwMessage, NOTIFYICONDATAW* lpData) #uselib "SHELL32.dll" #cfunc global Shell_NotifyIconW "Shell_NotifyIconW" int, var ; res = Shell_NotifyIconW(dwMessage, lpData) ; dwMessage : NOTIFY_ICON_MESSAGE -> "int" ; lpData : NOTIFYICONDATAW* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL Shell_NotifyIconW(NOTIFY_ICON_MESSAGE dwMessage, NOTIFYICONDATAW* lpData) #uselib "SHELL32.dll" #cfunc global Shell_NotifyIconW "Shell_NotifyIconW" int, intptr ; res = Shell_NotifyIconW(dwMessage, varptr(lpData)) ; dwMessage : NOTIFY_ICON_MESSAGE -> "int" ; lpData : NOTIFYICONDATAW* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procShell_NotifyIconW = shell32.NewProc("Shell_NotifyIconW")
)
// dwMessage (NOTIFY_ICON_MESSAGE), lpData (NOTIFYICONDATAW*)
r1, _, err := procShell_NotifyIconW.Call(
uintptr(dwMessage),
uintptr(lpData),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction Shell_NotifyIconW(
dwMessage: DWORD; // NOTIFY_ICON_MESSAGE
lpData: Pointer // NOTIFYICONDATAW*
): BOOL; stdcall;
external 'SHELL32.dll' name 'Shell_NotifyIconW';result := DllCall("SHELL32\Shell_NotifyIconW"
, "UInt", dwMessage ; NOTIFY_ICON_MESSAGE
, "Ptr", lpData ; NOTIFYICONDATAW*
, "Int") ; return: BOOL●Shell_NotifyIconW(dwMessage, lpData) = DLL("SHELL32.dll", "bool Shell_NotifyIconW(dword, void*)")
# 呼び出し: Shell_NotifyIconW(dwMessage, lpData)
# dwMessage : NOTIFY_ICON_MESSAGE -> "dword"
# lpData : NOTIFYICONDATAW* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。