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