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