ホーム › NetworkManagement.Dns › DnsFreeCustomServers
DnsFreeCustomServers
関数カスタムDNSサーバー一覧用に割り当てたメモリを解放する。
シグネチャ
// DNSAPI.dll
#include <windows.h>
void DnsFreeCustomServers(
DWORD* pcServers,
DNS_CUSTOM_SERVER** ppServers
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pcServers | DWORD* | inout | 解放するカスタムサーバー配列の要素数を保持するDWORDへのポインタ。解放後は0が設定される。 |
| ppServers | DNS_CUSTOM_SERVER** | inout | 解放対象のDNS_CUSTOM_SERVER配列へのポインタのアドレス。解放後はNULLが設定される。 |
戻り値の型: void
各言語での呼び出し定義
// DNSAPI.dll
#include <windows.h>
void DnsFreeCustomServers(
DWORD* pcServers,
DNS_CUSTOM_SERVER** ppServers
);[DllImport("DNSAPI.dll", ExactSpelling = true)]
static extern void DnsFreeCustomServers(
ref uint pcServers, // DWORD* in/out
IntPtr ppServers // DNS_CUSTOM_SERVER** in/out
);<DllImport("DNSAPI.dll", ExactSpelling:=True)>
Public Shared Sub DnsFreeCustomServers(
ByRef pcServers As UInteger, ' DWORD* in/out
ppServers As IntPtr ' DNS_CUSTOM_SERVER** in/out
)
End Sub' pcServers : DWORD* in/out
' ppServers : DNS_CUSTOM_SERVER** in/out
Declare PtrSafe Sub DnsFreeCustomServers Lib "dnsapi" ( _
ByRef pcServers As Long, _
ByVal ppServers As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DnsFreeCustomServers = ctypes.windll.dnsapi.DnsFreeCustomServers
DnsFreeCustomServers.restype = None
DnsFreeCustomServers.argtypes = [
ctypes.POINTER(wintypes.DWORD), # pcServers : DWORD* in/out
ctypes.c_void_p, # ppServers : DNS_CUSTOM_SERVER** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('DNSAPI.dll')
DnsFreeCustomServers = Fiddle::Function.new(
lib['DnsFreeCustomServers'],
[
Fiddle::TYPE_VOIDP, # pcServers : DWORD* in/out
Fiddle::TYPE_VOIDP, # ppServers : DNS_CUSTOM_SERVER** in/out
],
Fiddle::TYPE_VOID)#[link(name = "dnsapi")]
extern "system" {
fn DnsFreeCustomServers(
pcServers: *mut u32, // DWORD* in/out
ppServers: *mut *mut DNS_CUSTOM_SERVER // DNS_CUSTOM_SERVER** in/out
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("DNSAPI.dll")]
public static extern void DnsFreeCustomServers(ref uint pcServers, IntPtr ppServers);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DNSAPI_DnsFreeCustomServers' -Namespace Win32 -PassThru
# $api::DnsFreeCustomServers(pcServers, ppServers)#uselib "DNSAPI.dll"
#func global DnsFreeCustomServers "DnsFreeCustomServers" sptr, sptr
; DnsFreeCustomServers varptr(pcServers), varptr(ppServers)
; pcServers : DWORD* in/out -> "sptr"
; ppServers : DNS_CUSTOM_SERVER** in/out -> "sptr"出力引数:
#uselib "DNSAPI.dll" #func global DnsFreeCustomServers "DnsFreeCustomServers" var, var ; DnsFreeCustomServers pcServers, ppServers ; pcServers : DWORD* in/out -> "var" ; ppServers : DNS_CUSTOM_SERVER** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "DNSAPI.dll" #func global DnsFreeCustomServers "DnsFreeCustomServers" sptr, sptr ; DnsFreeCustomServers varptr(pcServers), varptr(ppServers) ; pcServers : DWORD* in/out -> "sptr" ; ppServers : DNS_CUSTOM_SERVER** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void DnsFreeCustomServers(DWORD* pcServers, DNS_CUSTOM_SERVER** ppServers) #uselib "DNSAPI.dll" #func global DnsFreeCustomServers "DnsFreeCustomServers" var, var ; DnsFreeCustomServers pcServers, ppServers ; pcServers : DWORD* in/out -> "var" ; ppServers : DNS_CUSTOM_SERVER** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void DnsFreeCustomServers(DWORD* pcServers, DNS_CUSTOM_SERVER** ppServers) #uselib "DNSAPI.dll" #func global DnsFreeCustomServers "DnsFreeCustomServers" intptr, intptr ; DnsFreeCustomServers varptr(pcServers), varptr(ppServers) ; pcServers : DWORD* in/out -> "intptr" ; ppServers : DNS_CUSTOM_SERVER** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dnsapi = windows.NewLazySystemDLL("DNSAPI.dll")
procDnsFreeCustomServers = dnsapi.NewProc("DnsFreeCustomServers")
)
// pcServers (DWORD* in/out), ppServers (DNS_CUSTOM_SERVER** in/out)
r1, _, err := procDnsFreeCustomServers.Call(
uintptr(pcServers),
uintptr(ppServers),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure DnsFreeCustomServers(
pcServers: Pointer; // DWORD* in/out
ppServers: Pointer // DNS_CUSTOM_SERVER** in/out
); stdcall;
external 'DNSAPI.dll' name 'DnsFreeCustomServers';result := DllCall("DNSAPI\DnsFreeCustomServers"
, "Ptr", pcServers ; DWORD* in/out
, "Ptr", ppServers ; DNS_CUSTOM_SERVER** in/out
, "Int") ; return: void●DnsFreeCustomServers(pcServers, ppServers) = DLL("DNSAPI.dll", "int DnsFreeCustomServers(void*, void*)")
# 呼び出し: DnsFreeCustomServers(pcServers, ppServers)
# pcServers : DWORD* in/out -> "void*"
# ppServers : DNS_CUSTOM_SERVER** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "dnsapi" fn DnsFreeCustomServers(
pcServers: [*c]u32, // DWORD* in/out
ppServers: [*c][*c]DNS_CUSTOM_SERVER // DNS_CUSTOM_SERVER** in/out
) callconv(std.os.windows.WINAPI) void;proc DnsFreeCustomServers(
pcServers: ptr uint32, # DWORD* in/out
ppServers: ptr DNS_CUSTOM_SERVER # DNS_CUSTOM_SERVER** in/out
) {.importc: "DnsFreeCustomServers", stdcall, dynlib: "DNSAPI.dll".}pragma(lib, "dnsapi");
extern(Windows)
void DnsFreeCustomServers(
uint* pcServers, // DWORD* in/out
DNS_CUSTOM_SERVER** ppServers // DNS_CUSTOM_SERVER** in/out
);ccall((:DnsFreeCustomServers, "DNSAPI.dll"), stdcall, Cvoid,
(Ptr{UInt32}, Ptr{DNS_CUSTOM_SERVER}),
pcServers, ppServers)
# pcServers : DWORD* in/out -> Ptr{UInt32}
# ppServers : DNS_CUSTOM_SERVER** in/out -> Ptr{DNS_CUSTOM_SERVER}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void DnsFreeCustomServers(
uint32_t* pcServers,
void* ppServers);
]]
local dnsapi = ffi.load("dnsapi")
-- dnsapi.DnsFreeCustomServers(pcServers, ppServers)
-- pcServers : DWORD* in/out
-- ppServers : DNS_CUSTOM_SERVER** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('DNSAPI.dll');
const DnsFreeCustomServers = lib.func('__stdcall', 'DnsFreeCustomServers', 'void', ['uint32_t *', 'void *']);
// DnsFreeCustomServers(pcServers, ppServers)
// pcServers : DWORD* in/out -> 'uint32_t *'
// ppServers : DNS_CUSTOM_SERVER** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("DNSAPI.dll", {
DnsFreeCustomServers: { parameters: ["pointer", "pointer"], result: "void" },
});
// lib.symbols.DnsFreeCustomServers(pcServers, ppServers)
// pcServers : DWORD* in/out -> "pointer"
// ppServers : DNS_CUSTOM_SERVER** in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void DnsFreeCustomServers(
uint32_t* pcServers,
void* ppServers);
C, "DNSAPI.dll");
// $ffi->DnsFreeCustomServers(pcServers, ppServers);
// pcServers : DWORD* in/out
// ppServers : DNS_CUSTOM_SERVER** in/out
// 構造体/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 Dnsapi extends StdCallLibrary {
Dnsapi INSTANCE = Native.load("dnsapi", Dnsapi.class);
void DnsFreeCustomServers(
IntByReference pcServers, // DWORD* in/out
Pointer ppServers // DNS_CUSTOM_SERVER** in/out
);
}@[Link("dnsapi")]
lib LibDNSAPI
fun DnsFreeCustomServers = DnsFreeCustomServers(
pcServers : UInt32*, # DWORD* in/out
ppServers : DNS_CUSTOM_SERVER** # DNS_CUSTOM_SERVER** in/out
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DnsFreeCustomServersNative = Void Function(Pointer<Uint32>, Pointer<Void>);
typedef DnsFreeCustomServersDart = void Function(Pointer<Uint32>, Pointer<Void>);
final DnsFreeCustomServers = DynamicLibrary.open('DNSAPI.dll')
.lookupFunction<DnsFreeCustomServersNative, DnsFreeCustomServersDart>('DnsFreeCustomServers');
// pcServers : DWORD* in/out -> Pointer<Uint32>
// ppServers : DNS_CUSTOM_SERVER** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure DnsFreeCustomServers(
pcServers: Pointer; // DWORD* in/out
ppServers: Pointer // DNS_CUSTOM_SERVER** in/out
); stdcall;
external 'DNSAPI.dll' name 'DnsFreeCustomServers';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DnsFreeCustomServers"
c_DnsFreeCustomServers :: Ptr Word32 -> Ptr () -> IO ()
-- pcServers : DWORD* in/out -> Ptr Word32
-- ppServers : DNS_CUSTOM_SERVER** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dnsfreecustomservers =
foreign "DnsFreeCustomServers"
((ptr uint32_t) @-> (ptr void) @-> returning void)
(* pcServers : DWORD* in/out -> (ptr uint32_t) *)
(* ppServers : DNS_CUSTOM_SERVER** in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dnsapi (t "DNSAPI.dll"))
(cffi:use-foreign-library dnsapi)
(cffi:defcfun ("DnsFreeCustomServers" dns-free-custom-servers :convention :stdcall) :void
(pc-servers :pointer) ; DWORD* in/out
(pp-servers :pointer)) ; DNS_CUSTOM_SERVER** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DnsFreeCustomServers = Win32::API::More->new('DNSAPI',
'void DnsFreeCustomServers(LPVOID pcServers, LPVOID ppServers)');
# my $ret = $DnsFreeCustomServers->Call($pcServers, $ppServers);
# pcServers : DWORD* in/out -> LPVOID
# ppServers : DNS_CUSTOM_SERVER** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型