ホーム › NetworkManagement.Rras › MprAdminIsServiceRunning
MprAdminIsServiceRunning
関数指定サーバーでルーターサービスが実行中かどうかを確認する。
シグネチャ
// MPRAPI.dll
#include <windows.h>
BOOL MprAdminIsServiceRunning(
LPWSTR lpwsServerName
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpwsServerName | LPWSTR | in | RRASサービスの稼働確認を行う対象サーバー名の文字列。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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 // BOOLfunction 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)。const std = @import("std");
extern "mprapi" fn MprAdminIsServiceRunning(
lpwsServerName: [*c]const u16 // LPWSTR
) callconv(std.os.windows.WINAPI) i32;proc MprAdminIsServiceRunning(
lpwsServerName: WideCString # LPWSTR
): int32 {.importc: "MprAdminIsServiceRunning", stdcall, dynlib: "MPRAPI.dll".}pragma(lib, "mprapi");
extern(Windows)
int MprAdminIsServiceRunning(
const(wchar)* lpwsServerName // LPWSTR
);ccall((:MprAdminIsServiceRunning, "MPRAPI.dll"), stdcall, Int32,
(Cwstring,),
lpwsServerName)
# lpwsServerName : LPWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t MprAdminIsServiceRunning(
const uint16_t* lpwsServerName);
]]
local mprapi = ffi.load("mprapi")
-- mprapi.MprAdminIsServiceRunning(lpwsServerName)
-- lpwsServerName : LPWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MPRAPI.dll');
const MprAdminIsServiceRunning = lib.func('__stdcall', 'MprAdminIsServiceRunning', 'int32_t', ['str16']);
// MprAdminIsServiceRunning(lpwsServerName)
// lpwsServerName : LPWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MPRAPI.dll", {
MprAdminIsServiceRunning: { parameters: ["buffer"], result: "i32" },
});
// lib.symbols.MprAdminIsServiceRunning(lpwsServerName)
// lpwsServerName : LPWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t MprAdminIsServiceRunning(
const uint16_t* lpwsServerName);
C, "MPRAPI.dll");
// $ffi->MprAdminIsServiceRunning(lpwsServerName);
// lpwsServerName : LPWSTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Mprapi extends StdCallLibrary {
Mprapi INSTANCE = Native.load("mprapi", Mprapi.class);
boolean MprAdminIsServiceRunning(
WString lpwsServerName // LPWSTR
);
}@[Link("mprapi")]
lib LibMPRAPI
fun MprAdminIsServiceRunning = MprAdminIsServiceRunning(
lpwsServerName : UInt16* # LPWSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef MprAdminIsServiceRunningNative = Int32 Function(Pointer<Utf16>);
typedef MprAdminIsServiceRunningDart = int Function(Pointer<Utf16>);
final MprAdminIsServiceRunning = DynamicLibrary.open('MPRAPI.dll')
.lookupFunction<MprAdminIsServiceRunningNative, MprAdminIsServiceRunningDart>('MprAdminIsServiceRunning');
// lpwsServerName : LPWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function MprAdminIsServiceRunning(
lpwsServerName: PWideChar // LPWSTR
): BOOL; stdcall;
external 'MPRAPI.dll' name 'MprAdminIsServiceRunning';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "MprAdminIsServiceRunning"
c_MprAdminIsServiceRunning :: CWString -> IO CInt
-- lpwsServerName : LPWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let mpradminisservicerunning =
foreign "MprAdminIsServiceRunning"
((ptr uint16_t) @-> returning int32_t)
(* lpwsServerName : LPWSTR -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mprapi (t "MPRAPI.dll"))
(cffi:use-foreign-library mprapi)
(cffi:defcfun ("MprAdminIsServiceRunning" mpr-admin-is-service-running :convention :stdcall) :int32
(lpws-server-name (:string :encoding :utf-16le))) ; LPWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $MprAdminIsServiceRunning = Win32::API::More->new('MPRAPI',
'BOOL MprAdminIsServiceRunning(LPCWSTR lpwsServerName)');
# my $ret = $MprAdminIsServiceRunning->Call($lpwsServerName);
# lpwsServerName : LPWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。