Win32 API 日本語リファレンス
ホームSystem.Js › JsSetProperty

JsSetProperty

関数
オブジェクトの指定プロパティに値を設定する。
DLLchakra.dll呼出規約winapi

シグネチャ

// chakra.dll
#include <windows.h>

JsErrorCode JsSetProperty(
    void* object,
    void* propertyId,
    void* value,
    BYTE useStrictRules
);

パラメーター

名前方向説明
objectvoid*inプロパティを設定する対象のオブジェクト。
propertyIdvoid*in設定するプロパティの識別子(JsPropertyIdRef)。
valuevoid*inプロパティに設定する値。
useStrictRulesBYTEin厳格モード(strict)の規則を適用するかの真偽値。0以外で厳格扱い。

戻り値の型: JsErrorCode

各言語での呼び出し定義

// chakra.dll
#include <windows.h>

JsErrorCode JsSetProperty(
    void* object,
    void* propertyId,
    void* value,
    BYTE useStrictRules
);
[DllImport("chakra.dll", ExactSpelling = true)]
static extern uint JsSetProperty(
    IntPtr object,   // void*
    IntPtr propertyId,   // void*
    IntPtr value,   // void*
    byte useStrictRules   // BYTE
);
<DllImport("chakra.dll", ExactSpelling:=True)>
Public Shared Function JsSetProperty(
    [object] As IntPtr,   ' void*
    propertyId As IntPtr,   ' void*
    value As IntPtr,   ' void*
    useStrictRules As Byte   ' BYTE
) As UInteger
End Function
' object : void*
' propertyId : void*
' value : void*
' useStrictRules : BYTE
Declare PtrSafe Function JsSetProperty Lib "chakra" ( _
    ByVal object As LongPtr, _
    ByVal propertyId As LongPtr, _
    ByVal value As LongPtr, _
    ByVal useStrictRules As Byte) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

JsSetProperty = ctypes.windll.chakra.JsSetProperty
JsSetProperty.restype = wintypes.DWORD
JsSetProperty.argtypes = [
    ctypes.POINTER(None),  # object : void*
    ctypes.POINTER(None),  # propertyId : void*
    ctypes.POINTER(None),  # value : void*
    ctypes.c_ubyte,  # useStrictRules : BYTE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('chakra.dll')
JsSetProperty = Fiddle::Function.new(
  lib['JsSetProperty'],
  [
    Fiddle::TYPE_VOIDP,  # object : void*
    Fiddle::TYPE_VOIDP,  # propertyId : void*
    Fiddle::TYPE_VOIDP,  # value : void*
    -Fiddle::TYPE_CHAR,  # useStrictRules : BYTE
  ],
  -Fiddle::TYPE_INT)
#[link(name = "chakra")]
extern "system" {
    fn JsSetProperty(
        object: *mut (),  // void*
        propertyId: *mut (),  // void*
        value: *mut (),  // void*
        useStrictRules: u8  // BYTE
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("chakra.dll")]
public static extern uint JsSetProperty(IntPtr object, IntPtr propertyId, IntPtr value, byte useStrictRules);
"@
$api = Add-Type -MemberDefinition $sig -Name 'chakra_JsSetProperty' -Namespace Win32 -PassThru
# $api::JsSetProperty(object, propertyId, value, useStrictRules)
#uselib "chakra.dll"
#func global JsSetProperty "JsSetProperty" sptr, sptr, sptr, sptr
; JsSetProperty object, propertyId, value, useStrictRules   ; 戻り値は stat
; object : void* -> "sptr"
; propertyId : void* -> "sptr"
; value : void* -> "sptr"
; useStrictRules : BYTE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "chakra.dll"
#cfunc global JsSetProperty "JsSetProperty" sptr, sptr, sptr, int
; res = JsSetProperty(object, propertyId, value, useStrictRules)
; object : void* -> "sptr"
; propertyId : void* -> "sptr"
; value : void* -> "sptr"
; useStrictRules : BYTE -> "int"
; JsErrorCode JsSetProperty(void* object, void* propertyId, void* value, BYTE useStrictRules)
#uselib "chakra.dll"
#cfunc global JsSetProperty "JsSetProperty" intptr, intptr, intptr, int
; res = JsSetProperty(object, propertyId, value, useStrictRules)
; object : void* -> "intptr"
; propertyId : void* -> "intptr"
; value : void* -> "intptr"
; useStrictRules : BYTE -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	chakra = windows.NewLazySystemDLL("chakra.dll")
	procJsSetProperty = chakra.NewProc("JsSetProperty")
)

// object (void*), propertyId (void*), value (void*), useStrictRules (BYTE)
r1, _, err := procJsSetProperty.Call(
	uintptr(object),
	uintptr(propertyId),
	uintptr(value),
	uintptr(useStrictRules),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // JsErrorCode
function JsSetProperty(
  object: Pointer;   // void*
  propertyId: Pointer;   // void*
  value: Pointer;   // void*
  useStrictRules: Byte   // BYTE
): DWORD; stdcall;
  external 'chakra.dll' name 'JsSetProperty';
result := DllCall("chakra\JsSetProperty"
    , "Ptr", object   ; void*
    , "Ptr", propertyId   ; void*
    , "Ptr", value   ; void*
    , "UChar", useStrictRules   ; BYTE
    , "UInt")   ; return: JsErrorCode
●JsSetProperty(object, propertyId, value, useStrictRules) = DLL("chakra.dll", "dword JsSetProperty(void*, void*, void*, byte)")
# 呼び出し: JsSetProperty(object, propertyId, value, useStrictRules)
# object : void* -> "void*"
# propertyId : void* -> "void*"
# value : void* -> "void*"
# useStrictRules : BYTE -> "byte"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "chakra" fn JsSetProperty(
    object: ?*anyopaque, // void*
    propertyId: ?*anyopaque, // void*
    value: ?*anyopaque, // void*
    useStrictRules: u8 // BYTE
) callconv(std.os.windows.WINAPI) u32;
proc JsSetProperty(
    `object`: pointer,  # void*
    propertyId: pointer,  # void*
    value: pointer,  # void*
    useStrictRules: uint8  # BYTE
): uint32 {.importc: "JsSetProperty", stdcall, dynlib: "chakra.dll".}
pragma(lib, "chakra");
extern(Windows)
uint JsSetProperty(
    void* object,   // void*
    void* propertyId,   // void*
    void* value,   // void*
    ubyte useStrictRules   // BYTE
);
ccall((:JsSetProperty, "chakra.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{Cvoid}, UInt8),
      object, propertyId, value, useStrictRules)
# object : void* -> Ptr{Cvoid}
# propertyId : void* -> Ptr{Cvoid}
# value : void* -> Ptr{Cvoid}
# useStrictRules : BYTE -> UInt8
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t JsSetProperty(
    void* object,
    void* propertyId,
    void* value,
    uint8_t useStrictRules);
]]
local chakra = ffi.load("chakra")
-- chakra.JsSetProperty(object, propertyId, value, useStrictRules)
-- object : void*
-- propertyId : void*
-- value : void*
-- useStrictRules : BYTE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('chakra.dll');
const JsSetProperty = lib.func('__stdcall', 'JsSetProperty', 'uint32_t', ['void *', 'void *', 'void *', 'uint8_t']);
// JsSetProperty(object, propertyId, value, useStrictRules)
// object : void* -> 'void *'
// propertyId : void* -> 'void *'
// value : void* -> 'void *'
// useStrictRules : BYTE -> 'uint8_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("chakra.dll", {
  JsSetProperty: { parameters: ["pointer", "pointer", "pointer", "u8"], result: "u32" },
});
// lib.symbols.JsSetProperty(object, propertyId, value, useStrictRules)
// object : void* -> "pointer"
// propertyId : void* -> "pointer"
// value : void* -> "pointer"
// useStrictRules : BYTE -> "u8"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t JsSetProperty(
    void* object,
    void* propertyId,
    void* value,
    uint8_t useStrictRules);
