ホーム › System.ApplicationInstallationAndServicing › ActivateActCtx
ActivateActCtx
関数アクティベーションコンテキストを現在のスレッドで有効化する。
シグネチャ
// KERNEL32.dll
#include <windows.h>
BOOL ActivateActCtx(
HANDLE hActCtx, // optional
UINT_PTR* lpCookie
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hActCtx | HANDLE | inoutoptional |
| lpCookie | UINT_PTR* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// KERNEL32.dll
#include <windows.h>
BOOL ActivateActCtx(
HANDLE hActCtx, // optional
UINT_PTR* lpCookie
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool ActivateActCtx(
IntPtr hActCtx, // HANDLE optional, in/out
out UIntPtr lpCookie // UINT_PTR* out
);<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function ActivateActCtx(
hActCtx As IntPtr, ' HANDLE optional, in/out
<Out> ByRef lpCookie As UIntPtr ' UINT_PTR* out
) As Boolean
End Function' hActCtx : HANDLE optional, in/out
' lpCookie : UINT_PTR* out
Declare PtrSafe Function ActivateActCtx Lib "kernel32" ( _
ByVal hActCtx As LongPtr, _
ByRef lpCookie As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ActivateActCtx = ctypes.windll.kernel32.ActivateActCtx
ActivateActCtx.restype = wintypes.BOOL
ActivateActCtx.argtypes = [
wintypes.HANDLE, # hActCtx : HANDLE optional, in/out
ctypes.POINTER(ctypes.c_size_t), # lpCookie : UINT_PTR* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
ActivateActCtx = Fiddle::Function.new(
lib['ActivateActCtx'],
[
Fiddle::TYPE_VOIDP, # hActCtx : HANDLE optional, in/out
Fiddle::TYPE_VOIDP, # lpCookie : UINT_PTR* out
],
Fiddle::TYPE_INT)#[link(name = "kernel32")]
extern "system" {
fn ActivateActCtx(
hActCtx: *mut core::ffi::c_void, // HANDLE optional, in/out
lpCookie: *mut usize // UINT_PTR* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool ActivateActCtx(IntPtr hActCtx, out UIntPtr lpCookie);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_ActivateActCtx' -Namespace Win32 -PassThru
# $api::ActivateActCtx(hActCtx, lpCookie)#uselib "KERNEL32.dll"
#func global ActivateActCtx "ActivateActCtx" sptr, sptr
; ActivateActCtx hActCtx, varptr(lpCookie) ; 戻り値は stat
; hActCtx : HANDLE optional, in/out -> "sptr"
; lpCookie : UINT_PTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global ActivateActCtx "ActivateActCtx" sptr, var ; res = ActivateActCtx(hActCtx, lpCookie) ; hActCtx : HANDLE optional, in/out -> "sptr" ; lpCookie : UINT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global ActivateActCtx "ActivateActCtx" sptr, sptr ; res = ActivateActCtx(hActCtx, varptr(lpCookie)) ; hActCtx : HANDLE optional, in/out -> "sptr" ; lpCookie : UINT_PTR* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL ActivateActCtx(HANDLE hActCtx, UINT_PTR* lpCookie) #uselib "KERNEL32.dll" #cfunc global ActivateActCtx "ActivateActCtx" intptr, var ; res = ActivateActCtx(hActCtx, lpCookie) ; hActCtx : HANDLE optional, in/out -> "intptr" ; lpCookie : UINT_PTR* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL ActivateActCtx(HANDLE hActCtx, UINT_PTR* lpCookie) #uselib "KERNEL32.dll" #cfunc global ActivateActCtx "ActivateActCtx" intptr, intptr ; res = ActivateActCtx(hActCtx, varptr(lpCookie)) ; hActCtx : HANDLE optional, in/out -> "intptr" ; lpCookie : UINT_PTR* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procActivateActCtx = kernel32.NewProc("ActivateActCtx")
)
// hActCtx (HANDLE optional, in/out), lpCookie (UINT_PTR* out)
r1, _, err := procActivateActCtx.Call(
uintptr(hActCtx),
uintptr(lpCookie),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction ActivateActCtx(
hActCtx: THandle; // HANDLE optional, in/out
lpCookie: Pointer // UINT_PTR* out
): BOOL; stdcall;
external 'KERNEL32.dll' name 'ActivateActCtx';result := DllCall("KERNEL32\ActivateActCtx"
, "Ptr", hActCtx ; HANDLE optional, in/out
, "Ptr", lpCookie ; UINT_PTR* out
, "Int") ; return: BOOL●ActivateActCtx(hActCtx, lpCookie) = DLL("KERNEL32.dll", "bool ActivateActCtx(void*, void*)")
# 呼び出し: ActivateActCtx(hActCtx, lpCookie)
# hActCtx : HANDLE optional, in/out -> "void*"
# lpCookie : UINT_PTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。