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