C, "chakra.dll");
// $ffi->JsSetProperty(object, propertyId, value, useStrictRules);
// object : void*
// propertyId : void*
// value : void*
// useStrictRules : BYTE
// 構造体/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 Chakra extends StdCallLibrary {
    Chakra INSTANCE = Native.load("chakra", Chakra.class);
    int JsSetProperty(
        Pointer object,   // void*
        Pointer propertyId,   // void*
        Pointer value,   // void*
        byte useStrictRules   // BYTE
    );
}
@[Link("chakra")]
lib Libchakra
  fun JsSetProperty = JsSetProperty(
    object : Void*,   # void*
    propertyId : Void*,   # void*
    value : Void*,   # void*
    useStrictRules : UInt8   # BYTE
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef JsSetPropertyNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Uint8);
typedef JsSetPropertyDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, int);
final JsSetProperty = DynamicLibrary.open('chakra.dll')
    .lookupFunction<JsSetPropertyNative, JsSetPropertyDart>('JsSetProperty');
// object : void* -> Pointer<Void>
// propertyId : void* -> Pointer<Void>
// value : void* -> Pointer<Void>
// useStrictRules : BYTE -> Uint8
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function JsSetProperty(
  object: Pointer;   // void*
  propertyId: Pointer;   // void*
  value: Pointer;   // void*
  useStrictRules: Byte   // BYTE
): DWORD; stdcall;
  external 'chakra.dll' name 'JsSetProperty';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "JsSetProperty"
  c_JsSetProperty :: Ptr () -> Ptr () -> Ptr () -> Word8 -> IO Word32
-- object : void* -> Ptr ()
-- propertyId : void* -> Ptr ()
-- value : void* -> Ptr ()
-- useStrictRules : BYTE -> Word8
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let jssetproperty =
  foreign "JsSetProperty"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> uint8_t @-> returning uint32_t)
(* object : void* -> (ptr void) *)
(* propertyId : void* -> (ptr void) *)
(* value : void* -> (ptr void) *)
(* useStrictRules : BYTE -> uint8_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library chakra (t "chakra.dll"))
(cffi:use-foreign-library chakra)

(cffi:defcfun ("JsSetProperty" js-set-property :convention :stdcall) :uint32
  (object :pointer)   ; void*
  (property-id :pointer)   ; void*
  (value :pointer)   ; void*
  (use-strict-rules :uint8))   ; BYTE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $JsSetProperty = Win32::API::More->new('chakra',
    'DWORD JsSetProperty(LPVOID object, LPVOID propertyId, LPVOID value, BYTE useStrictRules)');
# my $ret = $JsSetProperty->Call($object, $propertyId, $value, $useStrictRules);
# object : void* -> LPVOID
# propertyId : void* -> LPVOID
# value : void* -> LPVOID
# useStrictRules : BYTE -> BYTE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型