ホーム › Management.MobileDeviceManagementRegistration › DiscoverManagementServiceEx
DiscoverManagementServiceEx
関数検出サービス候補を指定してMDM管理サービス情報を検出する。
シグネチャ
// MDMRegistration.dll
#include <windows.h>
HRESULT DiscoverManagementServiceEx(
LPCWSTR pszUPN,
LPCWSTR pszDiscoveryServiceCandidate,
MANAGEMENT_SERVICE_INFO** ppMgmtInfo
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszUPN | LPCWSTR | in | 検出に使用するユーザーのUPNを示す文字列(Unicode)。 |
| pszDiscoveryServiceCandidate | LPCWSTR | in | 検出サービスの候補URLを示す文字列(Unicode)。NULL可。 |
| ppMgmtInfo | MANAGEMENT_SERVICE_INFO** | out | 検出された管理サービス情報MANAGEMENT_SERVICE_INFOを受け取るポインタのポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// MDMRegistration.dll
#include <windows.h>
HRESULT DiscoverManagementServiceEx(
LPCWSTR pszUPN,
LPCWSTR pszDiscoveryServiceCandidate,
MANAGEMENT_SERVICE_INFO** ppMgmtInfo
);[DllImport("MDMRegistration.dll", ExactSpelling = true)]
static extern int DiscoverManagementServiceEx(
[MarshalAs(UnmanagedType.LPWStr)] string pszUPN, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pszDiscoveryServiceCandidate, // LPCWSTR
IntPtr ppMgmtInfo // MANAGEMENT_SERVICE_INFO** out
);<DllImport("MDMRegistration.dll", ExactSpelling:=True)>
Public Shared Function DiscoverManagementServiceEx(
<MarshalAs(UnmanagedType.LPWStr)> pszUPN As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pszDiscoveryServiceCandidate As String, ' LPCWSTR
ppMgmtInfo As IntPtr ' MANAGEMENT_SERVICE_INFO** out
) As Integer
End Function' pszUPN : LPCWSTR
' pszDiscoveryServiceCandidate : LPCWSTR
' ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out
Declare PtrSafe Function DiscoverManagementServiceEx Lib "mdmregistration" ( _
ByVal pszUPN As LongPtr, _
ByVal pszDiscoveryServiceCandidate As LongPtr, _
ByVal ppMgmtInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DiscoverManagementServiceEx = ctypes.windll.mdmregistration.DiscoverManagementServiceEx
DiscoverManagementServiceEx.restype = ctypes.c_int
DiscoverManagementServiceEx.argtypes = [
wintypes.LPCWSTR, # pszUPN : LPCWSTR
wintypes.LPCWSTR, # pszDiscoveryServiceCandidate : LPCWSTR
ctypes.c_void_p, # ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('MDMRegistration.dll')
DiscoverManagementServiceEx = Fiddle::Function.new(
lib['DiscoverManagementServiceEx'],
[
Fiddle::TYPE_VOIDP, # pszUPN : LPCWSTR
Fiddle::TYPE_VOIDP, # pszDiscoveryServiceCandidate : LPCWSTR
Fiddle::TYPE_VOIDP, # ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out
],
Fiddle::TYPE_INT)#[link(name = "mdmregistration")]
extern "system" {
fn DiscoverManagementServiceEx(
pszUPN: *const u16, // LPCWSTR
pszDiscoveryServiceCandidate: *const u16, // LPCWSTR
ppMgmtInfo: *mut *mut MANAGEMENT_SERVICE_INFO // MANAGEMENT_SERVICE_INFO** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("MDMRegistration.dll")]
public static extern int DiscoverManagementServiceEx([MarshalAs(UnmanagedType.LPWStr)] string pszUPN, [MarshalAs(UnmanagedType.LPWStr)] string pszDiscoveryServiceCandidate, IntPtr ppMgmtInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MDMRegistration_DiscoverManagementServiceEx' -Namespace Win32 -PassThru
# $api::DiscoverManagementServiceEx(pszUPN, pszDiscoveryServiceCandidate, ppMgmtInfo)#uselib "MDMRegistration.dll"
#func global DiscoverManagementServiceEx "DiscoverManagementServiceEx" sptr, sptr, sptr
; DiscoverManagementServiceEx pszUPN, pszDiscoveryServiceCandidate, varptr(ppMgmtInfo) ; 戻り値は stat
; pszUPN : LPCWSTR -> "sptr"
; pszDiscoveryServiceCandidate : LPCWSTR -> "sptr"
; ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "MDMRegistration.dll" #cfunc global DiscoverManagementServiceEx "DiscoverManagementServiceEx" wstr, wstr, var ; res = DiscoverManagementServiceEx(pszUPN, pszDiscoveryServiceCandidate, ppMgmtInfo) ; pszUPN : LPCWSTR -> "wstr" ; pszDiscoveryServiceCandidate : LPCWSTR -> "wstr" ; ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "MDMRegistration.dll" #cfunc global DiscoverManagementServiceEx "DiscoverManagementServiceEx" wstr, wstr, sptr ; res = DiscoverManagementServiceEx(pszUPN, pszDiscoveryServiceCandidate, varptr(ppMgmtInfo)) ; pszUPN : LPCWSTR -> "wstr" ; pszDiscoveryServiceCandidate : LPCWSTR -> "wstr" ; ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT DiscoverManagementServiceEx(LPCWSTR pszUPN, LPCWSTR pszDiscoveryServiceCandidate, MANAGEMENT_SERVICE_INFO** ppMgmtInfo) #uselib "MDMRegistration.dll" #cfunc global DiscoverManagementServiceEx "DiscoverManagementServiceEx" wstr, wstr, var ; res = DiscoverManagementServiceEx(pszUPN, pszDiscoveryServiceCandidate, ppMgmtInfo) ; pszUPN : LPCWSTR -> "wstr" ; pszDiscoveryServiceCandidate : LPCWSTR -> "wstr" ; ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT DiscoverManagementServiceEx(LPCWSTR pszUPN, LPCWSTR pszDiscoveryServiceCandidate, MANAGEMENT_SERVICE_INFO** ppMgmtInfo) #uselib "MDMRegistration.dll" #cfunc global DiscoverManagementServiceEx "DiscoverManagementServiceEx" wstr, wstr, intptr ; res = DiscoverManagementServiceEx(pszUPN, pszDiscoveryServiceCandidate, varptr(ppMgmtInfo)) ; pszUPN : LPCWSTR -> "wstr" ; pszDiscoveryServiceCandidate : LPCWSTR -> "wstr" ; ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
mdmregistration = windows.NewLazySystemDLL("MDMRegistration.dll")
procDiscoverManagementServiceEx = mdmregistration.NewProc("DiscoverManagementServiceEx")
)
// pszUPN (LPCWSTR), pszDiscoveryServiceCandidate (LPCWSTR), ppMgmtInfo (MANAGEMENT_SERVICE_INFO** out)
r1, _, err := procDiscoverManagementServiceEx.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszUPN))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszDiscoveryServiceCandidate))),
uintptr(ppMgmtInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction DiscoverManagementServiceEx(
pszUPN: PWideChar; // LPCWSTR
pszDiscoveryServiceCandidate: PWideChar; // LPCWSTR
ppMgmtInfo: Pointer // MANAGEMENT_SERVICE_INFO** out
): Integer; stdcall;
external 'MDMRegistration.dll' name 'DiscoverManagementServiceEx';result := DllCall("MDMRegistration\DiscoverManagementServiceEx"
, "WStr", pszUPN ; LPCWSTR
, "WStr", pszDiscoveryServiceCandidate ; LPCWSTR
, "Ptr", ppMgmtInfo ; MANAGEMENT_SERVICE_INFO** out
, "Int") ; return: HRESULT●DiscoverManagementServiceEx(pszUPN, pszDiscoveryServiceCandidate, ppMgmtInfo) = DLL("MDMRegistration.dll", "int DiscoverManagementServiceEx(char*, char*, void*)")
# 呼び出し: DiscoverManagementServiceEx(pszUPN, pszDiscoveryServiceCandidate, ppMgmtInfo)
# pszUPN : LPCWSTR -> "char*"
# pszDiscoveryServiceCandidate : LPCWSTR -> "char*"
# ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "mdmregistration" fn DiscoverManagementServiceEx(
pszUPN: [*c]const u16, // LPCWSTR
pszDiscoveryServiceCandidate: [*c]const u16, // LPCWSTR
ppMgmtInfo: [*c][*c]MANAGEMENT_SERVICE_INFO // MANAGEMENT_SERVICE_INFO** out
) callconv(std.os.windows.WINAPI) i32;proc DiscoverManagementServiceEx(
pszUPN: WideCString, # LPCWSTR
pszDiscoveryServiceCandidate: WideCString, # LPCWSTR
ppMgmtInfo: ptr MANAGEMENT_SERVICE_INFO # MANAGEMENT_SERVICE_INFO** out
): int32 {.importc: "DiscoverManagementServiceEx", stdcall, dynlib: "MDMRegistration.dll".}pragma(lib, "mdmregistration");
extern(Windows)
int DiscoverManagementServiceEx(
const(wchar)* pszUPN, // LPCWSTR
const(wchar)* pszDiscoveryServiceCandidate, // LPCWSTR
MANAGEMENT_SERVICE_INFO** ppMgmtInfo // MANAGEMENT_SERVICE_INFO** out
);ccall((:DiscoverManagementServiceEx, "MDMRegistration.dll"), stdcall, Int32,
(Cwstring, Cwstring, Ptr{MANAGEMENT_SERVICE_INFO}),
pszUPN, pszDiscoveryServiceCandidate, ppMgmtInfo)
# pszUPN : LPCWSTR -> Cwstring
# pszDiscoveryServiceCandidate : LPCWSTR -> Cwstring
# ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out -> Ptr{MANAGEMENT_SERVICE_INFO}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DiscoverManagementServiceEx(
const uint16_t* pszUPN,
const uint16_t* pszDiscoveryServiceCandidate,
void* ppMgmtInfo);
]]
local mdmregistration = ffi.load("mdmregistration")
-- mdmregistration.DiscoverManagementServiceEx(pszUPN, pszDiscoveryServiceCandidate, ppMgmtInfo)
-- pszUPN : LPCWSTR
-- pszDiscoveryServiceCandidate : LPCWSTR
-- ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('MDMRegistration.dll');
const DiscoverManagementServiceEx = lib.func('__stdcall', 'DiscoverManagementServiceEx', 'int32_t', ['str16', 'str16', 'void *']);
// DiscoverManagementServiceEx(pszUPN, pszDiscoveryServiceCandidate, ppMgmtInfo)
// pszUPN : LPCWSTR -> 'str16'
// pszDiscoveryServiceCandidate : LPCWSTR -> 'str16'
// ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("MDMRegistration.dll", {
DiscoverManagementServiceEx: { parameters: ["buffer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.DiscoverManagementServiceEx(pszUPN, pszDiscoveryServiceCandidate, ppMgmtInfo)
// pszUPN : LPCWSTR -> "buffer"
// pszDiscoveryServiceCandidate : LPCWSTR -> "buffer"
// ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DiscoverManagementServiceEx(
const uint16_t* pszUPN,
const uint16_t* pszDiscoveryServiceCandidate,
void* ppMgmtInfo);
C, "MDMRegistration.dll");
// $ffi->DiscoverManagementServiceEx(pszUPN, pszDiscoveryServiceCandidate, ppMgmtInfo);
// pszUPN : LPCWSTR
// pszDiscoveryServiceCandidate : LPCWSTR
// ppMgmtInfo : MANAGEMENT_SERVICE_INFO** 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 Mdmregistration extends StdCallLibrary {
Mdmregistration INSTANCE = Native.load("mdmregistration", Mdmregistration.class);
int DiscoverManagementServiceEx(
WString pszUPN, // LPCWSTR
WString pszDiscoveryServiceCandidate, // LPCWSTR
Pointer ppMgmtInfo // MANAGEMENT_SERVICE_INFO** out
);
}@[Link("mdmregistration")]
lib LibMDMRegistration
fun DiscoverManagementServiceEx = DiscoverManagementServiceEx(
pszUPN : UInt16*, # LPCWSTR
pszDiscoveryServiceCandidate : UInt16*, # LPCWSTR
ppMgmtInfo : MANAGEMENT_SERVICE_INFO** # MANAGEMENT_SERVICE_INFO** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DiscoverManagementServiceExNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>);
typedef DiscoverManagementServiceExDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Void>);
final DiscoverManagementServiceEx = DynamicLibrary.open('MDMRegistration.dll')
.lookupFunction<DiscoverManagementServiceExNative, DiscoverManagementServiceExDart>('DiscoverManagementServiceEx');
// pszUPN : LPCWSTR -> Pointer<Utf16>
// pszDiscoveryServiceCandidate : LPCWSTR -> Pointer<Utf16>
// ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DiscoverManagementServiceEx(
pszUPN: PWideChar; // LPCWSTR
pszDiscoveryServiceCandidate: PWideChar; // LPCWSTR
ppMgmtInfo: Pointer // MANAGEMENT_SERVICE_INFO** out
): Integer; stdcall;
external 'MDMRegistration.dll' name 'DiscoverManagementServiceEx';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DiscoverManagementServiceEx"
c_DiscoverManagementServiceEx :: CWString -> CWString -> Ptr () -> IO Int32
-- pszUPN : LPCWSTR -> CWString
-- pszDiscoveryServiceCandidate : LPCWSTR -> CWString
-- ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let discovermanagementserviceex =
foreign "DiscoverManagementServiceEx"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr void) @-> returning int32_t)
(* pszUPN : LPCWSTR -> (ptr uint16_t) *)
(* pszDiscoveryServiceCandidate : LPCWSTR -> (ptr uint16_t) *)
(* ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library mdmregistration (t "MDMRegistration.dll"))
(cffi:use-foreign-library mdmregistration)
(cffi:defcfun ("DiscoverManagementServiceEx" discover-management-service-ex :convention :stdcall) :int32
(psz-upn (:string :encoding :utf-16le)) ; LPCWSTR
(psz-discovery-service-candidate (:string :encoding :utf-16le)) ; LPCWSTR
(pp-mgmt-info :pointer)) ; MANAGEMENT_SERVICE_INFO** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DiscoverManagementServiceEx = Win32::API::More->new('MDMRegistration',
'int DiscoverManagementServiceEx(LPCWSTR pszUPN, LPCWSTR pszDiscoveryServiceCandidate, LPVOID ppMgmtInfo)');
# my $ret = $DiscoverManagementServiceEx->Call($pszUPN, $pszDiscoveryServiceCandidate, $ppMgmtInfo);
# pszUPN : LPCWSTR -> LPCWSTR
# pszDiscoveryServiceCandidate : LPCWSTR -> LPCWSTR
# ppMgmtInfo : MANAGEMENT_SERVICE_INFO** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f DiscoverManagementService — UPNからMDM管理サービスの接続情報を検出して取得する。