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

MprAdminIsServiceRunning

関数
指定サーバーでルーターサービスが実行中かどうかを確認する。
DLLMPRAPI.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

BOOL MprAdminIsServiceRunning(
    LPWSTR lpwsServerName
);

パラメーター

名前方向
lpwsServerNameLPWSTRin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL MprAdminIsServiceRunning(
    LPWSTR lpwsServerName
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("MPRAPI.dll", ExactSpelling = true)]
static extern bool MprAdminIsServiceRunning(
    [MarshalAs(UnmanagedType.LPWStr)] string lpwsServerName   // LPWSTR
);
<DllImport("MPRAPI.dll", ExactSpelling:=True)>
Public Shared Function MprAdminIsServiceRunning(
    <MarshalAs(UnmanagedType.LPWStr)> lpwsServerName As String   ' LPWSTR
) As Boolean
End Function
' lpwsServerName : LPWSTR
Declare PtrSafe Function MprAdminIsServiceRunning Lib "mprapi" ( _
    ByVal lpwsServerName As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

MprAdminIsServiceRunning = ctypes.windll.mprapi.MprAdminIsServiceRunning
MprAdminIsServiceRunning.restype = wintypes.BOOL
MprAdminIsServiceRunning.argtypes = [
    wintypes.LPCWSTR,  # lpwsServerName : LPWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mprapi = windows.NewLazySystemDLL("MPRAPI.dll")
	procMprAdminIsServiceRunning = mprapi.NewProc("MprAdminIsServiceRunning")
)

// lpwsServerName (LPWSTR)
r1, _, err := procMprAdminIsServiceRunning.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpwsServerName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function MprAdminIsServiceRunning(
  lpwsServerName: PWideChar   // LPWSTR
): BOOL; stdcall;
  external 'MPRAPI.dll' name 'MprAdminIsServiceRunning';
result := DllCall("MPRAPI\MprAdminIsServiceRunning"
    , "WStr", lpwsServerName   ; LPWSTR
    , "Int")   ; return: BOOL
●MprAdminIsServiceRunning(lpwsServerName) = DLL("MPRAPI.dll", "bool MprAdminIsServiceRunning(char*)")
# 呼び出し: MprAdminIsServiceRunning(lpwsServerName)
# lpwsServerName : LPWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。