Win32 API 日本語リファレンス
ホームManagement.MobileDeviceManagementRegistration › IsDeviceRegisteredWithManagement

IsDeviceRegisteredWithManagement

関数
デバイスがMDMに登録済みかどうかを判定する。
DLLMDMRegistration.dll呼出規約winapi対応OSWindows 8.1 以降

シグネチャ

// MDMRegistration.dll
#include <windows.h>

HRESULT IsDeviceRegisteredWithManagement(
    BOOL* pfIsDeviceRegisteredWithManagement,
    DWORD cchUPN,
    LPWSTR pszUPN   // optional
);

パラメーター

名前方向
pfIsDeviceRegisteredWithManagementBOOL*out
cchUPNDWORDin
pszUPNLPWSTRoutoptional

戻り値の型: HRESULT

各言語での呼び出し定義

// MDMRegistration.dll
#include <windows.h>

HRESULT IsDeviceRegisteredWithManagement(
    BOOL* pfIsDeviceRegisteredWithManagement,
    DWORD cchUPN,
    LPWSTR pszUPN   // optional
);
[DllImport("MDMRegistration.dll", ExactSpelling = true)]
static extern int IsDeviceRegisteredWithManagement(
    out int pfIsDeviceRegisteredWithManagement,   // BOOL* out
    uint cchUPN,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszUPN   // LPWSTR optional, out
);
<DllImport("MDMRegistration.dll", ExactSpelling:=True)>
Public Shared Function IsDeviceRegisteredWithManagement(
    <Out> ByRef pfIsDeviceRegisteredWithManagement As Integer,   ' BOOL* out
    cchUPN As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> pszUPN As System.Text.StringBuilder   ' LPWSTR optional, out
) As Integer
End Function
' pfIsDeviceRegisteredWithManagement : BOOL* out
' cchUPN : DWORD
' pszUPN : LPWSTR optional, out
Declare PtrSafe Function IsDeviceRegisteredWithManagement Lib "mdmregistration" ( _
    ByRef pfIsDeviceRegisteredWithManagement As Long, _
    ByVal cchUPN As Long, _
    ByVal pszUPN As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

IsDeviceRegisteredWithManagement = ctypes.windll.mdmregistration.IsDeviceRegisteredWithManagement
IsDeviceRegisteredWithManagement.restype = ctypes.c_int
IsDeviceRegisteredWithManagement.argtypes = [
    ctypes.c_void_p,  # pfIsDeviceRegisteredWithManagement : BOOL* out
    wintypes.DWORD,  # cchUPN : DWORD
    wintypes.LPWSTR,  # pszUPN : LPWSTR optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('MDMRegistration.dll')
IsDeviceRegisteredWithManagement = Fiddle::Function.new(
  lib['IsDeviceRegisteredWithManagement'],
  [
    Fiddle::TYPE_VOIDP,  # pfIsDeviceRegisteredWithManagement : BOOL* out
    -Fiddle::TYPE_INT,  # cchUPN : DWORD
    Fiddle::TYPE_VOIDP,  # pszUPN : LPWSTR optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "mdmregistration")]
extern "system" {
    fn IsDeviceRegisteredWithManagement(
        pfIsDeviceRegisteredWithManagement: *mut i32,  // BOOL* out
        cchUPN: u32,  // DWORD
        pszUPN: *mut u16  // LPWSTR optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("MDMRegistration.dll")]
public static extern int IsDeviceRegisteredWithManagement(out int pfIsDeviceRegisteredWithManagement, uint cchUPN, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszUPN);
"@
$api = Add-Type -MemberDefinition $sig -Name 'MDMRegistration_IsDeviceRegisteredWithManagement' -Namespace Win32 -PassThru
# $api::IsDeviceRegisteredWithManagement(pfIsDeviceRegisteredWithManagement, cchUPN, pszUPN)
#uselib "MDMRegistration.dll"
#func global IsDeviceRegisteredWithManagement "IsDeviceRegisteredWithManagement" sptr, sptr, sptr
; IsDeviceRegisteredWithManagement pfIsDeviceRegisteredWithManagement, cchUPN, varptr(pszUPN)   ; 戻り値は stat
; pfIsDeviceRegisteredWithManagement : BOOL* out -> "sptr"
; cchUPN : DWORD -> "sptr"
; pszUPN : LPWSTR optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "MDMRegistration.dll"
#cfunc global IsDeviceRegisteredWithManagement "IsDeviceRegisteredWithManagement" int, int, var
; res = IsDeviceRegisteredWithManagement(pfIsDeviceRegisteredWithManagement, cchUPN, pszUPN)
; pfIsDeviceRegisteredWithManagement : BOOL* out -> "int"
; cchUPN : DWORD -> "int"
; pszUPN : LPWSTR optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT IsDeviceRegisteredWithManagement(BOOL* pfIsDeviceRegisteredWithManagement, DWORD cchUPN, LPWSTR pszUPN)
#uselib "MDMRegistration.dll"
#cfunc global IsDeviceRegisteredWithManagement "IsDeviceRegisteredWithManagement" int, int, var
; res = IsDeviceRegisteredWithManagement(pfIsDeviceRegisteredWithManagement, cchUPN, pszUPN)
; pfIsDeviceRegisteredWithManagement : BOOL* out -> "int"
; cchUPN : DWORD -> "int"
; pszUPN : LPWSTR optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	mdmregistration = windows.NewLazySystemDLL("MDMRegistration.dll")
	procIsDeviceRegisteredWithManagement = mdmregistration.NewProc("IsDeviceRegisteredWithManagement")
)

// pfIsDeviceRegisteredWithManagement (BOOL* out), cchUPN (DWORD), pszUPN (LPWSTR optional, out)
r1, _, err := procIsDeviceRegisteredWithManagement.Call(
	uintptr(pfIsDeviceRegisteredWithManagement),
	uintptr(cchUPN),
	uintptr(pszUPN),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function IsDeviceRegisteredWithManagement(
  pfIsDeviceRegisteredWithManagement: Pointer;   // BOOL* out
  cchUPN: DWORD;   // DWORD
  pszUPN: PWideChar   // LPWSTR optional, out
): Integer; stdcall;
  external 'MDMRegistration.dll' name 'IsDeviceRegisteredWithManagement';
result := DllCall("MDMRegistration\IsDeviceRegisteredWithManagement"
    , "Ptr", pfIsDeviceRegisteredWithManagement   ; BOOL* out
    , "UInt", cchUPN   ; DWORD
    , "Ptr", pszUPN   ; LPWSTR optional, out
    , "Int")   ; return: HRESULT
●IsDeviceRegisteredWithManagement(pfIsDeviceRegisteredWithManagement, cchUPN, pszUPN) = DLL("MDMRegistration.dll", "int IsDeviceRegisteredWithManagement(void*, dword, char*)")
# 呼び出し: IsDeviceRegisteredWithManagement(pfIsDeviceRegisteredWithManagement, cchUPN, pszUPN)
# pfIsDeviceRegisteredWithManagement : BOOL* out -> "void*"
# cchUPN : DWORD -> "dword"
# pszUPN : LPWSTR optional, out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。