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

MprConfigServerBackup

関数
ルーター構成情報を指定パスにバックアップする。
DLLMPRAPI.dll呼出規約winapi対応OSwindowsserver2000

シグネチャ

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

DWORD MprConfigServerBackup(
    HANDLE hMprConfig,
    LPWSTR lpwsPath
);

パラメーター

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

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MprConfigServerBackup(
    HANDLE hMprConfig,
    LPWSTR lpwsPath
);
[DllImport("MPRAPI.dll", ExactSpelling = true)]
static extern uint MprConfigServerBackup(
    IntPtr hMprConfig,   // HANDLE
    [MarshalAs(UnmanagedType.LPWStr)] string lpwsPath   // LPWSTR
);
<DllImport("MPRAPI.dll", ExactSpelling:=True)>
Public Shared Function MprConfigServerBackup(
    hMprConfig As IntPtr,   ' HANDLE
    <MarshalAs(UnmanagedType.LPWStr)> lpwsPath As String   ' LPWSTR
) As UInteger
End Function
' hMprConfig : HANDLE
' lpwsPath : LPWSTR
Declare PtrSafe Function MprConfigServerBackup 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

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

lib = Fiddle.dlopen('MPRAPI.dll')
MprConfigServerBackup = Fiddle::Function.new(
  lib['MprConfigServerBackup'],
  [
    Fiddle::TYPE_VOIDP,  # hMprConfig : HANDLE
    Fiddle::TYPE_VOIDP,  # lpwsPath : LPWSTR
  ],
  -Fiddle::TYPE_INT)
#[link(name = "mprapi")]
extern "system" {
    fn MprConfigServerBackup(
        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 MprConfigServerBackup(IntPtr hMprConfig, [MarshalAs(UnmanagedType.LPWStr)] string lpwsPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MPRAPI_MprConfigServerBackup' -Namespace Win32 -PassThru
# $api::MprConfigServerBackup(hMprConfig, lpwsPath)
#uselib "MPRAPI.dll"
#func global MprConfigServerBackup "MprConfigServerBackup" sptr, sptr
; MprConfigServerBackup hMprConfig, lpwsPath   ; 戻り値は stat
; hMprConfig : HANDLE -> "sptr"
; lpwsPath : LPWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "MPRAPI.dll"
#cfunc global MprConfigServerBackup "MprConfigServerBackup" sptr, wstr
; res = MprConfigServerBackup(hMprConfig, lpwsPath)
; hMprConfig : HANDLE -> "sptr"
; lpwsPath : LPWSTR -> "wstr"
; DWORD MprConfigServerBackup(HANDLE hMprConfig, LPWSTR lpwsPath)
#uselib "MPRAPI.dll"
#cfunc global MprConfigServerBackup "MprConfigServerBackup" intptr, wstr
; res = MprConfigServerBackup(hMprConfig, lpwsPath)
; hMprConfig : HANDLE -> "intptr"
; lpwsPath : LPWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mprapi = windows.NewLazySystemDLL("MPRAPI.dll")
	procMprConfigServerBackup = mprapi.NewProc("MprConfigServerBackup")
)

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

extern "mprapi" fn MprConfigServerBackup(
    hMprConfig: ?*anyopaque, // HANDLE
    lpwsPath: [*c]const u16 // LPWSTR
) callconv(std.os.windows.WINAPI) u32;
proc MprConfigServerBackup(
    hMprConfig: pointer,  # HANDLE
    lpwsPath: WideCString  # LPWSTR
): uint32 {.importc: "MprConfigServerBackup", stdcall, dynlib: "MPRAPI.dll".}
pragma(lib, "mprapi");
extern(Windows)
uint MprConfigServerBackup(
    void* hMprConfig,   // HANDLE
    const(wchar)* lpwsPath   // LPWSTR
);
ccall((:MprConfigServerBackup, "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 MprConfigServerBackup(
    void* hMprConfig,
    const uint16_t* lpwsPath);
]]
local mprapi = ffi.load("mprapi")
-- mprapi.MprConfigServerBackup(hMprConfig, lpwsPath)
-- hMprConfig : HANDLE
-- lpwsPath : LPWSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('MPRAPI.dll');
const MprConfigServerBackup = lib.func('__stdcall', 'MprConfigServerBackup', 'uint32_t', ['void *', 'str16']);
// MprConfigServerBackup(hMprConfig, lpwsPath)
// hMprConfig : HANDLE -> 'void *'
// lpwsPath : LPWSTR -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("MPRAPI.dll", {
  MprConfigServerBackup: { parameters: ["pointer", "buffer"], result: "u32" },
});
// lib.symbols.MprConfigServerBackup(hMprConfig, lpwsPath)
// hMprConfig : HANDLE -> "pointer"
// lpwsPath : LPWSTR -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t MprConfigServerBackup(
    void* hMprConfig,
    const uint16_t* lpwsPath);
C, "MPRAPI.dll");
// $ffi->MprConfigServerBackup(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 MprConfigServerBackup(
        Pointer hMprConfig,   // HANDLE
        WString lpwsPath   // LPWSTR
    );
}
@[Link("mprapi")]
lib LibMPRAPI
  fun MprConfigServerBackup = MprConfigServerBackup(
    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 MprConfigServerBackupNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>);
typedef MprConfigServerBackupDart = int Function(Pointer<Void>, Pointer<Utf16>);
final MprConfigServerBackup = DynamicLibrary.open('MPRAPI.dll')
    .lookupFunction<MprConfigServerBackupNative, MprConfigServerBackupDart>('MprConfigServerBackup');
// hMprConfig : HANDLE -> Pointer<Void>
// lpwsPath : LPWSTR -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function MprConfigServerBackup(
  hMprConfig: THandle;   // HANDLE
  lpwsPath: PWideChar   // LPWSTR
): DWORD; stdcall;
  external 'MPRAPI.dll' name 'MprConfigServerBackup';
import Foreign
import Foreign.C.Types
import Foreign.C.String

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

let mprconfigserverbackup =
  foreign "MprConfigServerBackup"
    ((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 ("MprConfigServerBackup" mpr-config-server-backup :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 $MprConfigServerBackup = Win32::API::More->new('MPRAPI',
    'DWORD MprConfigServerBackup(HANDLE hMprConfig, LPCWSTR lpwsPath)');
# my $ret = $MprConfigServerBackup->Call($hMprConfig, $lpwsPath);
# hMprConfig : HANDLE -> HANDLE
# lpwsPath : LPWSTR -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。