ホーム › NetworkManagement.Dns › DnsServiceCopyInstance
DnsServiceCopyInstance
関数DNS-SDサービスインスタンス構造体を複製する。
シグネチャ
// DNSAPI.dll
#include <windows.h>
DNS_SERVICE_INSTANCE* DnsServiceCopyInstance(
DNS_SERVICE_INSTANCE* pOrig
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pOrig | DNS_SERVICE_INSTANCE* | in | 複製元となるDNS_SERVICE_INSTANCE構造体へのポインタ。深いコピーを生成する。 |
戻り値の型: DNS_SERVICE_INSTANCE*
各言語での呼び出し定義
// DNSAPI.dll
#include <windows.h>
DNS_SERVICE_INSTANCE* DnsServiceCopyInstance(
DNS_SERVICE_INSTANCE* pOrig
);[DllImport("DNSAPI.dll", ExactSpelling = true)]
static extern IntPtr DnsServiceCopyInstance(
IntPtr pOrig // DNS_SERVICE_INSTANCE*
);<DllImport("DNSAPI.dll", ExactSpelling:=True)>
Public Shared Function DnsServiceCopyInstance(
pOrig As IntPtr ' DNS_SERVICE_INSTANCE*
) As IntPtr
End Function' pOrig : DNS_SERVICE_INSTANCE*
Declare PtrSafe Function DnsServiceCopyInstance Lib "dnsapi" ( _
ByVal pOrig As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DnsServiceCopyInstance = ctypes.windll.dnsapi.DnsServiceCopyInstance
DnsServiceCopyInstance.restype = ctypes.c_void_p
DnsServiceCopyInstance.argtypes = [
ctypes.c_void_p, # pOrig : DNS_SERVICE_INSTANCE*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('DNSAPI.dll')
DnsServiceCopyInstance = Fiddle::Function.new(
lib['DnsServiceCopyInstance'],
[
Fiddle::TYPE_VOIDP, # pOrig : DNS_SERVICE_INSTANCE*
],
Fiddle::TYPE_VOIDP)#[link(name = "dnsapi")]
extern "system" {
fn DnsServiceCopyInstance(
pOrig: *mut DNS_SERVICE_INSTANCE // DNS_SERVICE_INSTANCE*
) -> *mut DNS_SERVICE_INSTANCE;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("DNSAPI.dll")]
public static extern IntPtr DnsServiceCopyInstance(IntPtr pOrig);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DNSAPI_DnsServiceCopyInstance' -Namespace Win32 -PassThru
# $api::DnsServiceCopyInstance(pOrig)#uselib "DNSAPI.dll"
#func global DnsServiceCopyInstance "DnsServiceCopyInstance" sptr
; DnsServiceCopyInstance varptr(pOrig) ; 戻り値は stat
; pOrig : DNS_SERVICE_INSTANCE* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "DNSAPI.dll" #cfunc global DnsServiceCopyInstance "DnsServiceCopyInstance" var ; res = DnsServiceCopyInstance(pOrig) ; pOrig : DNS_SERVICE_INSTANCE* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "DNSAPI.dll" #cfunc global DnsServiceCopyInstance "DnsServiceCopyInstance" sptr ; res = DnsServiceCopyInstance(varptr(pOrig)) ; pOrig : DNS_SERVICE_INSTANCE* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DNS_SERVICE_INSTANCE* DnsServiceCopyInstance(DNS_SERVICE_INSTANCE* pOrig) #uselib "DNSAPI.dll" #cfunc global DnsServiceCopyInstance "DnsServiceCopyInstance" var ; res = DnsServiceCopyInstance(pOrig) ; pOrig : DNS_SERVICE_INSTANCE* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DNS_SERVICE_INSTANCE* DnsServiceCopyInstance(DNS_SERVICE_INSTANCE* pOrig) #uselib "DNSAPI.dll" #cfunc global DnsServiceCopyInstance "DnsServiceCopyInstance" intptr ; res = DnsServiceCopyInstance(varptr(pOrig)) ; pOrig : DNS_SERVICE_INSTANCE* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dnsapi = windows.NewLazySystemDLL("DNSAPI.dll")
procDnsServiceCopyInstance = dnsapi.NewProc("DnsServiceCopyInstance")
)
// pOrig (DNS_SERVICE_INSTANCE*)
r1, _, err := procDnsServiceCopyInstance.Call(
uintptr(pOrig),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DNS_SERVICE_INSTANCE*function DnsServiceCopyInstance(
pOrig: Pointer // DNS_SERVICE_INSTANCE*
): Pointer; stdcall;
external 'DNSAPI.dll' name 'DnsServiceCopyInstance';result := DllCall("DNSAPI\DnsServiceCopyInstance"
, "Ptr", pOrig ; DNS_SERVICE_INSTANCE*
, "Ptr") ; return: DNS_SERVICE_INSTANCE*●DnsServiceCopyInstance(pOrig) = DLL("DNSAPI.dll", "void* DnsServiceCopyInstance(void*)")
# 呼び出し: DnsServiceCopyInstance(pOrig)
# pOrig : DNS_SERVICE_INSTANCE* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "dnsapi" fn DnsServiceCopyInstance(
pOrig: [*c]DNS_SERVICE_INSTANCE // DNS_SERVICE_INSTANCE*
) callconv(std.os.windows.WINAPI) [*c]DNS_SERVICE_INSTANCE;proc DnsServiceCopyInstance(
pOrig: ptr DNS_SERVICE_INSTANCE # DNS_SERVICE_INSTANCE*
): ptr DNS_SERVICE_INSTANCE {.importc: "DnsServiceCopyInstance", stdcall, dynlib: "DNSAPI.dll".}pragma(lib, "dnsapi");
extern(Windows)
DNS_SERVICE_INSTANCE* DnsServiceCopyInstance(
DNS_SERVICE_INSTANCE* pOrig // DNS_SERVICE_INSTANCE*
);ccall((:DnsServiceCopyInstance, "DNSAPI.dll"), stdcall, Ptr{DNS_SERVICE_INSTANCE},
(Ptr{DNS_SERVICE_INSTANCE},),
pOrig)
# pOrig : DNS_SERVICE_INSTANCE* -> Ptr{DNS_SERVICE_INSTANCE}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void* DnsServiceCopyInstance(
void* pOrig);
]]
local dnsapi = ffi.load("dnsapi")
-- dnsapi.DnsServiceCopyInstance(pOrig)
-- pOrig : DNS_SERVICE_INSTANCE*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('DNSAPI.dll');
const DnsServiceCopyInstance = lib.func('__stdcall', 'DnsServiceCopyInstance', 'void *', ['void *']);
// DnsServiceCopyInstance(pOrig)
// pOrig : DNS_SERVICE_INSTANCE* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("DNSAPI.dll", {
DnsServiceCopyInstance: { parameters: ["pointer"], result: "pointer" },
});
// lib.symbols.DnsServiceCopyInstance(pOrig)
// pOrig : DNS_SERVICE_INSTANCE* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* DnsServiceCopyInstance(
void* pOrig);
C, "DNSAPI.dll");
// $ffi->DnsServiceCopyInstance(pOrig);
// pOrig : DNS_SERVICE_INSTANCE*
// 構造体/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);
Pointer DnsServiceCopyInstance(
Pointer pOrig // DNS_SERVICE_INSTANCE*
);
}@[Link("dnsapi")]
lib LibDNSAPI
fun DnsServiceCopyInstance = DnsServiceCopyInstance(
pOrig : DNS_SERVICE_INSTANCE* # DNS_SERVICE_INSTANCE*
) : DNS_SERVICE_INSTANCE*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DnsServiceCopyInstanceNative = Pointer<Void> Function(Pointer<Void>);
typedef DnsServiceCopyInstanceDart = Pointer<Void> Function(Pointer<Void>);
final DnsServiceCopyInstance = DynamicLibrary.open('DNSAPI.dll')
.lookupFunction<DnsServiceCopyInstanceNative, DnsServiceCopyInstanceDart>('DnsServiceCopyInstance');
// pOrig : DNS_SERVICE_INSTANCE* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DnsServiceCopyInstance(
pOrig: Pointer // DNS_SERVICE_INSTANCE*
): Pointer; stdcall;
external 'DNSAPI.dll' name 'DnsServiceCopyInstance';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DnsServiceCopyInstance"
c_DnsServiceCopyInstance :: Ptr () -> IO (Ptr ())
-- pOrig : DNS_SERVICE_INSTANCE* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dnsservicecopyinstance =
foreign "DnsServiceCopyInstance"
((ptr void) @-> returning (ptr void))
(* pOrig : DNS_SERVICE_INSTANCE* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dnsapi (t "DNSAPI.dll"))
(cffi:use-foreign-library dnsapi)
(cffi:defcfun ("DnsServiceCopyInstance" dns-service-copy-instance :convention :stdcall) :pointer
(p-orig :pointer)) ; DNS_SERVICE_INSTANCE*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DnsServiceCopyInstance = Win32::API::More->new('DNSAPI',
'LPVOID DnsServiceCopyInstance(LPVOID pOrig)');
# my $ret = $DnsServiceCopyInstance->Call($pOrig);
# pOrig : DNS_SERVICE_INSTANCE* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。