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

SHObjectProperties

関数
シェルオブジェクトのプロパティシートを表示する。
DLLSHELL32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

BOOL SHObjectProperties(
    HWND hwnd,   // optional
    DWORD shopObjectType,
    LPCWSTR pszObjectName,
    LPCWSTR pszPropertyPage   // optional
);

パラメーター

名前方向
hwndHWNDinoptional
shopObjectTypeDWORDin
pszObjectNameLPCWSTRin
pszPropertyPageLPCWSTRinoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SHObjectProperties(
    HWND hwnd,   // optional
    DWORD shopObjectType,
    LPCWSTR pszObjectName,
    LPCWSTR pszPropertyPage   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern bool SHObjectProperties(
    IntPtr hwnd,   // HWND optional
    uint shopObjectType,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string pszObjectName,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pszPropertyPage   // LPCWSTR optional
);
<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function SHObjectProperties(
    hwnd As IntPtr,   ' HWND optional
    shopObjectType As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> pszObjectName As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pszPropertyPage As String   ' LPCWSTR optional
) As Boolean
End Function
' hwnd : HWND optional
' shopObjectType : DWORD
' pszObjectName : LPCWSTR
' pszPropertyPage : LPCWSTR optional
Declare PtrSafe Function SHObjectProperties Lib "shell32" ( _
    ByVal hwnd As LongPtr, _
    ByVal shopObjectType As Long, _
    ByVal pszObjectName As LongPtr, _
    ByVal pszPropertyPage As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SHObjectProperties = ctypes.windll.shell32.SHObjectProperties
SHObjectProperties.restype = wintypes.BOOL
SHObjectProperties.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND optional
    wintypes.DWORD,  # shopObjectType : DWORD
    wintypes.LPCWSTR,  # pszObjectName : LPCWSTR
    wintypes.LPCWSTR,  # pszPropertyPage : LPCWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
SHObjectProperties = Fiddle::Function.new(
  lib['SHObjectProperties'],
  [
    Fiddle::TYPE_VOIDP,  # hwnd : HWND optional
    -Fiddle::TYPE_INT,  # shopObjectType : DWORD
    Fiddle::TYPE_VOIDP,  # pszObjectName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pszPropertyPage : LPCWSTR optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "shell32")]
extern "system" {
    fn SHObjectProperties(
        hwnd: *mut core::ffi::c_void,  // HWND optional
        shopObjectType: u32,  // DWORD
        pszObjectName: *const u16,  // LPCWSTR
        pszPropertyPage: *const u16  // LPCWSTR optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll")]
public static extern bool SHObjectProperties(IntPtr hwnd, uint shopObjectType, [MarshalAs(UnmanagedType.LPWStr)] string pszObjectName, [MarshalAs(UnmanagedType.LPWStr)] string pszPropertyPage);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHObjectProperties' -Namespace Win32 -PassThru
# $api::SHObjectProperties(hwnd, shopObjectType, pszObjectName, pszPropertyPage)
#uselib "SHELL32.dll"
#func global SHObjectProperties "SHObjectProperties" sptr, sptr, sptr, sptr
; SHObjectProperties hwnd, shopObjectType, pszObjectName, pszPropertyPage   ; 戻り値は stat
; hwnd : HWND optional -> "sptr"
; shopObjectType : DWORD -> "sptr"
; pszObjectName : LPCWSTR -> "sptr"
; pszPropertyPage : LPCWSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHELL32.dll"
#cfunc global SHObjectProperties "SHObjectProperties" sptr, int, wstr, wstr
; res = SHObjectProperties(hwnd, shopObjectType, pszObjectName, pszPropertyPage)
; hwnd : HWND optional -> "sptr"
; shopObjectType : DWORD -> "int"
; pszObjectName : LPCWSTR -> "wstr"
; pszPropertyPage : LPCWSTR optional -> "wstr"
; BOOL SHObjectProperties(HWND hwnd, DWORD shopObjectType, LPCWSTR pszObjectName, LPCWSTR pszPropertyPage)
#uselib "SHELL32.dll"
#cfunc global SHObjectProperties "SHObjectProperties" intptr, int, wstr, wstr
; res = SHObjectProperties(hwnd, shopObjectType, pszObjectName, pszPropertyPage)
; hwnd : HWND optional -> "intptr"
; shopObjectType : DWORD -> "int"
; pszObjectName : LPCWSTR -> "wstr"
; pszPropertyPage : LPCWSTR optional -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procSHObjectProperties = shell32.NewProc("SHObjectProperties")
)

// hwnd (HWND optional), shopObjectType (DWORD), pszObjectName (LPCWSTR), pszPropertyPage (LPCWSTR optional)
r1, _, err := procSHObjectProperties.Call(
	uintptr(hwnd),
	uintptr(shopObjectType),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszObjectName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPropertyPage))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SHObjectProperties(
  hwnd: THandle;   // HWND optional
  shopObjectType: DWORD;   // DWORD
  pszObjectName: PWideChar;   // LPCWSTR
  pszPropertyPage: PWideChar   // LPCWSTR optional
): BOOL; stdcall;
  external 'SHELL32.dll' name 'SHObjectProperties';
result := DllCall("SHELL32\SHObjectProperties"
    , "Ptr", hwnd   ; HWND optional
    , "UInt", shopObjectType   ; DWORD
    , "WStr", pszObjectName   ; LPCWSTR
    , "WStr", pszPropertyPage   ; LPCWSTR optional
    , "Int")   ; return: BOOL
●SHObjectProperties(hwnd, shopObjectType, pszObjectName, pszPropertyPage) = DLL("SHELL32.dll", "bool SHObjectProperties(void*, dword, char*, char*)")
# 呼び出し: SHObjectProperties(hwnd, shopObjectType, pszObjectName, pszPropertyPage)
# hwnd : HWND optional -> "void*"
# shopObjectType : DWORD -> "dword"
# pszObjectName : LPCWSTR -> "char*"
# pszPropertyPage : LPCWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。