SHSetDefaultProperties
関数シェルアイテムに既定のプロパティを設定する。
シグネチャ
// SHELL32.dll
#include <windows.h>
HRESULT SHSetDefaultProperties(
HWND hwnd, // optional
IShellItem* psi,
DWORD dwFileOpFlags,
IFileOperationProgressSink* pfops // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwnd | HWND | inoptional |
| psi | IShellItem* | in |
| dwFileOpFlags | DWORD | in |
| pfops | IFileOperationProgressSink* | inoptional |
戻り値の型: HRESULT
各言語での呼び出し定義
// SHELL32.dll
#include <windows.h>
HRESULT SHSetDefaultProperties(
HWND hwnd, // optional
IShellItem* psi,
DWORD dwFileOpFlags,
IFileOperationProgressSink* pfops // optional
);[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern int SHSetDefaultProperties(
IntPtr hwnd, // HWND optional
IntPtr psi, // IShellItem*
uint dwFileOpFlags, // DWORD
IntPtr pfops // IFileOperationProgressSink* optional
);<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function SHSetDefaultProperties(
hwnd As IntPtr, ' HWND optional
psi As IntPtr, ' IShellItem*
dwFileOpFlags As UInteger, ' DWORD
pfops As IntPtr ' IFileOperationProgressSink* optional
) As Integer
End Function' hwnd : HWND optional
' psi : IShellItem*
' dwFileOpFlags : DWORD
' pfops : IFileOperationProgressSink* optional
Declare PtrSafe Function SHSetDefaultProperties Lib "shell32" ( _
ByVal hwnd As LongPtr, _
ByVal psi As LongPtr, _
ByVal dwFileOpFlags As Long, _
ByVal pfops As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHSetDefaultProperties = ctypes.windll.shell32.SHSetDefaultProperties
SHSetDefaultProperties.restype = ctypes.c_int
SHSetDefaultProperties.argtypes = [
wintypes.HANDLE, # hwnd : HWND optional
ctypes.c_void_p, # psi : IShellItem*
wintypes.DWORD, # dwFileOpFlags : DWORD
ctypes.c_void_p, # pfops : IFileOperationProgressSink* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
SHSetDefaultProperties = Fiddle::Function.new(
lib['SHSetDefaultProperties'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND optional
Fiddle::TYPE_VOIDP, # psi : IShellItem*
-Fiddle::TYPE_INT, # dwFileOpFlags : DWORD
Fiddle::TYPE_VOIDP, # pfops : IFileOperationProgressSink* optional
],
Fiddle::TYPE_INT)#[link(name = "shell32")]
extern "system" {
fn SHSetDefaultProperties(
hwnd: *mut core::ffi::c_void, // HWND optional
psi: *mut core::ffi::c_void, // IShellItem*
dwFileOpFlags: u32, // DWORD
pfops: *mut core::ffi::c_void // IFileOperationProgressSink* optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHELL32.dll")]
public static extern int SHSetDefaultProperties(IntPtr hwnd, IntPtr psi, uint dwFileOpFlags, IntPtr pfops);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHSetDefaultProperties' -Namespace Win32 -PassThru
# $api::SHSetDefaultProperties(hwnd, psi, dwFileOpFlags, pfops)#uselib "SHELL32.dll"
#func global SHSetDefaultProperties "SHSetDefaultProperties" sptr, sptr, sptr, sptr
; SHSetDefaultProperties hwnd, psi, dwFileOpFlags, pfops ; 戻り値は stat
; hwnd : HWND optional -> "sptr"
; psi : IShellItem* -> "sptr"
; dwFileOpFlags : DWORD -> "sptr"
; pfops : IFileOperationProgressSink* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHELL32.dll"
#cfunc global SHSetDefaultProperties "SHSetDefaultProperties" sptr, sptr, int, sptr
; res = SHSetDefaultProperties(hwnd, psi, dwFileOpFlags, pfops)
; hwnd : HWND optional -> "sptr"
; psi : IShellItem* -> "sptr"
; dwFileOpFlags : DWORD -> "int"
; pfops : IFileOperationProgressSink* optional -> "sptr"; HRESULT SHSetDefaultProperties(HWND hwnd, IShellItem* psi, DWORD dwFileOpFlags, IFileOperationProgressSink* pfops)
#uselib "SHELL32.dll"
#cfunc global SHSetDefaultProperties "SHSetDefaultProperties" intptr, intptr, int, intptr
; res = SHSetDefaultProperties(hwnd, psi, dwFileOpFlags, pfops)
; hwnd : HWND optional -> "intptr"
; psi : IShellItem* -> "intptr"
; dwFileOpFlags : DWORD -> "int"
; pfops : IFileOperationProgressSink* optional -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procSHSetDefaultProperties = shell32.NewProc("SHSetDefaultProperties")
)
// hwnd (HWND optional), psi (IShellItem*), dwFileOpFlags (DWORD), pfops (IFileOperationProgressSink* optional)
r1, _, err := procSHSetDefaultProperties.Call(
uintptr(hwnd),
uintptr(psi),
uintptr(dwFileOpFlags),
uintptr(pfops),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SHSetDefaultProperties(
hwnd: THandle; // HWND optional
psi: Pointer; // IShellItem*
dwFileOpFlags: DWORD; // DWORD
pfops: Pointer // IFileOperationProgressSink* optional
): Integer; stdcall;
external 'SHELL32.dll' name 'SHSetDefaultProperties';result := DllCall("SHELL32\SHSetDefaultProperties"
, "Ptr", hwnd ; HWND optional
, "Ptr", psi ; IShellItem*
, "UInt", dwFileOpFlags ; DWORD
, "Ptr", pfops ; IFileOperationProgressSink* optional
, "Int") ; return: HRESULT●SHSetDefaultProperties(hwnd, psi, dwFileOpFlags, pfops) = DLL("SHELL32.dll", "int SHSetDefaultProperties(void*, void*, dword, void*)")
# 呼び出し: SHSetDefaultProperties(hwnd, psi, dwFileOpFlags, pfops)
# hwnd : HWND optional -> "void*"
# psi : IShellItem* -> "void*"
# dwFileOpFlags : DWORD -> "dword"
# pfops : IFileOperationProgressSink* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。