Shell_NotifyIconGetRect
関数通知領域アイコンの画面上の矩形位置を取得する。
シグネチャ
// SHELL32.dll
#include <windows.h>
HRESULT Shell_NotifyIconGetRect(
const NOTIFYICONIDENTIFIER* identifier,
RECT* iconLocation
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| identifier | NOTIFYICONIDENTIFIER* | in | アイコンを識別する NOTIFYICONIDENTIFIER 構造体へのポインターです。 |
| iconLocation | RECT* | out | RECT 構造体へのポインターです。この関数が正常に終了すると、この構造体にアイコンの座標が格納されます。 |
戻り値の型: HRESULT
公式ドキュメント
通知アイコンの境界矩形のスクリーン座標を取得します。
戻り値
型: HRESULT
この関数が成功した場合は S_OK を返します。それ以外の場合は HRESULT エラーコードを返します。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// 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 方式にも切替可。#uselib "SHELL32.dll" #cfunc global Shell_NotifyIconGetRect "Shell_NotifyIconGetRect" sptr, sptr ; res = Shell_NotifyIconGetRect(varptr(identifier), varptr(iconLocation)) ; identifier : NOTIFYICONIDENTIFIER* -> "sptr" ; iconLocation : RECT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; HRESULT Shell_NotifyIconGetRect(NOTIFYICONIDENTIFIER* identifier, RECT* iconLocation) #uselib "SHELL32.dll" #cfunc global Shell_NotifyIconGetRect "Shell_NotifyIconGetRect" intptr, intptr ; res = Shell_NotifyIconGetRect(varptr(identifier), varptr(iconLocation)) ; identifier : NOTIFYICONIDENTIFIER* -> "intptr" ; iconLocation : RECT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // HRESULTfunction 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)。const std = @import("std");
extern "shell32" fn Shell_NotifyIconGetRect(
identifier: [*c]NOTIFYICONIDENTIFIER, // NOTIFYICONIDENTIFIER*
iconLocation: [*c]RECT // RECT* out
) callconv(std.os.windows.WINAPI) i32;proc Shell_NotifyIconGetRect(
identifier: ptr NOTIFYICONIDENTIFIER, # NOTIFYICONIDENTIFIER*
iconLocation: ptr RECT # RECT* out
): int32 {.importc: "Shell_NotifyIconGetRect", stdcall, dynlib: "SHELL32.dll".}pragma(lib, "shell32");
extern(Windows)
int Shell_NotifyIconGetRect(
NOTIFYICONIDENTIFIER* identifier, // NOTIFYICONIDENTIFIER*
RECT* iconLocation // RECT* out
);ccall((:Shell_NotifyIconGetRect, "SHELL32.dll"), stdcall, Int32,
(Ptr{NOTIFYICONIDENTIFIER}, Ptr{RECT}),
identifier, iconLocation)
# identifier : NOTIFYICONIDENTIFIER* -> Ptr{NOTIFYICONIDENTIFIER}
# iconLocation : RECT* out -> Ptr{RECT}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t Shell_NotifyIconGetRect(
void* identifier,
void* iconLocation);
]]
local shell32 = ffi.load("shell32")
-- shell32.Shell_NotifyIconGetRect(identifier, iconLocation)
-- identifier : NOTIFYICONIDENTIFIER*
-- iconLocation : RECT* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const Shell_NotifyIconGetRect = lib.func('__stdcall', 'Shell_NotifyIconGetRect', 'int32_t', ['void *', 'void *']);
// Shell_NotifyIconGetRect(identifier, iconLocation)
// identifier : NOTIFYICONIDENTIFIER* -> 'void *'
// iconLocation : RECT* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SHELL32.dll", {
Shell_NotifyIconGetRect: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.Shell_NotifyIconGetRect(identifier, iconLocation)
// identifier : NOTIFYICONIDENTIFIER* -> "pointer"
// iconLocation : RECT* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t Shell_NotifyIconGetRect(
void* identifier,
void* iconLocation);
C, "SHELL32.dll");
// $ffi->Shell_NotifyIconGetRect(identifier, iconLocation);
// identifier : NOTIFYICONIDENTIFIER*
// iconLocation : RECT* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Shell32 extends StdCallLibrary {
Shell32 INSTANCE = Native.load("shell32", Shell32.class);
int Shell_NotifyIconGetRect(
Pointer identifier, // NOTIFYICONIDENTIFIER*
Pointer iconLocation // RECT* out
);
}@[Link("shell32")]
lib LibSHELL32
fun Shell_NotifyIconGetRect = Shell_NotifyIconGetRect(
identifier : NOTIFYICONIDENTIFIER*, # NOTIFYICONIDENTIFIER*
iconLocation : RECT* # RECT* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef Shell_NotifyIconGetRectNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef Shell_NotifyIconGetRectDart = int Function(Pointer<Void>, Pointer<Void>);
final Shell_NotifyIconGetRect = DynamicLibrary.open('SHELL32.dll')
.lookupFunction<Shell_NotifyIconGetRectNative, Shell_NotifyIconGetRectDart>('Shell_NotifyIconGetRect');
// identifier : NOTIFYICONIDENTIFIER* -> Pointer<Void>
// iconLocation : RECT* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function Shell_NotifyIconGetRect(
identifier: Pointer; // NOTIFYICONIDENTIFIER*
iconLocation: Pointer // RECT* out
): Integer; stdcall;
external 'SHELL32.dll' name 'Shell_NotifyIconGetRect';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "Shell_NotifyIconGetRect"
c_Shell_NotifyIconGetRect :: Ptr () -> Ptr () -> IO Int32
-- identifier : NOTIFYICONIDENTIFIER* -> Ptr ()
-- iconLocation : RECT* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let shell_notifyicongetrect =
foreign "Shell_NotifyIconGetRect"
((ptr void) @-> (ptr void) @-> returning int32_t)
(* identifier : NOTIFYICONIDENTIFIER* -> (ptr void) *)
(* iconLocation : RECT* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)
(cffi:defcfun ("Shell_NotifyIconGetRect" shell-notify-icon-get-rect :convention :stdcall) :int32
(identifier :pointer) ; NOTIFYICONIDENTIFIER*
(icon-location :pointer)) ; RECT* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $Shell_NotifyIconGetRect = Win32::API::More->new('SHELL32',
'int Shell_NotifyIconGetRect(LPVOID identifier, LPVOID iconLocation)');
# my $ret = $Shell_NotifyIconGetRect->Call($identifier, $iconLocation);
# identifier : NOTIFYICONIDENTIFIER* -> LPVOID
# iconLocation : RECT* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。