Win32 API 日本語リファレンス
ホームSystem.Ole › OleSetMenuDescriptor

OleSetMenuDescriptor

関数
合成メニューを枠ウィンドウにインストールする。
DLLOLE32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT OleSetMenuDescriptor(
    INT_PTR holemenu,
    HWND hwndFrame,
    HWND hwndActiveObject,
    IOleInPlaceFrame* lpFrame,
    IOleInPlaceActiveObject* lpActiveObj
);

パラメーター

名前方向
holemenuINT_PTRin
hwndFrameHWNDin
hwndActiveObjectHWNDin
lpFrameIOleInPlaceFrame*in
lpActiveObjIOleInPlaceActiveObject*in

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT OleSetMenuDescriptor(
    INT_PTR holemenu,
    HWND hwndFrame,
    HWND hwndActiveObject,
    IOleInPlaceFrame* lpFrame,
    IOleInPlaceActiveObject* lpActiveObj
);
[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int OleSetMenuDescriptor(
    IntPtr holemenu,   // INT_PTR
    IntPtr hwndFrame,   // HWND
    IntPtr hwndActiveObject,   // HWND
    IntPtr lpFrame,   // IOleInPlaceFrame*
    IntPtr lpActiveObj   // IOleInPlaceActiveObject*
);
<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function OleSetMenuDescriptor(
    holemenu As IntPtr,   ' INT_PTR
    hwndFrame As IntPtr,   ' HWND
    hwndActiveObject As IntPtr,   ' HWND
    lpFrame As IntPtr,   ' IOleInPlaceFrame*
    lpActiveObj As IntPtr   ' IOleInPlaceActiveObject*
) As Integer
End Function
' holemenu : INT_PTR
' hwndFrame : HWND
' hwndActiveObject : HWND
' lpFrame : IOleInPlaceFrame*
' lpActiveObj : IOleInPlaceActiveObject*
Declare PtrSafe Function OleSetMenuDescriptor Lib "ole32" ( _
    ByVal holemenu As LongPtr, _
    ByVal hwndFrame As LongPtr, _
    ByVal hwndActiveObject As LongPtr, _
    ByVal lpFrame As LongPtr, _
    ByVal lpActiveObj As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

OleSetMenuDescriptor = ctypes.windll.ole32.OleSetMenuDescriptor
OleSetMenuDescriptor.restype = ctypes.c_int
OleSetMenuDescriptor.argtypes = [
    ctypes.c_ssize_t,  # holemenu : INT_PTR
    wintypes.HANDLE,  # hwndFrame : HWND
    wintypes.HANDLE,  # hwndActiveObject : HWND
    ctypes.c_void_p,  # lpFrame : IOleInPlaceFrame*
    ctypes.c_void_p,  # lpActiveObj : IOleInPlaceActiveObject*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('OLE32.dll')
OleSetMenuDescriptor = Fiddle::Function.new(
  lib['OleSetMenuDescriptor'],
  [
    Fiddle::TYPE_INTPTR_T,  # holemenu : INT_PTR
    Fiddle::TYPE_VOIDP,  # hwndFrame : HWND
    Fiddle::TYPE_VOIDP,  # hwndActiveObject : HWND
    Fiddle::TYPE_VOIDP,  # lpFrame : IOleInPlaceFrame*
    Fiddle::TYPE_VOIDP,  # lpActiveObj : IOleInPlaceActiveObject*
  ],
  Fiddle::TYPE_INT)
#[link(name = "ole32")]
extern "system" {
    fn OleSetMenuDescriptor(
        holemenu: isize,  // INT_PTR
        hwndFrame: *mut core::ffi::c_void,  // HWND
        hwndActiveObject: *mut core::ffi::c_void,  // HWND
        lpFrame: *mut core::ffi::c_void,  // IOleInPlaceFrame*
        lpActiveObj: *mut core::ffi::c_void  // IOleInPlaceActiveObject*
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("OLE32.dll")]
public static extern int OleSetMenuDescriptor(IntPtr holemenu, IntPtr hwndFrame, IntPtr hwndActiveObject, IntPtr lpFrame, IntPtr lpActiveObj);
"@
$api = Add-Type -MemberDefinition $sig -Name 'OLE32_OleSetMenuDescriptor' -Namespace Win32 -PassThru
# $api::OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj)
#uselib "OLE32.dll"
#func global OleSetMenuDescriptor "OleSetMenuDescriptor" sptr, sptr, sptr, sptr, sptr
; OleSetMenuDescriptor holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj   ; 戻り値は stat
; holemenu : INT_PTR -> "sptr"
; hwndFrame : HWND -> "sptr"
; hwndActiveObject : HWND -> "sptr"
; lpFrame : IOleInPlaceFrame* -> "sptr"
; lpActiveObj : IOleInPlaceActiveObject* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "OLE32.dll"
#cfunc global OleSetMenuDescriptor "OleSetMenuDescriptor" sptr, sptr, sptr, sptr, sptr
; res = OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj)
; holemenu : INT_PTR -> "sptr"
; hwndFrame : HWND -> "sptr"
; hwndActiveObject : HWND -> "sptr"
; lpFrame : IOleInPlaceFrame* -> "sptr"
; lpActiveObj : IOleInPlaceActiveObject* -> "sptr"
; HRESULT OleSetMenuDescriptor(INT_PTR holemenu, HWND hwndFrame, HWND hwndActiveObject, IOleInPlaceFrame* lpFrame, IOleInPlaceActiveObject* lpActiveObj)
#uselib "OLE32.dll"
#cfunc global OleSetMenuDescriptor "OleSetMenuDescriptor" intptr, intptr, intptr, intptr, intptr
; res = OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj)
; holemenu : INT_PTR -> "intptr"
; hwndFrame : HWND -> "intptr"
; hwndActiveObject : HWND -> "intptr"
; lpFrame : IOleInPlaceFrame* -> "intptr"
; lpActiveObj : IOleInPlaceActiveObject* -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	ole32 = windows.NewLazySystemDLL("OLE32.dll")
	procOleSetMenuDescriptor = ole32.NewProc("OleSetMenuDescriptor")
)

// holemenu (INT_PTR), hwndFrame (HWND), hwndActiveObject (HWND), lpFrame (IOleInPlaceFrame*), lpActiveObj (IOleInPlaceActiveObject*)
r1, _, err := procOleSetMenuDescriptor.Call(
	uintptr(holemenu),
	uintptr(hwndFrame),
	uintptr(hwndActiveObject),
	uintptr(lpFrame),
	uintptr(lpActiveObj),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function OleSetMenuDescriptor(
  holemenu: NativeInt;   // INT_PTR
  hwndFrame: THandle;   // HWND
  hwndActiveObject: THandle;   // HWND
  lpFrame: Pointer;   // IOleInPlaceFrame*
  lpActiveObj: Pointer   // IOleInPlaceActiveObject*
): Integer; stdcall;
  external 'OLE32.dll' name 'OleSetMenuDescriptor';
result := DllCall("OLE32\OleSetMenuDescriptor"
    , "Ptr", holemenu   ; INT_PTR
    , "Ptr", hwndFrame   ; HWND
    , "Ptr", hwndActiveObject   ; HWND
    , "Ptr", lpFrame   ; IOleInPlaceFrame*
    , "Ptr", lpActiveObj   ; IOleInPlaceActiveObject*
    , "Int")   ; return: HRESULT
●OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj) = DLL("OLE32.dll", "int OleSetMenuDescriptor(int, void*, void*, void*, void*)")
# 呼び出し: OleSetMenuDescriptor(holemenu, hwndFrame, hwndActiveObject, lpFrame, lpActiveObj)
# holemenu : INT_PTR -> "int"
# hwndFrame : HWND -> "void*"
# hwndActiveObject : HWND -> "void*"
# lpFrame : IOleInPlaceFrame* -> "void*"
# lpActiveObj : IOleInPlaceActiveObject* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。