SHObjectProperties
関数シェルオブジェクトのプロパティシートを表示する。
シグネチャ
// SHELL32.dll
#include <windows.h>
BOOL SHObjectProperties(
HWND hwnd, // optional
DWORD shopObjectType,
LPCWSTR pszObjectName,
LPCWSTR pszPropertyPage // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | inoptional | ダイアログ ボックスの親ウィンドウのハンドル。この値は NULL でもかまいません。 |
| shopObjectType | DWORD | in | オブジェクトの種類を指定するフラグ値。 SHOP_PRINTERNAMEpszObjectName にはプリンターのフレンドリ名が格納されます。 SHOP_FILEPATHpszObjectName には完全修飾ファイル名が格納されます。 SHOP_VOLUMEGUIDpszObjectName には、(a) \?\Volume{GUID}\ 形式のボリューム名 (ここで {GUID} はグローバルに一意な識別子。例: "\?\Volume{2eca078d-5cbc-43d3-aff8-7e8511f60d0e})")、または (b) ドライブ パス (例: "C:") のいずれかが格納されます。 |
| pszObjectName | LPCWSTR | in | オブジェクト名を格納する null で終わる Unicode 文字列。この文字列の内容は shopObjectType に設定されたフラグによって決まります。 |
| pszPropertyPage | LPCWSTR | inoptional | 最初に開くプロパティ シート ページの名前を格納する null で終わる Unicode 文字列。既定のページを指定するには、このパラメーターを NULL に設定します。 |
戻り値の型: BOOL
公式ドキュメント
SHObjectProperties は変更されるか、利用できなくなる可能性があります。
戻り値
型: BOOL
コマンドが正常に呼び出された場合は TRUE、それ以外の場合は FALSE。
出典・ライセンス: 上記「公式ドキュメント」の内容は 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>
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 <MarshalAs(UnmanagedType.Bool)> 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 // BOOLfunction 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)。const std = @import("std");
extern "shell32" fn SHObjectProperties(
hwnd: ?*anyopaque, // HWND optional
shopObjectType: u32, // DWORD
pszObjectName: [*c]const u16, // LPCWSTR
pszPropertyPage: [*c]const u16 // LPCWSTR optional
) callconv(std.os.windows.WINAPI) i32;proc SHObjectProperties(
hwnd: pointer, # HWND optional
shopObjectType: uint32, # DWORD
pszObjectName: WideCString, # LPCWSTR
pszPropertyPage: WideCString # LPCWSTR optional
): int32 {.importc: "SHObjectProperties", stdcall, dynlib: "SHELL32.dll".}pragma(lib, "shell32");
extern(Windows)
int SHObjectProperties(
void* hwnd, // HWND optional
uint shopObjectType, // DWORD
const(wchar)* pszObjectName, // LPCWSTR
const(wchar)* pszPropertyPage // LPCWSTR optional
);ccall((:SHObjectProperties, "SHELL32.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, Cwstring, Cwstring),
hwnd, shopObjectType, pszObjectName, pszPropertyPage)
# hwnd : HWND optional -> Ptr{Cvoid}
# shopObjectType : DWORD -> UInt32
# pszObjectName : LPCWSTR -> Cwstring
# pszPropertyPage : LPCWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SHObjectProperties(
void* hwnd,
uint32_t shopObjectType,
const uint16_t* pszObjectName,
const uint16_t* pszPropertyPage);
]]
local shell32 = ffi.load("shell32")
-- shell32.SHObjectProperties(hwnd, shopObjectType, pszObjectName, pszPropertyPage)
-- hwnd : HWND optional
-- shopObjectType : DWORD
-- pszObjectName : LPCWSTR
-- pszPropertyPage : LPCWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const SHObjectProperties = lib.func('__stdcall', 'SHObjectProperties', 'int32_t', ['void *', 'uint32_t', 'str16', 'str16']);
// SHObjectProperties(hwnd, shopObjectType, pszObjectName, pszPropertyPage)
// hwnd : HWND optional -> 'void *'
// shopObjectType : DWORD -> 'uint32_t'
// pszObjectName : LPCWSTR -> 'str16'
// pszPropertyPage : LPCWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SHELL32.dll", {
SHObjectProperties: { parameters: ["pointer", "u32", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.SHObjectProperties(hwnd, shopObjectType, pszObjectName, pszPropertyPage)
// hwnd : HWND optional -> "pointer"
// shopObjectType : DWORD -> "u32"
// pszObjectName : LPCWSTR -> "buffer"
// pszPropertyPage : LPCWSTR optional -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SHObjectProperties(
void* hwnd,
uint32_t shopObjectType,
const uint16_t* pszObjectName,
const uint16_t* pszPropertyPage);
C, "SHELL32.dll");
// $ffi->SHObjectProperties(hwnd, shopObjectType, pszObjectName, pszPropertyPage);
// hwnd : HWND optional
// shopObjectType : DWORD
// pszObjectName : LPCWSTR
// pszPropertyPage : LPCWSTR optional
// 構造体/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);
boolean SHObjectProperties(
Pointer hwnd, // HWND optional
int shopObjectType, // DWORD
WString pszObjectName, // LPCWSTR
WString pszPropertyPage // LPCWSTR optional
);
}@[Link("shell32")]
lib LibSHELL32
fun SHObjectProperties = SHObjectProperties(
hwnd : Void*, # HWND optional
shopObjectType : UInt32, # DWORD
pszObjectName : UInt16*, # LPCWSTR
pszPropertyPage : UInt16* # LPCWSTR optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SHObjectPropertiesNative = Int32 Function(Pointer<Void>, Uint32, Pointer<Utf16>, Pointer<Utf16>);
typedef SHObjectPropertiesDart = int Function(Pointer<Void>, int, Pointer<Utf16>, Pointer<Utf16>);
final SHObjectProperties = DynamicLibrary.open('SHELL32.dll')
.lookupFunction<SHObjectPropertiesNative, SHObjectPropertiesDart>('SHObjectProperties');
// hwnd : HWND optional -> Pointer<Void>
// shopObjectType : DWORD -> Uint32
// pszObjectName : LPCWSTR -> Pointer<Utf16>
// pszPropertyPage : LPCWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SHObjectProperties(
hwnd: THandle; // HWND optional
shopObjectType: DWORD; // DWORD
pszObjectName: PWideChar; // LPCWSTR
pszPropertyPage: PWideChar // LPCWSTR optional
): BOOL; stdcall;
external 'SHELL32.dll' name 'SHObjectProperties';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SHObjectProperties"
c_SHObjectProperties :: Ptr () -> Word32 -> CWString -> CWString -> IO CInt
-- hwnd : HWND optional -> Ptr ()
-- shopObjectType : DWORD -> Word32
-- pszObjectName : LPCWSTR -> CWString
-- pszPropertyPage : LPCWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let shobjectproperties =
foreign "SHObjectProperties"
((ptr void) @-> uint32_t @-> (ptr uint16_t) @-> (ptr uint16_t) @-> returning int32_t)
(* hwnd : HWND optional -> (ptr void) *)
(* shopObjectType : DWORD -> uint32_t *)
(* pszObjectName : LPCWSTR -> (ptr uint16_t) *)
(* pszPropertyPage : LPCWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)
(cffi:defcfun ("SHObjectProperties" shobject-properties :convention :stdcall) :int32
(hwnd :pointer) ; HWND optional
(shop-object-type :uint32) ; DWORD
(psz-object-name (:string :encoding :utf-16le)) ; LPCWSTR
(psz-property-page (:string :encoding :utf-16le))) ; LPCWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SHObjectProperties = Win32::API::More->new('SHELL32',
'BOOL SHObjectProperties(HANDLE hwnd, DWORD shopObjectType, LPCWSTR pszObjectName, LPCWSTR pszPropertyPage)');
# my $ret = $SHObjectProperties->Call($hwnd, $shopObjectType, $pszObjectName, $pszPropertyPage);
# hwnd : HWND optional -> HANDLE
# shopObjectType : DWORD -> DWORD
# pszObjectName : LPCWSTR -> LPCWSTR
# pszPropertyPage : LPCWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。