Win32 API 日本語リファレンス
ホームUI.Shell › Shell_NotifyIconGetRect

Shell_NotifyIconGetRect

関数
通知領域アイコンの画面上の矩形位置を取得する。
DLLSHELL32.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

// SHELL32.dll
#include <windows.h>

HRESULT Shell_NotifyIconGetRect(
    const NOTIFYICONIDENTIFIER* identifier,
    RECT* iconLocation
);

パラメーター

名前方向
identifierNOTIFYICONIDENTIFIER*in
iconLocationRECT*out

戻り値の型: HRESULT

各言語での呼び出し定義

// SHELL32.dll
#include <windows.h>

HRESULT Shell_NotifyIconGetRect(
    const NOTIFYICONIDENTIFIER* identifier,
    RECT* iconLocation
);
[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern int Shell_NotifyIconGetRect(
    IntPtr identifier,   // NOTIFYICONIDENTIFIER*
    IntPtr iconLocation   // RECT* out
);
<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function Shell_NotifyIconGetRect(
    identifier As IntPtr,   ' NOTIFYICONIDENTIFIER*
    iconLocation As IntPtr   ' RECT* out
) As Integer
End Function
' identifier : NOTIFYICONIDENTIFIER*
' iconLocation : RECT* out
Declare PtrSafe Function Shell_NotifyIconGetRect Lib "shell32" ( _
    ByVal identifier As LongPtr, _
    ByVal iconLocation As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

Shell_NotifyIconGetRect = ctypes.windll.shell32.Shell_NotifyIconGetRect
Shell_NotifyIconGetRect.restype = ctypes.c_int
Shell_NotifyIconGetRect.argtypes = [
    ctypes.c_void_p,  # identifier : NOTIFYICONIDENTIFIER*
    ctypes.c_void_p,  # iconLocation : RECT* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
Shell_NotifyIconGetRect = Fiddle::Function.new(
  lib['Shell_NotifyIconGetRect'],
  [
    Fiddle::TYPE_VOIDP,  # identifier : NOTIFYICONIDENTIFIER*
    Fiddle::TYPE_VOIDP,  # iconLocation : RECT* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "shell32")]
extern "system" {
    fn Shell_NotifyIconGetRect(
        identifier: *const NOTIFYICONIDENTIFIER,  // NOTIFYICONIDENTIFIER*
        iconLocation: *mut RECT  // RECT* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHELL32.dll")]
public static extern int Shell_NotifyIconGetRect(IntPtr identifier, IntPtr iconLocation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_Shell_NotifyIconGetRect' -Namespace Win32 -PassThru
# $api::Shell_NotifyIconGetRect(identifier, iconLocation)
#uselib "SHELL32.dll"
#func global Shell_NotifyIconGetRect "Shell_NotifyIconGetRect" sptr, sptr
; Shell_NotifyIconGetRect varptr(identifier), varptr(iconLocation)   ; 戻り値は stat
; identifier : NOTIFYICONIDENTIFIER* -> "sptr"
; iconLocation : RECT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SHELL32.dll"
#cfunc global Shell_NotifyIconGetRect "Shell_NotifyIconGetRect" var, var
; res = Shell_NotifyIconGetRect(identifier, iconLocation)
; identifier : NOTIFYICONIDENTIFIER* -> "var"
; iconLocation : RECT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT Shell_NotifyIconGetRect(NOTIFYICONIDENTIFIER* identifier, RECT* iconLocation)
#uselib "SHELL32.dll"
#cfunc global Shell_NotifyIconGetRect "Shell_NotifyIconGetRect" var, var
; res = Shell_NotifyIconGetRect(identifier, iconLocation)
; identifier : NOTIFYICONIDENTIFIER* -> "var"
; iconLocation : RECT* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procShell_NotifyIconGetRect = shell32.NewProc("Shell_NotifyIconGetRect")
)

// identifier (NOTIFYICONIDENTIFIER*), iconLocation (RECT* out)
r1, _, err := procShell_NotifyIconGetRect.Call(
	uintptr(identifier),
	uintptr(iconLocation),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function Shell_NotifyIconGetRect(
  identifier: Pointer;   // NOTIFYICONIDENTIFIER*
  iconLocation: Pointer   // RECT* out
): Integer; stdcall;
  external 'SHELL32.dll' name 'Shell_NotifyIconGetRect';
result := DllCall("SHELL32\Shell_NotifyIconGetRect"
    , "Ptr", identifier   ; NOTIFYICONIDENTIFIER*
    , "Ptr", iconLocation   ; RECT* out
    , "Int")   ; return: HRESULT
●Shell_NotifyIconGetRect(identifier, iconLocation) = DLL("SHELL32.dll", "int Shell_NotifyIconGetRect(void*, void*)")
# 呼び出し: Shell_NotifyIconGetRect(identifier, iconLocation)
# identifier : NOTIFYICONIDENTIFIER* -> "void*"
# iconLocation : RECT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。