ホーム › NetworkManagement.Dhcp › DhcpServerBackupDatabase
DhcpServerBackupDatabase
関数DHCPサーバーのデータベースを指定パスにバックアップする。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpServerBackupDatabase(
LPWSTR ServerIpAddress, // optional
LPWSTR Path
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ServerIpAddress | LPWSTR | inoptional |
| Path | LPWSTR | in |
戻り値の型: DWORD
各言語での呼び出し定義
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpServerBackupDatabase(
LPWSTR ServerIpAddress, // optional
LPWSTR Path
);[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpServerBackupDatabase(
[MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, // LPWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string Path // LPWSTR
);<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpServerBackupDatabase(
<MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String, ' LPWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> Path As String ' LPWSTR
) As UInteger
End Function' ServerIpAddress : LPWSTR optional
' Path : LPWSTR
Declare PtrSafe Function DhcpServerBackupDatabase Lib "dhcpsapi" ( _
ByVal ServerIpAddress As LongPtr, _
ByVal Path As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DhcpServerBackupDatabase = ctypes.windll.dhcpsapi.DhcpServerBackupDatabase
DhcpServerBackupDatabase.restype = wintypes.DWORD
DhcpServerBackupDatabase.argtypes = [
wintypes.LPCWSTR, # ServerIpAddress : LPWSTR optional
wintypes.LPCWSTR, # Path : LPWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpServerBackupDatabase = Fiddle::Function.new(
lib['DhcpServerBackupDatabase'],
[
Fiddle::TYPE_VOIDP, # ServerIpAddress : LPWSTR optional
Fiddle::TYPE_VOIDP, # Path : LPWSTR
],
-Fiddle::TYPE_INT)#[link(name = "dhcpsapi")]
extern "system" {
fn DhcpServerBackupDatabase(
ServerIpAddress: *mut u16, // LPWSTR optional
Path: *mut u16 // LPWSTR
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpServerBackupDatabase([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, [MarshalAs(UnmanagedType.LPWStr)] string Path);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpServerBackupDatabase' -Namespace Win32 -PassThru
# $api::DhcpServerBackupDatabase(ServerIpAddress, Path)#uselib "DHCPSAPI.dll"
#func global DhcpServerBackupDatabase "DhcpServerBackupDatabase" sptr, sptr
; DhcpServerBackupDatabase ServerIpAddress, Path ; 戻り値は stat
; ServerIpAddress : LPWSTR optional -> "sptr"
; Path : LPWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "DHCPSAPI.dll"
#cfunc global DhcpServerBackupDatabase "DhcpServerBackupDatabase" wstr, wstr
; res = DhcpServerBackupDatabase(ServerIpAddress, Path)
; ServerIpAddress : LPWSTR optional -> "wstr"
; Path : LPWSTR -> "wstr"; DWORD DhcpServerBackupDatabase(LPWSTR ServerIpAddress, LPWSTR Path)
#uselib "DHCPSAPI.dll"
#cfunc global DhcpServerBackupDatabase "DhcpServerBackupDatabase" wstr, wstr
; res = DhcpServerBackupDatabase(ServerIpAddress, Path)
; ServerIpAddress : LPWSTR optional -> "wstr"
; Path : LPWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
procDhcpServerBackupDatabase = dhcpsapi.NewProc("DhcpServerBackupDatabase")
)
// ServerIpAddress (LPWSTR optional), Path (LPWSTR)
r1, _, err := procDhcpServerBackupDatabase.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerIpAddress))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Path))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction DhcpServerBackupDatabase(
ServerIpAddress: PWideChar; // LPWSTR optional
Path: PWideChar // LPWSTR
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpServerBackupDatabase';result := DllCall("DHCPSAPI\DhcpServerBackupDatabase"
, "WStr", ServerIpAddress ; LPWSTR optional
, "WStr", Path ; LPWSTR
, "UInt") ; return: DWORD●DhcpServerBackupDatabase(ServerIpAddress, Path) = DLL("DHCPSAPI.dll", "dword DhcpServerBackupDatabase(char*, char*)")
# 呼び出し: DhcpServerBackupDatabase(ServerIpAddress, Path)
# ServerIpAddress : LPWSTR optional -> "char*"
# Path : LPWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。