ホーム › UI.Shell.PropertiesSystem › SHAddDefaultPropertiesByExt
SHAddDefaultPropertiesByExt
関数拡張子に基づく既定プロパティをストアに追加する。
シグネチャ
// SHELL32.dll
#include <windows.h>
HRESULT SHAddDefaultPropertiesByExt(
LPCWSTR pszExt,
IPropertyStore* pPropStore
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszExt | LPCWSTR | in | 対象のファイル拡張子を表すワイド文字列。先頭のドットを含む形式で指定する。 |
| pPropStore | IPropertyStore* | in | 既定プロパティを追加する先のIPropertyStoreインターフェイス。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// SHELL32.dll
#include <windows.h>
HRESULT SHAddDefaultPropertiesByExt(
LPCWSTR pszExt,
IPropertyStore* pPropStore
);[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern int SHAddDefaultPropertiesByExt(
[MarshalAs(UnmanagedType.LPWStr)] string pszExt, // LPCWSTR
IntPtr pPropStore // IPropertyStore*
);<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function SHAddDefaultPropertiesByExt(
<MarshalAs(UnmanagedType.LPWStr)> pszExt As String, ' LPCWSTR
pPropStore As IntPtr ' IPropertyStore*
) As Integer
End Function' pszExt : LPCWSTR
' pPropStore : IPropertyStore*
Declare PtrSafe Function SHAddDefaultPropertiesByExt Lib "shell32" ( _
ByVal pszExt As LongPtr, _
ByVal pPropStore As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHAddDefaultPropertiesByExt = ctypes.windll.shell32.SHAddDefaultPropertiesByExt
SHAddDefaultPropertiesByExt.restype = ctypes.c_int
SHAddDefaultPropertiesByExt.argtypes = [
wintypes.LPCWSTR, # pszExt : LPCWSTR
ctypes.c_void_p, # pPropStore : IPropertyStore*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
SHAddDefaultPropertiesByExt = Fiddle::Function.new(
lib['SHAddDefaultPropertiesByExt'],
[
Fiddle::TYPE_VOIDP, # pszExt : LPCWSTR
Fiddle::TYPE_VOIDP, # pPropStore : IPropertyStore*
],
Fiddle::TYPE_INT)#[link(name = "shell32")]
extern "system" {
fn SHAddDefaultPropertiesByExt(
pszExt: *const u16, // LPCWSTR
pPropStore: *mut core::ffi::c_void // IPropertyStore*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHELL32.dll")]
public static extern int SHAddDefaultPropertiesByExt([MarshalAs(UnmanagedType.LPWStr)] string pszExt, IntPtr pPropStore);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHAddDefaultPropertiesByExt' -Namespace Win32 -PassThru
# $api::SHAddDefaultPropertiesByExt(pszExt, pPropStore)#uselib "SHELL32.dll"
#func global SHAddDefaultPropertiesByExt "SHAddDefaultPropertiesByExt" sptr, sptr
; SHAddDefaultPropertiesByExt pszExt, pPropStore ; 戻り値は stat
; pszExt : LPCWSTR -> "sptr"
; pPropStore : IPropertyStore* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHELL32.dll"
#cfunc global SHAddDefaultPropertiesByExt "SHAddDefaultPropertiesByExt" wstr, sptr
; res = SHAddDefaultPropertiesByExt(pszExt, pPropStore)
; pszExt : LPCWSTR -> "wstr"
; pPropStore : IPropertyStore* -> "sptr"; HRESULT SHAddDefaultPropertiesByExt(LPCWSTR pszExt, IPropertyStore* pPropStore)
#uselib "SHELL32.dll"
#cfunc global SHAddDefaultPropertiesByExt "SHAddDefaultPropertiesByExt" wstr, intptr
; res = SHAddDefaultPropertiesByExt(pszExt, pPropStore)
; pszExt : LPCWSTR -> "wstr"
; pPropStore : IPropertyStore* -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procSHAddDefaultPropertiesByExt = shell32.NewProc("SHAddDefaultPropertiesByExt")
)
// pszExt (LPCWSTR), pPropStore (IPropertyStore*)
r1, _, err := procSHAddDefaultPropertiesByExt.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszExt))),
uintptr(pPropStore),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SHAddDefaultPropertiesByExt(
pszExt: PWideChar; // LPCWSTR
pPropStore: Pointer // IPropertyStore*
): Integer; stdcall;
external 'SHELL32.dll' name 'SHAddDefaultPropertiesByExt';result := DllCall("SHELL32\SHAddDefaultPropertiesByExt"
, "WStr", pszExt ; LPCWSTR
, "Ptr", pPropStore ; IPropertyStore*
, "Int") ; return: HRESULT●SHAddDefaultPropertiesByExt(pszExt, pPropStore) = DLL("SHELL32.dll", "int SHAddDefaultPropertiesByExt(char*, void*)")
# 呼び出し: SHAddDefaultPropertiesByExt(pszExt, pPropStore)
# pszExt : LPCWSTR -> "char*"
# pPropStore : IPropertyStore* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "shell32" fn SHAddDefaultPropertiesByExt(
pszExt: [*c]const u16, // LPCWSTR
pPropStore: ?*anyopaque // IPropertyStore*
) callconv(std.os.windows.WINAPI) i32;proc SHAddDefaultPropertiesByExt(
pszExt: WideCString, # LPCWSTR
pPropStore: pointer # IPropertyStore*
): int32 {.importc: "SHAddDefaultPropertiesByExt", stdcall, dynlib: "SHELL32.dll".}pragma(lib, "shell32");
extern(Windows)
int SHAddDefaultPropertiesByExt(
const(wchar)* pszExt, // LPCWSTR
void* pPropStore // IPropertyStore*
);ccall((:SHAddDefaultPropertiesByExt, "SHELL32.dll"), stdcall, Int32,
(Cwstring, Ptr{Cvoid}),
pszExt, pPropStore)
# pszExt : LPCWSTR -> Cwstring
# pPropStore : IPropertyStore* -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SHAddDefaultPropertiesByExt(
const uint16_t* pszExt,
void* pPropStore);
]]
local shell32 = ffi.load("shell32")
-- shell32.SHAddDefaultPropertiesByExt(pszExt, pPropStore)
-- pszExt : LPCWSTR
-- pPropStore : IPropertyStore*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const SHAddDefaultPropertiesByExt = lib.func('__stdcall', 'SHAddDefaultPropertiesByExt', 'int32_t', ['str16', 'void *']);
// SHAddDefaultPropertiesByExt(pszExt, pPropStore)
// pszExt : LPCWSTR -> 'str16'
// pPropStore : IPropertyStore* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SHELL32.dll", {
SHAddDefaultPropertiesByExt: { parameters: ["buffer", "pointer"], result: "i32" },
});
// lib.symbols.SHAddDefaultPropertiesByExt(pszExt, pPropStore)
// pszExt : LPCWSTR -> "buffer"
// pPropStore : IPropertyStore* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SHAddDefaultPropertiesByExt(
const uint16_t* pszExt,
void* pPropStore);
C, "SHELL32.dll");
// $ffi->SHAddDefaultPropertiesByExt(pszExt, pPropStore);
// pszExt : LPCWSTR
// pPropStore : IPropertyStore*
// 構造体/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);
int SHAddDefaultPropertiesByExt(
WString pszExt, // LPCWSTR
Pointer pPropStore // IPropertyStore*
);
}@[Link("shell32")]
lib LibSHELL32
fun SHAddDefaultPropertiesByExt = SHAddDefaultPropertiesByExt(
pszExt : UInt16*, # LPCWSTR
pPropStore : Void* # IPropertyStore*
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SHAddDefaultPropertiesByExtNative = Int32 Function(Pointer<Utf16>, Pointer<Void>);
typedef SHAddDefaultPropertiesByExtDart = int Function(Pointer<Utf16>, Pointer<Void>);
final SHAddDefaultPropertiesByExt = DynamicLibrary.open('SHELL32.dll')
.lookupFunction<SHAddDefaultPropertiesByExtNative, SHAddDefaultPropertiesByExtDart>('SHAddDefaultPropertiesByExt');
// pszExt : LPCWSTR -> Pointer<Utf16>
// pPropStore : IPropertyStore* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SHAddDefaultPropertiesByExt(
pszExt: PWideChar; // LPCWSTR
pPropStore: Pointer // IPropertyStore*
): Integer; stdcall;
external 'SHELL32.dll' name 'SHAddDefaultPropertiesByExt';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SHAddDefaultPropertiesByExt"
c_SHAddDefaultPropertiesByExt :: CWString -> Ptr () -> IO Int32
-- pszExt : LPCWSTR -> CWString
-- pPropStore : IPropertyStore* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let shadddefaultpropertiesbyext =
foreign "SHAddDefaultPropertiesByExt"
((ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* pszExt : LPCWSTR -> (ptr uint16_t) *)
(* pPropStore : IPropertyStore* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)
(cffi:defcfun ("SHAddDefaultPropertiesByExt" shadd-default-properties-by-ext :convention :stdcall) :int32
(psz-ext (:string :encoding :utf-16le)) ; LPCWSTR
(p-prop-store :pointer)) ; IPropertyStore*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SHAddDefaultPropertiesByExt = Win32::API::More->new('SHELL32',
'int SHAddDefaultPropertiesByExt(LPCWSTR pszExt, LPVOID pPropStore)');
# my $ret = $SHAddDefaultPropertiesByExt->Call($pszExt, $pPropStore);
# pszExt : LPCWSTR -> LPCWSTR
# pPropStore : IPropertyStore* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型