ホーム › Management.MobileDeviceManagementRegistration › DiscoverManagementServiceEx
DiscoverManagementServiceEx
関数検出サービス候補を指定してMDM管理サービス情報を検出する。
シグネチャ
// MDMRegistration.dll
#include <windows.h>
HRESULT DiscoverManagementServiceEx(
LPCWSTR pszUPN,
LPCWSTR pszDiscoveryServiceCandidate,
MANAGEMENT_SERVICE_INFO** ppMgmtInfo
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszUPN | LPCWSTR | in |
| pszDiscoveryServiceCandidate | LPCWSTR | in |
| ppMgmtInfo | MANAGEMENT_SERVICE_INFO** | out |
戻り値の型: 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)。