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

CoRegisterSurrogate

関数
DLLサーバーをホストするサロゲートプロセスを登録する。
DLLOLE32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT CoRegisterSurrogate(
    ISurrogate* pSurrogate
);

パラメーター

名前方向
pSurrogateISurrogate*in

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT CoRegisterSurrogate(
    ISurrogate* pSurrogate
);
[DllImport("OLE32.dll", ExactSpelling = true)]
static extern int CoRegisterSurrogate(
    IntPtr pSurrogate   // ISurrogate*
);
<DllImport("OLE32.dll", ExactSpelling:=True)>
Public Shared Function CoRegisterSurrogate(
    pSurrogate As IntPtr   ' ISurrogate*
) As Integer
End Function
' pSurrogate : ISurrogate*
Declare PtrSafe Function CoRegisterSurrogate Lib "ole32" ( _
    ByVal pSurrogate As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CoRegisterSurrogate = ctypes.windll.ole32.CoRegisterSurrogate
CoRegisterSurrogate.restype = ctypes.c_int
CoRegisterSurrogate.argtypes = [
    ctypes.c_void_p,  # pSurrogate : ISurrogate*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ole32 = windows.NewLazySystemDLL("OLE32.dll")
	procCoRegisterSurrogate = ole32.NewProc("CoRegisterSurrogate")
)

// pSurrogate (ISurrogate*)
r1, _, err := procCoRegisterSurrogate.Call(
	uintptr(pSurrogate),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function CoRegisterSurrogate(
  pSurrogate: Pointer   // ISurrogate*
): Integer; stdcall;
  external 'OLE32.dll' name 'CoRegisterSurrogate';
result := DllCall("OLE32\CoRegisterSurrogate"
    , "Ptr", pSurrogate   ; ISurrogate*
    , "Int")   ; return: HRESULT
●CoRegisterSurrogate(pSurrogate) = DLL("OLE32.dll", "int CoRegisterSurrogate(void*)")
# 呼び出し: CoRegisterSurrogate(pSurrogate)
# pSurrogate : ISurrogate* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。