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

HcsModifyProcess

関数
コンピュートシステム内プロセスの設定を変更する。
DLLcomputecore.dll呼出規約winapi

シグネチャ

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

HRESULT HcsModifyProcess(
    HCS_PROCESS process,
    HCS_OPERATION operation,
    LPCWSTR settings
);

パラメーター

名前方向
processHCS_PROCESSin
operationHCS_OPERATIONin
settingsLPCWSTRin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT HcsModifyProcess(
    HCS_PROCESS process,
    HCS_OPERATION operation,
    LPCWSTR settings
);
[DllImport("computecore.dll", ExactSpelling = true)]
static extern int HcsModifyProcess(
    IntPtr process,   // HCS_PROCESS
    IntPtr operation,   // HCS_OPERATION
    [MarshalAs(UnmanagedType.LPWStr)] string settings   // LPCWSTR
);
<DllImport("computecore.dll", ExactSpelling:=True)>
Public Shared Function HcsModifyProcess(
    process As IntPtr,   ' HCS_PROCESS
    operation As IntPtr,   ' HCS_OPERATION
    <MarshalAs(UnmanagedType.LPWStr)> settings As String   ' LPCWSTR
) As Integer
End Function
' process : HCS_PROCESS
' operation : HCS_OPERATION
' settings : LPCWSTR
Declare PtrSafe Function HcsModifyProcess Lib "computecore" ( _
    ByVal process As LongPtr, _
    ByVal operation As LongPtr, _
    ByVal settings As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

HcsModifyProcess = ctypes.windll.computecore.HcsModifyProcess
HcsModifyProcess.restype = ctypes.c_int
HcsModifyProcess.argtypes = [
    wintypes.HANDLE,  # process : HCS_PROCESS
    wintypes.HANDLE,  # operation : HCS_OPERATION
    wintypes.LPCWSTR,  # settings : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('computecore.dll')
HcsModifyProcess = Fiddle::Function.new(
  lib['HcsModifyProcess'],
  [
    Fiddle::TYPE_VOIDP,  # process : HCS_PROCESS
    Fiddle::TYPE_VOIDP,  # operation : HCS_OPERATION
    Fiddle::TYPE_VOIDP,  # settings : LPCWSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "computecore")]
extern "system" {
    fn HcsModifyProcess(
        process: *mut core::ffi::c_void,  // HCS_PROCESS
        operation: *mut core::ffi::c_void,  // HCS_OPERATION
        settings: *const u16  // LPCWSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("computecore.dll")]
public static extern int HcsModifyProcess(IntPtr process, IntPtr operation, [MarshalAs(UnmanagedType.LPWStr)] string settings);
"@
$api = Add-Type -MemberDefinition $sig -Name 'computecore_HcsModifyProcess' -Namespace Win32 -PassThru
# $api::HcsModifyProcess(process, operation, settings)
#uselib "computecore.dll"
#func global HcsModifyProcess "HcsModifyProcess" sptr, sptr, sptr
; HcsModifyProcess process, operation, settings   ; 戻り値は stat
; process : HCS_PROCESS -> "sptr"
; operation : HCS_OPERATION -> "sptr"
; settings : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "computecore.dll"
#cfunc global HcsModifyProcess "HcsModifyProcess" sptr, sptr, wstr
; res = HcsModifyProcess(process, operation, settings)
; process : HCS_PROCESS -> "sptr"
; operation : HCS_OPERATION -> "sptr"
; settings : LPCWSTR -> "wstr"
; HRESULT HcsModifyProcess(HCS_PROCESS process, HCS_OPERATION operation, LPCWSTR settings)
#uselib "computecore.dll"
#cfunc global HcsModifyProcess "HcsModifyProcess" intptr, intptr, wstr
; res = HcsModifyProcess(process, operation, settings)
; process : HCS_PROCESS -> "intptr"
; operation : HCS_OPERATION -> "intptr"
; settings : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	computecore = windows.NewLazySystemDLL("computecore.dll")
	procHcsModifyProcess = computecore.NewProc("HcsModifyProcess")
)

// process (HCS_PROCESS), operation (HCS_OPERATION), settings (LPCWSTR)
r1, _, err := procHcsModifyProcess.Call(
	uintptr(process),
	uintptr(operation),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(settings))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function HcsModifyProcess(
  process: THandle;   // HCS_PROCESS
  operation: THandle;   // HCS_OPERATION
  settings: PWideChar   // LPCWSTR
): Integer; stdcall;
  external 'computecore.dll' name 'HcsModifyProcess';
result := DllCall("computecore\HcsModifyProcess"
    , "Ptr", process   ; HCS_PROCESS
    , "Ptr", operation   ; HCS_OPERATION
    , "WStr", settings   ; LPCWSTR
    , "Int")   ; return: HRESULT
●HcsModifyProcess(process, operation, settings) = DLL("computecore.dll", "int HcsModifyProcess(void*, void*, char*)")
# 呼び出し: HcsModifyProcess(process, operation, settings)
# process : HCS_PROCESS -> "void*"
# operation : HCS_OPERATION -> "void*"
# settings : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。