ホーム › Devices.WebServicesOnDevices › WSDCreateUdpAddress
WSDCreateUdpAddress
関数WSD用のUDPアドレスオブジェクトを作成する。
シグネチャ
// wsdapi.dll
#include <windows.h>
HRESULT WSDCreateUdpAddress(
IWSDUdpAddress** ppAddress
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ppAddress | IWSDUdpAddress** | out | 作成したIWSDUdpAddressオブジェクトを受け取る出力先ポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// wsdapi.dll
#include <windows.h>
HRESULT WSDCreateUdpAddress(
IWSDUdpAddress** ppAddress
);[DllImport("wsdapi.dll", ExactSpelling = true)]
static extern int WSDCreateUdpAddress(
IntPtr ppAddress // IWSDUdpAddress** out
);<DllImport("wsdapi.dll", ExactSpelling:=True)>
Public Shared Function WSDCreateUdpAddress(
ppAddress As IntPtr ' IWSDUdpAddress** out
) As Integer
End Function' ppAddress : IWSDUdpAddress** out
Declare PtrSafe Function WSDCreateUdpAddress Lib "wsdapi" ( _
ByVal ppAddress As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WSDCreateUdpAddress = ctypes.windll.wsdapi.WSDCreateUdpAddress
WSDCreateUdpAddress.restype = ctypes.c_int
WSDCreateUdpAddress.argtypes = [
ctypes.c_void_p, # ppAddress : IWSDUdpAddress** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('wsdapi.dll')
WSDCreateUdpAddress = Fiddle::Function.new(
lib['WSDCreateUdpAddress'],
[
Fiddle::TYPE_VOIDP, # ppAddress : IWSDUdpAddress** out
],
Fiddle::TYPE_INT)#[link(name = "wsdapi")]
extern "system" {
fn WSDCreateUdpAddress(
ppAddress: *mut *mut core::ffi::c_void // IWSDUdpAddress** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("wsdapi.dll")]
public static extern int WSDCreateUdpAddress(IntPtr ppAddress);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsdapi_WSDCreateUdpAddress' -Namespace Win32 -PassThru
# $api::WSDCreateUdpAddress(ppAddress)#uselib "wsdapi.dll"
#func global WSDCreateUdpAddress "WSDCreateUdpAddress" sptr
; WSDCreateUdpAddress ppAddress ; 戻り値は stat
; ppAddress : IWSDUdpAddress** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "wsdapi.dll"
#cfunc global WSDCreateUdpAddress "WSDCreateUdpAddress" sptr
; res = WSDCreateUdpAddress(ppAddress)
; ppAddress : IWSDUdpAddress** out -> "sptr"; HRESULT WSDCreateUdpAddress(IWSDUdpAddress** ppAddress)
#uselib "wsdapi.dll"
#cfunc global WSDCreateUdpAddress "WSDCreateUdpAddress" intptr
; res = WSDCreateUdpAddress(ppAddress)
; ppAddress : IWSDUdpAddress** out -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wsdapi = windows.NewLazySystemDLL("wsdapi.dll")
procWSDCreateUdpAddress = wsdapi.NewProc("WSDCreateUdpAddress")
)
// ppAddress (IWSDUdpAddress** out)
r1, _, err := procWSDCreateUdpAddress.Call(
uintptr(ppAddress),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WSDCreateUdpAddress(
ppAddress: Pointer // IWSDUdpAddress** out
): Integer; stdcall;
external 'wsdapi.dll' name 'WSDCreateUdpAddress';result := DllCall("wsdapi\WSDCreateUdpAddress"
, "Ptr", ppAddress ; IWSDUdpAddress** out
, "Int") ; return: HRESULT●WSDCreateUdpAddress(ppAddress) = DLL("wsdapi.dll", "int WSDCreateUdpAddress(void*)")
# 呼び出し: WSDCreateUdpAddress(ppAddress)
# ppAddress : IWSDUdpAddress** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wsdapi" fn WSDCreateUdpAddress(
ppAddress: ?*anyopaque // IWSDUdpAddress** out
) callconv(std.os.windows.WINAPI) i32;proc WSDCreateUdpAddress(
ppAddress: pointer # IWSDUdpAddress** out
): int32 {.importc: "WSDCreateUdpAddress", stdcall, dynlib: "wsdapi.dll".}pragma(lib, "wsdapi");
extern(Windows)
int WSDCreateUdpAddress(
void* ppAddress // IWSDUdpAddress** out
);ccall((:WSDCreateUdpAddress, "wsdapi.dll"), stdcall, Int32,
(Ptr{Cvoid},),
ppAddress)
# ppAddress : IWSDUdpAddress** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WSDCreateUdpAddress(
void* ppAddress);
]]
local wsdapi = ffi.load("wsdapi")
-- wsdapi.WSDCreateUdpAddress(ppAddress)
-- ppAddress : IWSDUdpAddress** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('wsdapi.dll');
const WSDCreateUdpAddress = lib.func('__stdcall', 'WSDCreateUdpAddress', 'int32_t', ['void *']);
// WSDCreateUdpAddress(ppAddress)
// ppAddress : IWSDUdpAddress** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("wsdapi.dll", {
WSDCreateUdpAddress: { parameters: ["pointer"], result: "i32" },
});
// lib.symbols.WSDCreateUdpAddress(ppAddress)
// ppAddress : IWSDUdpAddress** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WSDCreateUdpAddress(
void* ppAddress);
C, "wsdapi.dll");
// $ffi->WSDCreateUdpAddress(ppAddress);
// ppAddress : IWSDUdpAddress** 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 Wsdapi extends StdCallLibrary {
Wsdapi INSTANCE = Native.load("wsdapi", Wsdapi.class);
int WSDCreateUdpAddress(
Pointer ppAddress // IWSDUdpAddress** out
);
}@[Link("wsdapi")]
lib Libwsdapi
fun WSDCreateUdpAddress = WSDCreateUdpAddress(
ppAddress : Void* # IWSDUdpAddress** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WSDCreateUdpAddressNative = Int32 Function(Pointer<Void>);
typedef WSDCreateUdpAddressDart = int Function(Pointer<Void>);
final WSDCreateUdpAddress = DynamicLibrary.open('wsdapi.dll')
.lookupFunction<WSDCreateUdpAddressNative, WSDCreateUdpAddressDart>('WSDCreateUdpAddress');
// ppAddress : IWSDUdpAddress** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WSDCreateUdpAddress(
ppAddress: Pointer // IWSDUdpAddress** out
): Integer; stdcall;
external 'wsdapi.dll' name 'WSDCreateUdpAddress';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WSDCreateUdpAddress"
c_WSDCreateUdpAddress :: Ptr () -> IO Int32
-- ppAddress : IWSDUdpAddress** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wsdcreateudpaddress =
foreign "WSDCreateUdpAddress"
((ptr void) @-> returning int32_t)
(* ppAddress : IWSDUdpAddress** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wsdapi (t "wsdapi.dll"))
(cffi:use-foreign-library wsdapi)
(cffi:defcfun ("WSDCreateUdpAddress" wsdcreate-udp-address :convention :stdcall) :int32
(pp-address :pointer)) ; IWSDUdpAddress** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WSDCreateUdpAddress = Win32::API::More->new('wsdapi',
'int WSDCreateUdpAddress(LPVOID ppAddress)');
# my $ret = $WSDCreateUdpAddress->Call($ppAddress);
# ppAddress : IWSDUdpAddress** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型