Win32 API 日本語リファレンス
ホームNetworkManagement.Rras › MprAdminSendUserMessage

MprAdminSendUserMessage

関数
RASサーバーから接続中のユーザーにメッセージを送信する。
DLLMPRAPI.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD MprAdminSendUserMessage(
    INT_PTR hMprServer,
    HANDLE hConnection,
    LPWSTR lpwszMessage
);

パラメーター

名前方向
hMprServerINT_PTRin
hConnectionHANDLEin
lpwszMessageLPWSTRin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MprAdminSendUserMessage(
    INT_PTR hMprServer,
    HANDLE hConnection,
    LPWSTR lpwszMessage
);
[DllImport("MPRAPI.dll", ExactSpelling = true)]
static extern uint MprAdminSendUserMessage(
    IntPtr hMprServer,   // INT_PTR
    IntPtr hConnection,   // HANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string lpwszMessage   // LPWSTR
);
<DllImport("MPRAPI.dll", ExactSpelling:=True)>
Public Shared Function MprAdminSendUserMessage(
    hMprServer As IntPtr,   ' INT_PTR
    hConnection As IntPtr,   ' HANDLE
    <MarshalAs(UnmanagedType.LPWStr)> lpwszMessage As String   ' LPWSTR
) As UInteger
End Function
' hMprServer : INT_PTR
' hConnection : HANDLE
' lpwszMessage : LPWSTR
Declare PtrSafe Function MprAdminSendUserMessage Lib "mprapi" ( _
    ByVal hMprServer As LongPtr, _
    ByVal hConnection As LongPtr, _
    ByVal lpwszMessage As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MprAdminSendUserMessage = ctypes.windll.mprapi.MprAdminSendUserMessage
MprAdminSendUserMessage.restype = wintypes.DWORD
MprAdminSendUserMessage.argtypes = [
    ctypes.c_ssize_t,  # hMprServer : INT_PTR
    wintypes.HANDLE,  # hConnection : HANDLE
    wintypes.LPCWSTR,  # lpwszMessage : LPWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MPRAPI.dll')
MprAdminSendUserMessage = Fiddle::Function.new(
  lib['MprAdminSendUserMessage'],
  [
    Fiddle::TYPE_INTPTR_T,  # hMprServer : INT_PTR
    Fiddle::TYPE_VOIDP,  # hConnection : HANDLE
    Fiddle::TYPE_VOIDP,  # lpwszMessage : LPWSTR
  ],
  -Fiddle::TYPE_INT)
#[link(name = "mprapi")]
extern "system" {
    fn MprAdminSendUserMessage(
        hMprServer: isize,  // INT_PTR
        hConnection: *mut core::ffi::c_void,  // HANDLE
        lpwszMessage: *mut u16  // LPWSTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MPRAPI.dll")]
public static extern uint MprAdminSendUserMessage(IntPtr hMprServer, IntPtr hConnection, [MarshalAs(UnmanagedType.LPWStr)] string lpwszMessage);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MPRAPI_MprAdminSendUserMessage' -Namespace Win32 -PassThru
# $api::MprAdminSendUserMessage(hMprServer, hConnection, lpwszMessage)
#uselib "MPRAPI.dll"
#func global MprAdminSendUserMessage "MprAdminSendUserMessage" sptr, sptr, sptr
; MprAdminSendUserMessage hMprServer, hConnection, lpwszMessage   ; 戻り値は stat
; hMprServer : INT_PTR -> "sptr"
; hConnection : HANDLE -> "sptr"
; lpwszMessage : LPWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "MPRAPI.dll"
#cfunc global MprAdminSendUserMessage "MprAdminSendUserMessage" sptr, sptr, wstr
; res = MprAdminSendUserMessage(hMprServer, hConnection, lpwszMessage)
; hMprServer : INT_PTR -> "sptr"
; hConnection : HANDLE -> "sptr"
; lpwszMessage : LPWSTR -> "wstr"
; DWORD MprAdminSendUserMessage(INT_PTR hMprServer, HANDLE hConnection, LPWSTR lpwszMessage)
#uselib "MPRAPI.dll"
#cfunc global MprAdminSendUserMessage "MprAdminSendUserMessage" intptr, intptr, wstr
; res = MprAdminSendUserMessage(hMprServer, hConnection, lpwszMessage)
; hMprServer : INT_PTR -> "intptr"
; hConnection : HANDLE -> "intptr"
; lpwszMessage : LPWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mprapi = windows.NewLazySystemDLL("MPRAPI.dll")
	procMprAdminSendUserMessage = mprapi.NewProc("MprAdminSendUserMessage")
)

// hMprServer (INT_PTR), hConnection (HANDLE), lpwszMessage (LPWSTR)
r1, _, err := procMprAdminSendUserMessage.Call(
	uintptr(hMprServer),
	uintptr(hConnection),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpwszMessage))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function MprAdminSendUserMessage(
  hMprServer: NativeInt;   // INT_PTR
  hConnection: THandle;   // HANDLE
  lpwszMessage: PWideChar   // LPWSTR
): DWORD; stdcall;
  external 'MPRAPI.dll' name 'MprAdminSendUserMessage';
result := DllCall("MPRAPI\MprAdminSendUserMessage"
    , "Ptr", hMprServer   ; INT_PTR
    , "Ptr", hConnection   ; HANDLE
    , "WStr", lpwszMessage   ; LPWSTR
    , "UInt")   ; return: DWORD
●MprAdminSendUserMessage(hMprServer, hConnection, lpwszMessage) = DLL("MPRAPI.dll", "dword MprAdminSendUserMessage(int, void*, char*)")
# 呼び出し: MprAdminSendUserMessage(hMprServer, hConnection, lpwszMessage)
# hMprServer : INT_PTR -> "int"
# hConnection : HANDLE -> "void*"
# lpwszMessage : LPWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。