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

MprConfigServerRestore

関数
指定パスからルーター構成情報を復元する。
DLLMPRAPI.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD MprConfigServerRestore(
    HANDLE hMprConfig,
    LPWSTR lpwsPath
);

パラメーター

名前方向説明
hMprConfigHANDLEinMprConfigServerConnectで取得した構成ハンドル。
lpwsPathLPWSTRin復元元のバックアップディレクトリパスを指すUnicode文字列。

戻り値の型: DWORD

各言語での呼び出し定義

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

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

MprConfigServerRestore = ctypes.windll.mprapi.MprConfigServerRestore
MprConfigServerRestore.restype = wintypes.DWORD
MprConfigServerRestore.argtypes = [
    wintypes.HANDLE,  # hMprConfig : HANDLE
    wintypes.LPCWSTR,  # lpwsPath : LPWSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mprapi = windows.NewLazySystemDLL("MPRAPI.dll")
	procMprConfigServerRestore = mprapi.NewProc("MprConfigServerRestore")
)

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

extern "mprapi" fn MprConfigServerRestore(
    hMprConfig: ?*anyopaque, // HANDLE
    lpwsPath: [*c]const u16 // LPWSTR
) callconv(std.os.windows.WINAPI) u32;
proc MprConfigServerRestore(
    hMprConfig: pointer,  # HANDLE
    lpwsPath: WideCString  # LPWSTR
): uint32 {.importc: "MprConfigServerRestore", stdcall, dynlib: "MPRAPI.dll".}
pragma(lib, "mprapi");
extern(Windows)
uint MprConfigServerRestore(
    void* hMprConfig,   // HANDLE
    const(wchar)* lpwsPath   // LPWSTR
);
ccall((:MprConfigServerRestore, "MPRAPI.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, Cwstring),
      hMprConfig, lpwsPath)
# hMprConfig : HANDLE -> Ptr{Cvoid}
# lpwsPath : LPWSTR -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t MprConfigServerRestore(
    void* hMprConfig,
    const uint16_t* lpwsPath);
]]
local mprapi = ffi.load("mprapi")
-- mprapi.MprConfigServerRestore(hMprConfig, lpwsPath)
-- hMprConfig : HANDLE
-- lpwsPath : LPWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('MPRAPI.dll');
const MprConfigServerRestore = lib.func('__stdcall', 'MprConfigServerRestore', 'uint32_t', ['void *', 'str16']);
// MprConfigServerRestore(hMprConfig, lpwsPath)
// hMprConfig : HANDLE -> 'void *'
// lpwsPath : LPWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("MPRAPI.dll", {
  MprConfigServerRestore: { parameters: ["pointer", "buffer"], result: "u32" },
});
// lib.symbols.MprConfigServerRestore(hMprConfig, lpwsPath)
// hMprConfig : HANDLE -> "pointer"
// lpwsPath : LPWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t MprConfigServerRestore(
    void* hMprConfig,
    const uint16_t* lpwsPath);
C, "MPRAPI.dll");
// $ffi->MprConfigServerRestore(hMprConfig, lpwsPath);
// hMprConfig : HANDLE
// lpwsPath : 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);
    int MprConfigServerRestore(
        Pointer hMprConfig,   // HANDLE
        WString lpwsPath   // LPWSTR
    );
}
@[Link("mprapi")]
lib LibMPRAPI
  fun MprConfigServerRestore = MprConfigServerRestore(
    hMprConfig : Void*,   # HANDLE
    lpwsPath : UInt16*   # LPWSTR
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef MprConfigServerRestoreNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>);
typedef MprConfigServerRestoreDart = int Function(Pointer<Void>, Pointer<Utf16>);
final MprConfigServerRestore = DynamicLibrary.open('MPRAPI.dll')
    .lookupFunction<MprConfigServerRestoreNative, MprConfigServerRestoreDart>('MprConfigServerRestore');
// hMprConfig : HANDLE -> Pointer<Void>
// lpwsPath : LPWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MprConfigServerRestore(
  hMprConfig: THandle;   // HANDLE
  lpwsPath: PWideChar   // LPWSTR
): DWORD; stdcall;
  external 'MPRAPI.dll' name 'MprConfigServerRestore';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "MprConfigServerRestore"
  c_MprConfigServerRestore :: Ptr () -> CWString -> IO Word32
-- hMprConfig : HANDLE -> Ptr ()
-- lpwsPath : LPWSTR -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let mprconfigserverrestore =
  foreign "MprConfigServerRestore"
    ((ptr void) @-> (ptr uint16_t) @-> returning uint32_t)
(* hMprConfig : HANDLE -> (ptr void) *)
(* lpwsPath : 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 ("MprConfigServerRestore" mpr-config-server-restore :convention :stdcall) :uint32
  (h-mpr-config :pointer)   ; HANDLE
  (lpws-path (:string :encoding :utf-16le)))   ; LPWSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $MprConfigServerRestore = Win32::API::More->new('MPRAPI',
    'DWORD MprConfigServerRestore(HANDLE hMprConfig, LPCWSTR lpwsPath)');
# my $ret = $MprConfigServerRestore->Call($hMprConfig, $lpwsPath);
# hMprConfig : HANDLE -> HANDLE
# lpwsPath : LPWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。