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

Shell_MergeMenus

関数
二つのメニューを統合しID調整して結合する。
DLLSHELL32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

DWORD Shell_MergeMenus(
    HMENU hmDst,
    HMENU hmSrc,
    DWORD uInsert,
    DWORD uIDAdjust,
    DWORD uIDAdjustMax,
    MM_FLAGS uFlags
);

パラメーター

名前方向
hmDstHMENUin
hmSrcHMENUin
uInsertDWORDin
uIDAdjustDWORDin
uIDAdjustMaxDWORDin
uFlagsMM_FLAGSin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD Shell_MergeMenus(
    HMENU hmDst,
    HMENU hmSrc,
    DWORD uInsert,
    DWORD uIDAdjust,
    DWORD uIDAdjustMax,
    MM_FLAGS uFlags
);
[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern uint Shell_MergeMenus(
    IntPtr hmDst,   // HMENU
    IntPtr hmSrc,   // HMENU
    uint uInsert,   // DWORD
    uint uIDAdjust,   // DWORD
    uint uIDAdjustMax,   // DWORD
    uint uFlags   // MM_FLAGS
);
<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function Shell_MergeMenus(
    hmDst As IntPtr,   ' HMENU
    hmSrc As IntPtr,   ' HMENU
    uInsert As UInteger,   ' DWORD
    uIDAdjust As UInteger,   ' DWORD
    uIDAdjustMax As UInteger,   ' DWORD
    uFlags As UInteger   ' MM_FLAGS
) As UInteger
End Function
' hmDst : HMENU
' hmSrc : HMENU
' uInsert : DWORD
' uIDAdjust : DWORD
' uIDAdjustMax : DWORD
' uFlags : MM_FLAGS
Declare PtrSafe Function Shell_MergeMenus Lib "shell32" ( _
    ByVal hmDst As LongPtr, _
    ByVal hmSrc As LongPtr, _
    ByVal uInsert As Long, _
    ByVal uIDAdjust As Long, _
    ByVal uIDAdjustMax As Long, _
    ByVal uFlags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

Shell_MergeMenus = ctypes.windll.shell32.Shell_MergeMenus
Shell_MergeMenus.restype = wintypes.DWORD
Shell_MergeMenus.argtypes = [
    wintypes.HANDLE,  # hmDst : HMENU
    wintypes.HANDLE,  # hmSrc : HMENU
    wintypes.DWORD,  # uInsert : DWORD
    wintypes.DWORD,  # uIDAdjust : DWORD
    wintypes.DWORD,  # uIDAdjustMax : DWORD
    wintypes.DWORD,  # uFlags : MM_FLAGS
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
Shell_MergeMenus = Fiddle::Function.new(
  lib['Shell_MergeMenus'],
  [
    Fiddle::TYPE_VOIDP,  # hmDst : HMENU
    Fiddle::TYPE_VOIDP,  # hmSrc : HMENU
    -Fiddle::TYPE_INT,  # uInsert : DWORD
    -Fiddle::TYPE_INT,  # uIDAdjust : DWORD
    -Fiddle::TYPE_INT,  # uIDAdjustMax : DWORD
    -Fiddle::TYPE_INT,  # uFlags : MM_FLAGS
  ],
  -Fiddle::TYPE_INT)
#[link(name = "shell32")]
extern "system" {
    fn Shell_MergeMenus(
        hmDst: *mut core::ffi::c_void,  // HMENU
        hmSrc: *mut core::ffi::c_void,  // HMENU
        uInsert: u32,  // DWORD
        uIDAdjust: u32,  // DWORD
        uIDAdjustMax: u32,  // DWORD
        uFlags: u32  // MM_FLAGS
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHELL32.dll")]
public static extern uint Shell_MergeMenus(IntPtr hmDst, IntPtr hmSrc, uint uInsert, uint uIDAdjust, uint uIDAdjustMax, uint uFlags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_Shell_MergeMenus' -Namespace Win32 -PassThru
# $api::Shell_MergeMenus(hmDst, hmSrc, uInsert, uIDAdjust, uIDAdjustMax, uFlags)
#uselib "SHELL32.dll"
#func global Shell_MergeMenus "Shell_MergeMenus" sptr, sptr, sptr, sptr, sptr, sptr
; Shell_MergeMenus hmDst, hmSrc, uInsert, uIDAdjust, uIDAdjustMax, uFlags   ; 戻り値は stat
; hmDst : HMENU -> "sptr"
; hmSrc : HMENU -> "sptr"
; uInsert : DWORD -> "sptr"
; uIDAdjust : DWORD -> "sptr"
; uIDAdjustMax : DWORD -> "sptr"
; uFlags : MM_FLAGS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHELL32.dll"
#cfunc global Shell_MergeMenus "Shell_MergeMenus" sptr, sptr, int, int, int, int
; res = Shell_MergeMenus(hmDst, hmSrc, uInsert, uIDAdjust, uIDAdjustMax, uFlags)
; hmDst : HMENU -> "sptr"
; hmSrc : HMENU -> "sptr"
; uInsert : DWORD -> "int"
; uIDAdjust : DWORD -> "int"
; uIDAdjustMax : DWORD -> "int"
; uFlags : MM_FLAGS -> "int"
; DWORD Shell_MergeMenus(HMENU hmDst, HMENU hmSrc, DWORD uInsert, DWORD uIDAdjust, DWORD uIDAdjustMax, MM_FLAGS uFlags)
#uselib "SHELL32.dll"
#cfunc global Shell_MergeMenus "Shell_MergeMenus" intptr, intptr, int, int, int, int
; res = Shell_MergeMenus(hmDst, hmSrc, uInsert, uIDAdjust, uIDAdjustMax, uFlags)
; hmDst : HMENU -> "intptr"
; hmSrc : HMENU -> "intptr"
; uInsert : DWORD -> "int"
; uIDAdjust : DWORD -> "int"
; uIDAdjustMax : DWORD -> "int"
; uFlags : MM_FLAGS -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procShell_MergeMenus = shell32.NewProc("Shell_MergeMenus")
)

// hmDst (HMENU), hmSrc (HMENU), uInsert (DWORD), uIDAdjust (DWORD), uIDAdjustMax (DWORD), uFlags (MM_FLAGS)
r1, _, err := procShell_MergeMenus.Call(
	uintptr(hmDst),
	uintptr(hmSrc),
	uintptr(uInsert),
	uintptr(uIDAdjust),
	uintptr(uIDAdjustMax),
	uintptr(uFlags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function Shell_MergeMenus(
  hmDst: THandle;   // HMENU
  hmSrc: THandle;   // HMENU
  uInsert: DWORD;   // DWORD
  uIDAdjust: DWORD;   // DWORD
  uIDAdjustMax: DWORD;   // DWORD
  uFlags: DWORD   // MM_FLAGS
): DWORD; stdcall;
  external 'SHELL32.dll' name 'Shell_MergeMenus';
result := DllCall("SHELL32\Shell_MergeMenus"
    , "Ptr", hmDst   ; HMENU
    , "Ptr", hmSrc   ; HMENU
    , "UInt", uInsert   ; DWORD
    , "UInt", uIDAdjust   ; DWORD
    , "UInt", uIDAdjustMax   ; DWORD
    , "UInt", uFlags   ; MM_FLAGS
    , "UInt")   ; return: DWORD
●Shell_MergeMenus(hmDst, hmSrc, uInsert, uIDAdjust, uIDAdjustMax, uFlags) = DLL("SHELL32.dll", "dword Shell_MergeMenus(void*, void*, dword, dword, dword, dword)")
# 呼び出し: Shell_MergeMenus(hmDst, hmSrc, uInsert, uIDAdjust, uIDAdjustMax, uFlags)
# hmDst : HMENU -> "void*"
# hmSrc : HMENU -> "void*"
# uInsert : DWORD -> "dword"
# uIDAdjust : DWORD -> "dword"
# uIDAdjustMax : DWORD -> "dword"
# uFlags : MM_FLAGS -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。