ホーム › System.WindowsProgramming › EnableProcessOptionalXStateFeatures
EnableProcessOptionalXStateFeatures
関数プロセスで任意のXStateフィーチャーを有効化する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL EnableProcessOptionalXStateFeatures(
ULONGLONG Features
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Features | ULONGLONG | in | プロセスで有効化するオプションのXState機能を表すビットマスク。 |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL EnableProcessOptionalXStateFeatures(
ULONGLONG Features
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern bool EnableProcessOptionalXStateFeatures(
ulong Features // ULONGLONG
);<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function EnableProcessOptionalXStateFeatures(
Features As ULong ' ULONGLONG
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' Features : ULONGLONG
Declare PtrSafe Function EnableProcessOptionalXStateFeatures Lib "kernel32" ( _
ByVal Features As LongLong) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
EnableProcessOptionalXStateFeatures = ctypes.windll.kernel32.EnableProcessOptionalXStateFeatures
EnableProcessOptionalXStateFeatures.restype = wintypes.BOOL
EnableProcessOptionalXStateFeatures.argtypes = [
ctypes.c_ulonglong, # Features : ULONGLONG
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
EnableProcessOptionalXStateFeatures = Fiddle::Function.new(
lib['EnableProcessOptionalXStateFeatures'],
[
-Fiddle::TYPE_LONG_LONG, # Features : ULONGLONG
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn EnableProcessOptionalXStateFeatures(
Features: u64 // ULONGLONG
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll")]
public static extern bool EnableProcessOptionalXStateFeatures(ulong Features);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_EnableProcessOptionalXStateFeatures' -Namespace Win32 -PassThru
# $api::EnableProcessOptionalXStateFeatures(Features)#uselib "KERNEL32.dll"
#func global EnableProcessOptionalXStateFeatures "EnableProcessOptionalXStateFeatures" sptr
; EnableProcessOptionalXStateFeatures Features ; 戻り値は stat
; Features : ULONGLONG -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global EnableProcessOptionalXStateFeatures "EnableProcessOptionalXStateFeatures" int64
; res = EnableProcessOptionalXStateFeatures(Features)
; Features : ULONGLONG -> "int64"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。; BOOL EnableProcessOptionalXStateFeatures(ULONGLONG Features)
#uselib "KERNEL32.dll"
#cfunc global EnableProcessOptionalXStateFeatures "EnableProcessOptionalXStateFeatures" int64
; res = EnableProcessOptionalXStateFeatures(Features)
; Features : ULONGLONG -> "int64"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procEnableProcessOptionalXStateFeatures = kernel32.NewProc("EnableProcessOptionalXStateFeatures")
)
// Features (ULONGLONG)
r1, _, err := procEnableProcessOptionalXStateFeatures.Call(
uintptr(Features),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction EnableProcessOptionalXStateFeatures(
Features: UInt64 // ULONGLONG
): BOOL; stdcall;
external 'KERNEL32.dll' name 'EnableProcessOptionalXStateFeatures';result := DllCall("KERNEL32\EnableProcessOptionalXStateFeatures"
, "Int64", Features ; ULONGLONG
, "Int") ; return: BOOL●EnableProcessOptionalXStateFeatures(Features) = DLL("KERNEL32.dll", "bool EnableProcessOptionalXStateFeatures(qword)")
# 呼び出し: EnableProcessOptionalXStateFeatures(Features)
# Features : ULONGLONG -> "qword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn EnableProcessOptionalXStateFeatures(
Features: u64 // ULONGLONG
) callconv(std.os.windows.WINAPI) i32;proc EnableProcessOptionalXStateFeatures(
Features: uint64 # ULONGLONG
): int32 {.importc: "EnableProcessOptionalXStateFeatures", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
int EnableProcessOptionalXStateFeatures(
ulong Features // ULONGLONG
);ccall((:EnableProcessOptionalXStateFeatures, "KERNEL32.dll"), stdcall, Int32,
(UInt64,),
Features)
# Features : ULONGLONG -> UInt64
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t EnableProcessOptionalXStateFeatures(
uint64_t Features);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.EnableProcessOptionalXStateFeatures(Features)
-- Features : ULONGLONG
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const EnableProcessOptionalXStateFeatures = lib.func('__stdcall', 'EnableProcessOptionalXStateFeatures', 'int32_t', ['uint64_t']);
// EnableProcessOptionalXStateFeatures(Features)
// Features : ULONGLONG -> 'uint64_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
EnableProcessOptionalXStateFeatures: { parameters: ["u64"], result: "i32" },
});
// lib.symbols.EnableProcessOptionalXStateFeatures(Features)
// Features : ULONGLONG -> "u64"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t EnableProcessOptionalXStateFeatures(
uint64_t Features);
C, "KERNEL32.dll");
// $ffi->EnableProcessOptionalXStateFeatures(Features);
// Features : ULONGLONG
// 構造体/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 Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class);
boolean EnableProcessOptionalXStateFeatures(
long Features // ULONGLONG
);
}@[Link("kernel32")]
lib LibKERNEL32
fun EnableProcessOptionalXStateFeatures = EnableProcessOptionalXStateFeatures(
Features : UInt64 # ULONGLONG
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef EnableProcessOptionalXStateFeaturesNative = Int32 Function(Uint64);
typedef EnableProcessOptionalXStateFeaturesDart = int Function(int);
final EnableProcessOptionalXStateFeatures = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<EnableProcessOptionalXStateFeaturesNative, EnableProcessOptionalXStateFeaturesDart>('EnableProcessOptionalXStateFeatures');
// Features : ULONGLONG -> Uint64
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function EnableProcessOptionalXStateFeatures(
Features: UInt64 // ULONGLONG
): BOOL; stdcall;
external 'KERNEL32.dll' name 'EnableProcessOptionalXStateFeatures';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "EnableProcessOptionalXStateFeatures"
c_EnableProcessOptionalXStateFeatures :: Word64 -> IO CInt
-- Features : ULONGLONG -> Word64
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let enableprocessoptionalxstatefeatures =
foreign "EnableProcessOptionalXStateFeatures"
(uint64_t @-> returning int32_t)
(* Features : ULONGLONG -> uint64_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("EnableProcessOptionalXStateFeatures" enable-process-optional-xstate-features :convention :stdcall) :int32
(features :uint64)) ; ULONGLONG
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $EnableProcessOptionalXStateFeatures = Win32::API::More->new('KERNEL32',
'BOOL EnableProcessOptionalXStateFeatures(UINT64 Features)');
# my $ret = $EnableProcessOptionalXStateFeatures->Call($Features);
# Features : ULONGLONG -> UINT64
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。