ホーム › System.ComponentServices › RecycleSurrogate
RecycleSurrogate
関数指定した理由コードでサロゲートプロセスのリサイクルを要求する。
シグネチャ
// comsvcs.dll
#include <windows.h>
HRESULT RecycleSurrogate(
INT lReasonCode
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lReasonCode | INT | in | サロゲートプロセスをリサイクル(再生成要求)する理由を示すコード。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// comsvcs.dll
#include <windows.h>
HRESULT RecycleSurrogate(
INT lReasonCode
);[DllImport("comsvcs.dll", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)]
static extern int RecycleSurrogate(
int lReasonCode // INT
);<DllImport("comsvcs.dll", ExactSpelling:=True, CallingConvention:=CallingConvention.Cdecl)>
Public Shared Function RecycleSurrogate(
lReasonCode As Integer ' INT
) As Integer
End Function' lReasonCode : INT
Declare PtrSafe Function RecycleSurrogate Lib "comsvcs" ( _
ByVal lReasonCode As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RecycleSurrogate = ctypes.cdll.comsvcs.RecycleSurrogate
RecycleSurrogate.restype = ctypes.c_int
RecycleSurrogate.argtypes = [
ctypes.c_int, # lReasonCode : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('comsvcs.dll')
RecycleSurrogate = Fiddle::Function.new(
lib['RecycleSurrogate'],
[
Fiddle::TYPE_INT, # lReasonCode : INT
],
Fiddle::TYPE_INT, Fiddle::Function::CDECL)#[link(name = "comsvcs")]
extern "C" {
fn RecycleSurrogate(
lReasonCode: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("comsvcs.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int RecycleSurrogate(int lReasonCode);
"@
$api = Add-Type -MemberDefinition $sig -Name 'comsvcs_RecycleSurrogate' -Namespace Win32 -PassThru
# $api::RecycleSurrogate(lReasonCode)#uselib "comsvcs.dll"
#func global RecycleSurrogate "RecycleSurrogate" sptr
; RecycleSurrogate lReasonCode ; 戻り値は stat
; lReasonCode : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "comsvcs.dll"
#cfunc global RecycleSurrogate "RecycleSurrogate" int
; res = RecycleSurrogate(lReasonCode)
; lReasonCode : INT -> "int"; HRESULT RecycleSurrogate(INT lReasonCode)
#uselib "comsvcs.dll"
#cfunc global RecycleSurrogate "RecycleSurrogate" int
; res = RecycleSurrogate(lReasonCode)
; lReasonCode : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
comsvcs = windows.NewLazySystemDLL("comsvcs.dll")
procRecycleSurrogate = comsvcs.NewProc("RecycleSurrogate")
)
// lReasonCode (INT)
r1, _, err := procRecycleSurrogate.Call(
uintptr(lReasonCode),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction RecycleSurrogate(
lReasonCode: Integer // INT
): Integer; cdecl;
external 'comsvcs.dll' name 'RecycleSurrogate';result := DllCall("comsvcs\RecycleSurrogate"
, "Int", lReasonCode ; INT
, "Cdecl Int") ; return: HRESULT●RecycleSurrogate(lReasonCode) = DLL("comsvcs.dll", "int RecycleSurrogate(int)")
# 呼び出し: RecycleSurrogate(lReasonCode)
# lReasonCode : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※cdecl関数。DLL()宣言はstdcall前提。cdeclは EXEC_PTR(`cdecl`,…) を使用。const std = @import("std");
extern "comsvcs" fn RecycleSurrogate(
lReasonCode: i32 // INT
) callconv(.c) i32;proc RecycleSurrogate(
lReasonCode: int32 # INT
): int32 {.importc: "RecycleSurrogate", cdecl, dynlib: "comsvcs.dll".}pragma(lib, "comsvcs");
extern(C)
int RecycleSurrogate(
int lReasonCode // INT
);ccall((:RecycleSurrogate, "comsvcs.dll"), Int32,
(Int32,),
lReasonCode)
# lReasonCode : INT -> Int32local ffi = require("ffi")
ffi.cdef[[
int32_t RecycleSurrogate(
int32_t lReasonCode);
]]
local comsvcs = ffi.load("comsvcs")
-- comsvcs.RecycleSurrogate(lReasonCode)
-- lReasonCode : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('comsvcs.dll');
const RecycleSurrogate = lib.func('__cdecl', 'RecycleSurrogate', 'int32_t', ['int32_t']);
// RecycleSurrogate(lReasonCode)
// lReasonCode : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("comsvcs.dll", {
RecycleSurrogate: { parameters: ["i32"], result: "i32" },
});
// lib.symbols.RecycleSurrogate(lReasonCode)
// lReasonCode : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RecycleSurrogate(
int32_t lReasonCode);
C, "comsvcs.dll");
// $ffi->RecycleSurrogate(lReasonCode);
// lReasonCode : INT
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Comsvcs extends Library {
Comsvcs INSTANCE = Native.load("comsvcs", Comsvcs.class);
int RecycleSurrogate(
int lReasonCode // INT
);
}@[Link("comsvcs")]
lib Libcomsvcs
fun RecycleSurrogate = RecycleSurrogate(
lReasonCode : Int32 # INT
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RecycleSurrogateNative = Int32 Function(Int32);
typedef RecycleSurrogateDart = int Function(int);
final RecycleSurrogate = DynamicLibrary.open('comsvcs.dll')
.lookupFunction<RecycleSurrogateNative, RecycleSurrogateDart>('RecycleSurrogate');
// lReasonCode : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RecycleSurrogate(
lReasonCode: Integer // INT
): Integer; cdecl;
external 'comsvcs.dll' name 'RecycleSurrogate';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import ccall safe "RecycleSurrogate"
c_RecycleSurrogate :: Int32 -> IO Int32
-- lReasonCode : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let recyclesurrogate =
foreign "RecycleSurrogate"
(int32_t @-> returning int32_t)
(* lReasonCode : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library comsvcs (t "comsvcs.dll"))
(cffi:use-foreign-library comsvcs)
(cffi:defcfun ("RecycleSurrogate" recycle-surrogate :convention :cdecl) :int32
(l-reason-code :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RecycleSurrogate = Win32::API::More->new('comsvcs',
'int RecycleSurrogate(int lReasonCode)');
# my $ret = $RecycleSurrogate->Call($lReasonCode);
# lReasonCode : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。