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