ホーム › Devices.WebServicesOnDevices › WSDCreateDiscoveryPublisher2
WSDCreateDiscoveryPublisher2
関数構成パラメータ付きでディスカバリパブリッシャを作成する。
シグネチャ
// wsdapi.dll
#include <windows.h>
HRESULT WSDCreateDiscoveryPublisher2(
IWSDXMLContext* pContext,
WSD_CONFIG_PARAM* pConfigParams, // optional
DWORD dwConfigParamCount,
IWSDiscoveryPublisher** ppPublisher
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pContext | IWSDXMLContext* | in | XML処理に用いるIWSDXMLContextへのポインタ。NULL可で既定を使う。 |
| pConfigParams | WSD_CONFIG_PARAM* | inoptional | パブリッシャー動作を構成するWSD_CONFIG_PARAM配列へのポインタ。 |
| dwConfigParamCount | DWORD | in | pConfigParamsの要素数。 |
| ppPublisher | IWSDiscoveryPublisher** | out | 作成したIWSDiscoveryPublisherオブジェクトを受け取る出力先ポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// wsdapi.dll
#include <windows.h>
HRESULT WSDCreateDiscoveryPublisher2(
IWSDXMLContext* pContext,
WSD_CONFIG_PARAM* pConfigParams, // optional
DWORD dwConfigParamCount,
IWSDiscoveryPublisher** ppPublisher
);[DllImport("wsdapi.dll", ExactSpelling = true)]
static extern int WSDCreateDiscoveryPublisher2(
IntPtr pContext, // IWSDXMLContext*
IntPtr pConfigParams, // WSD_CONFIG_PARAM* optional
uint dwConfigParamCount, // DWORD
IntPtr ppPublisher // IWSDiscoveryPublisher** out
);<DllImport("wsdapi.dll", ExactSpelling:=True)>
Public Shared Function WSDCreateDiscoveryPublisher2(
pContext As IntPtr, ' IWSDXMLContext*
pConfigParams As IntPtr, ' WSD_CONFIG_PARAM* optional
dwConfigParamCount As UInteger, ' DWORD
ppPublisher As IntPtr ' IWSDiscoveryPublisher** out
) As Integer
End Function' pContext : IWSDXMLContext*
' pConfigParams : WSD_CONFIG_PARAM* optional
' dwConfigParamCount : DWORD
' ppPublisher : IWSDiscoveryPublisher** out
Declare PtrSafe Function WSDCreateDiscoveryPublisher2 Lib "wsdapi" ( _
ByVal pContext As LongPtr, _
ByVal pConfigParams As LongPtr, _
ByVal dwConfigParamCount As Long, _
ByVal ppPublisher As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
WSDCreateDiscoveryPublisher2 = ctypes.windll.wsdapi.WSDCreateDiscoveryPublisher2
WSDCreateDiscoveryPublisher2.restype = ctypes.c_int
WSDCreateDiscoveryPublisher2.argtypes = [
ctypes.c_void_p, # pContext : IWSDXMLContext*
ctypes.c_void_p, # pConfigParams : WSD_CONFIG_PARAM* optional
wintypes.DWORD, # dwConfigParamCount : DWORD
ctypes.c_void_p, # ppPublisher : IWSDiscoveryPublisher** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('wsdapi.dll')
WSDCreateDiscoveryPublisher2 = Fiddle::Function.new(
lib['WSDCreateDiscoveryPublisher2'],
[
Fiddle::TYPE_VOIDP, # pContext : IWSDXMLContext*
Fiddle::TYPE_VOIDP, # pConfigParams : WSD_CONFIG_PARAM* optional
-Fiddle::TYPE_INT, # dwConfigParamCount : DWORD
Fiddle::TYPE_VOIDP, # ppPublisher : IWSDiscoveryPublisher** out
],
Fiddle::TYPE_INT)#[link(name = "wsdapi")]
extern "system" {
fn WSDCreateDiscoveryPublisher2(
pContext: *mut core::ffi::c_void, // IWSDXMLContext*
pConfigParams: *mut WSD_CONFIG_PARAM, // WSD_CONFIG_PARAM* optional
dwConfigParamCount: u32, // DWORD
ppPublisher: *mut *mut core::ffi::c_void // IWSDiscoveryPublisher** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("wsdapi.dll")]
public static extern int WSDCreateDiscoveryPublisher2(IntPtr pContext, IntPtr pConfigParams, uint dwConfigParamCount, IntPtr ppPublisher);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsdapi_WSDCreateDiscoveryPublisher2' -Namespace Win32 -PassThru
# $api::WSDCreateDiscoveryPublisher2(pContext, pConfigParams, dwConfigParamCount, ppPublisher)#uselib "wsdapi.dll"
#func global WSDCreateDiscoveryPublisher2 "WSDCreateDiscoveryPublisher2" sptr, sptr, sptr, sptr
; WSDCreateDiscoveryPublisher2 pContext, varptr(pConfigParams), dwConfigParamCount, ppPublisher ; 戻り値は stat
; pContext : IWSDXMLContext* -> "sptr"
; pConfigParams : WSD_CONFIG_PARAM* optional -> "sptr"
; dwConfigParamCount : DWORD -> "sptr"
; ppPublisher : IWSDiscoveryPublisher** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "wsdapi.dll" #cfunc global WSDCreateDiscoveryPublisher2 "WSDCreateDiscoveryPublisher2" sptr, var, int, sptr ; res = WSDCreateDiscoveryPublisher2(pContext, pConfigParams, dwConfigParamCount, ppPublisher) ; pContext : IWSDXMLContext* -> "sptr" ; pConfigParams : WSD_CONFIG_PARAM* optional -> "var" ; dwConfigParamCount : DWORD -> "int" ; ppPublisher : IWSDiscoveryPublisher** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "wsdapi.dll" #cfunc global WSDCreateDiscoveryPublisher2 "WSDCreateDiscoveryPublisher2" sptr, sptr, int, sptr ; res = WSDCreateDiscoveryPublisher2(pContext, varptr(pConfigParams), dwConfigParamCount, ppPublisher) ; pContext : IWSDXMLContext* -> "sptr" ; pConfigParams : WSD_CONFIG_PARAM* optional -> "sptr" ; dwConfigParamCount : DWORD -> "int" ; ppPublisher : IWSDiscoveryPublisher** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT WSDCreateDiscoveryPublisher2(IWSDXMLContext* pContext, WSD_CONFIG_PARAM* pConfigParams, DWORD dwConfigParamCount, IWSDiscoveryPublisher** ppPublisher) #uselib "wsdapi.dll" #cfunc global WSDCreateDiscoveryPublisher2 "WSDCreateDiscoveryPublisher2" intptr, var, int, intptr ; res = WSDCreateDiscoveryPublisher2(pContext, pConfigParams, dwConfigParamCount, ppPublisher) ; pContext : IWSDXMLContext* -> "intptr" ; pConfigParams : WSD_CONFIG_PARAM* optional -> "var" ; dwConfigParamCount : DWORD -> "int" ; ppPublisher : IWSDiscoveryPublisher** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT WSDCreateDiscoveryPublisher2(IWSDXMLContext* pContext, WSD_CONFIG_PARAM* pConfigParams, DWORD dwConfigParamCount, IWSDiscoveryPublisher** ppPublisher) #uselib "wsdapi.dll" #cfunc global WSDCreateDiscoveryPublisher2 "WSDCreateDiscoveryPublisher2" intptr, intptr, int, intptr ; res = WSDCreateDiscoveryPublisher2(pContext, varptr(pConfigParams), dwConfigParamCount, ppPublisher) ; pContext : IWSDXMLContext* -> "intptr" ; pConfigParams : WSD_CONFIG_PARAM* optional -> "intptr" ; dwConfigParamCount : DWORD -> "int" ; ppPublisher : IWSDiscoveryPublisher** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wsdapi = windows.NewLazySystemDLL("wsdapi.dll")
procWSDCreateDiscoveryPublisher2 = wsdapi.NewProc("WSDCreateDiscoveryPublisher2")
)
// pContext (IWSDXMLContext*), pConfigParams (WSD_CONFIG_PARAM* optional), dwConfigParamCount (DWORD), ppPublisher (IWSDiscoveryPublisher** out)
r1, _, err := procWSDCreateDiscoveryPublisher2.Call(
uintptr(pContext),
uintptr(pConfigParams),
uintptr(dwConfigParamCount),
uintptr(ppPublisher),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction WSDCreateDiscoveryPublisher2(
pContext: Pointer; // IWSDXMLContext*
pConfigParams: Pointer; // WSD_CONFIG_PARAM* optional
dwConfigParamCount: DWORD; // DWORD
ppPublisher: Pointer // IWSDiscoveryPublisher** out
): Integer; stdcall;
external 'wsdapi.dll' name 'WSDCreateDiscoveryPublisher2';result := DllCall("wsdapi\WSDCreateDiscoveryPublisher2"
, "Ptr", pContext ; IWSDXMLContext*
, "Ptr", pConfigParams ; WSD_CONFIG_PARAM* optional
, "UInt", dwConfigParamCount ; DWORD
, "Ptr", ppPublisher ; IWSDiscoveryPublisher** out
, "Int") ; return: HRESULT●WSDCreateDiscoveryPublisher2(pContext, pConfigParams, dwConfigParamCount, ppPublisher) = DLL("wsdapi.dll", "int WSDCreateDiscoveryPublisher2(void*, void*, dword, void*)")
# 呼び出し: WSDCreateDiscoveryPublisher2(pContext, pConfigParams, dwConfigParamCount, ppPublisher)
# pContext : IWSDXMLContext* -> "void*"
# pConfigParams : WSD_CONFIG_PARAM* optional -> "void*"
# dwConfigParamCount : DWORD -> "dword"
# ppPublisher : IWSDiscoveryPublisher** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wsdapi" fn WSDCreateDiscoveryPublisher2(
pContext: ?*anyopaque, // IWSDXMLContext*
pConfigParams: [*c]WSD_CONFIG_PARAM, // WSD_CONFIG_PARAM* optional
dwConfigParamCount: u32, // DWORD
ppPublisher: ?*anyopaque // IWSDiscoveryPublisher** out
) callconv(std.os.windows.WINAPI) i32;proc WSDCreateDiscoveryPublisher2(
pContext: pointer, # IWSDXMLContext*
pConfigParams: ptr WSD_CONFIG_PARAM, # WSD_CONFIG_PARAM* optional
dwConfigParamCount: uint32, # DWORD
ppPublisher: pointer # IWSDiscoveryPublisher** out
): int32 {.importc: "WSDCreateDiscoveryPublisher2", stdcall, dynlib: "wsdapi.dll".}pragma(lib, "wsdapi");
extern(Windows)
int WSDCreateDiscoveryPublisher2(
void* pContext, // IWSDXMLContext*
WSD_CONFIG_PARAM* pConfigParams, // WSD_CONFIG_PARAM* optional
uint dwConfigParamCount, // DWORD
void* ppPublisher // IWSDiscoveryPublisher** out
);ccall((:WSDCreateDiscoveryPublisher2, "wsdapi.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{WSD_CONFIG_PARAM}, UInt32, Ptr{Cvoid}),
pContext, pConfigParams, dwConfigParamCount, ppPublisher)
# pContext : IWSDXMLContext* -> Ptr{Cvoid}
# pConfigParams : WSD_CONFIG_PARAM* optional -> Ptr{WSD_CONFIG_PARAM}
# dwConfigParamCount : DWORD -> UInt32
# ppPublisher : IWSDiscoveryPublisher** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t WSDCreateDiscoveryPublisher2(
void* pContext,
void* pConfigParams,
uint32_t dwConfigParamCount,
void* ppPublisher);
]]
local wsdapi = ffi.load("wsdapi")
-- wsdapi.WSDCreateDiscoveryPublisher2(pContext, pConfigParams, dwConfigParamCount, ppPublisher)
-- pContext : IWSDXMLContext*
-- pConfigParams : WSD_CONFIG_PARAM* optional
-- dwConfigParamCount : DWORD
-- ppPublisher : IWSDiscoveryPublisher** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('wsdapi.dll');
const WSDCreateDiscoveryPublisher2 = lib.func('__stdcall', 'WSDCreateDiscoveryPublisher2', 'int32_t', ['void *', 'void *', 'uint32_t', 'void *']);
// WSDCreateDiscoveryPublisher2(pContext, pConfigParams, dwConfigParamCount, ppPublisher)
// pContext : IWSDXMLContext* -> 'void *'
// pConfigParams : WSD_CONFIG_PARAM* optional -> 'void *'
// dwConfigParamCount : DWORD -> 'uint32_t'
// ppPublisher : IWSDiscoveryPublisher** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("wsdapi.dll", {
WSDCreateDiscoveryPublisher2: { parameters: ["pointer", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.WSDCreateDiscoveryPublisher2(pContext, pConfigParams, dwConfigParamCount, ppPublisher)
// pContext : IWSDXMLContext* -> "pointer"
// pConfigParams : WSD_CONFIG_PARAM* optional -> "pointer"
// dwConfigParamCount : DWORD -> "u32"
// ppPublisher : IWSDiscoveryPublisher** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t WSDCreateDiscoveryPublisher2(
void* pContext,
void* pConfigParams,
uint32_t dwConfigParamCount,
void* ppPublisher);
C, "wsdapi.dll");
// $ffi->WSDCreateDiscoveryPublisher2(pContext, pConfigParams, dwConfigParamCount, ppPublisher);
// pContext : IWSDXMLContext*
// pConfigParams : WSD_CONFIG_PARAM* optional
// dwConfigParamCount : DWORD
// ppPublisher : IWSDiscoveryPublisher** 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 WSDCreateDiscoveryPublisher2(
Pointer pContext, // IWSDXMLContext*
Pointer pConfigParams, // WSD_CONFIG_PARAM* optional
int dwConfigParamCount, // DWORD
Pointer ppPublisher // IWSDiscoveryPublisher** out
);
}@[Link("wsdapi")]
lib Libwsdapi
fun WSDCreateDiscoveryPublisher2 = WSDCreateDiscoveryPublisher2(
pContext : Void*, # IWSDXMLContext*
pConfigParams : WSD_CONFIG_PARAM*, # WSD_CONFIG_PARAM* optional
dwConfigParamCount : UInt32, # DWORD
ppPublisher : Void* # IWSDiscoveryPublisher** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef WSDCreateDiscoveryPublisher2Native = Int32 Function(Pointer<Void>, Pointer<Void>, Uint32, Pointer<Void>);
typedef WSDCreateDiscoveryPublisher2Dart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Void>);
final WSDCreateDiscoveryPublisher2 = DynamicLibrary.open('wsdapi.dll')
.lookupFunction<WSDCreateDiscoveryPublisher2Native, WSDCreateDiscoveryPublisher2Dart>('WSDCreateDiscoveryPublisher2');
// pContext : IWSDXMLContext* -> Pointer<Void>
// pConfigParams : WSD_CONFIG_PARAM* optional -> Pointer<Void>
// dwConfigParamCount : DWORD -> Uint32
// ppPublisher : IWSDiscoveryPublisher** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function WSDCreateDiscoveryPublisher2(
pContext: Pointer; // IWSDXMLContext*
pConfigParams: Pointer; // WSD_CONFIG_PARAM* optional
dwConfigParamCount: DWORD; // DWORD
ppPublisher: Pointer // IWSDiscoveryPublisher** out
): Integer; stdcall;
external 'wsdapi.dll' name 'WSDCreateDiscoveryPublisher2';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "WSDCreateDiscoveryPublisher2"
c_WSDCreateDiscoveryPublisher2 :: Ptr () -> Ptr () -> Word32 -> Ptr () -> IO Int32
-- pContext : IWSDXMLContext* -> Ptr ()
-- pConfigParams : WSD_CONFIG_PARAM* optional -> Ptr ()
-- dwConfigParamCount : DWORD -> Word32
-- ppPublisher : IWSDiscoveryPublisher** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let wsdcreatediscoverypublisher2 =
foreign "WSDCreateDiscoveryPublisher2"
((ptr void) @-> (ptr void) @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* pContext : IWSDXMLContext* -> (ptr void) *)
(* pConfigParams : WSD_CONFIG_PARAM* optional -> (ptr void) *)
(* dwConfigParamCount : DWORD -> uint32_t *)
(* ppPublisher : IWSDiscoveryPublisher** 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 ("WSDCreateDiscoveryPublisher2" wsdcreate-discovery-publisher2 :convention :stdcall) :int32
(p-context :pointer) ; IWSDXMLContext*
(p-config-params :pointer) ; WSD_CONFIG_PARAM* optional
(dw-config-param-count :uint32) ; DWORD
(pp-publisher :pointer)) ; IWSDiscoveryPublisher** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $WSDCreateDiscoveryPublisher2 = Win32::API::More->new('wsdapi',
'int WSDCreateDiscoveryPublisher2(LPVOID pContext, LPVOID pConfigParams, DWORD dwConfigParamCount, LPVOID ppPublisher)');
# my $ret = $WSDCreateDiscoveryPublisher2->Call($pContext, $pConfigParams, $dwConfigParamCount, $ppPublisher);
# pContext : IWSDXMLContext* -> LPVOID
# pConfigParams : WSD_CONFIG_PARAM* optional -> LPVOID
# dwConfigParamCount : DWORD -> DWORD
# ppPublisher : IWSDiscoveryPublisher** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f WSDCreateDiscoveryPublisher — WSDで自デバイスを公告するディスカバリパブリッシャを作成する。