Win32 API 日本語リファレンス
ホームGraphics.Printing › DeleteMonitorW

DeleteMonitorW

関数
指定のプリントモニターをシステムから削除する。
DLLwinspool.drv文字セットUnicode (-W)呼出規約winapiSetLastErrorあり

シグネチャ

// winspool.drv  (Unicode / -W)
#include <windows.h>

BOOL DeleteMonitorW(
    LPCWSTR pName,   // optional
    LPCWSTR pEnvironment,   // optional
    LPCWSTR pMonitorName
);

パラメーター

名前方向
pNameLPCWSTRinoptional
pEnvironmentLPCWSTRinoptional
pMonitorNameLPCWSTRin

戻り値の型: BOOL

各言語での呼び出し定義

// winspool.drv  (Unicode / -W)
#include <windows.h>

BOOL DeleteMonitorW(
    LPCWSTR pName,   // optional
    LPCWSTR pEnvironment,   // optional
    LPCWSTR pMonitorName
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("winspool.drv", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool DeleteMonitorW(
    [MarshalAs(UnmanagedType.LPWStr)] string pName,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string pEnvironment,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string pMonitorName   // LPCWSTR
);
<DllImport("winspool.drv", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DeleteMonitorW(
    <MarshalAs(UnmanagedType.LPWStr)> pName As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> pEnvironment As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> pMonitorName As String   ' LPCWSTR
) As Boolean
End Function
' pName : LPCWSTR optional
' pEnvironment : LPCWSTR optional
' pMonitorName : LPCWSTR
Declare PtrSafe Function DeleteMonitorW Lib "winspool.drv" ( _
    ByVal pName As LongPtr, _
    ByVal pEnvironment As LongPtr, _
    ByVal pMonitorName As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DeleteMonitorW = ctypes.windll.LoadLibrary("winspool.drv").DeleteMonitorW
DeleteMonitorW.restype = wintypes.BOOL
DeleteMonitorW.argtypes = [
    wintypes.LPCWSTR,  # pName : LPCWSTR optional
    wintypes.LPCWSTR,  # pEnvironment : LPCWSTR optional
    wintypes.LPCWSTR,  # pMonitorName : LPCWSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('winspool.drv')
DeleteMonitorW = Fiddle::Function.new(
  lib['DeleteMonitorW'],
  [
    Fiddle::TYPE_VOIDP,  # pName : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # pEnvironment : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # pMonitorName : LPCWSTR
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "winspool.drv")]
extern "system" {
    fn DeleteMonitorW(
        pName: *const u16,  // LPCWSTR optional
        pEnvironment: *const u16,  // LPCWSTR optional
        pMonitorName: *const u16  // LPCWSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("winspool.drv", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool DeleteMonitorW([MarshalAs(UnmanagedType.LPWStr)] string pName, [MarshalAs(UnmanagedType.LPWStr)] string pEnvironment, [MarshalAs(UnmanagedType.LPWStr)] string pMonitorName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winspool.drv_DeleteMonitorW' -Namespace Win32 -PassThru
# $api::DeleteMonitorW(pName, pEnvironment, pMonitorName)
#uselib "winspool.drv"
#func global DeleteMonitorW "DeleteMonitorW" wptr, wptr, wptr
; DeleteMonitorW pName, pEnvironment, pMonitorName   ; 戻り値は stat
; pName : LPCWSTR optional -> "wptr"
; pEnvironment : LPCWSTR optional -> "wptr"
; pMonitorName : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "winspool.drv"
#cfunc global DeleteMonitorW "DeleteMonitorW" wstr, wstr, wstr
; res = DeleteMonitorW(pName, pEnvironment, pMonitorName)
; pName : LPCWSTR optional -> "wstr"
; pEnvironment : LPCWSTR optional -> "wstr"
; pMonitorName : LPCWSTR -> "wstr"
; BOOL DeleteMonitorW(LPCWSTR pName, LPCWSTR pEnvironment, LPCWSTR pMonitorName)
#uselib "winspool.drv"
#cfunc global DeleteMonitorW "DeleteMonitorW" wstr, wstr, wstr
; res = DeleteMonitorW(pName, pEnvironment, pMonitorName)
; pName : LPCWSTR optional -> "wstr"
; pEnvironment : LPCWSTR optional -> "wstr"
; pMonitorName : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winspool_drv = windows.NewLazySystemDLL("winspool.drv")
	procDeleteMonitorW = winspool_drv.NewProc("DeleteMonitorW")
)

// pName (LPCWSTR optional), pEnvironment (LPCWSTR optional), pMonitorName (LPCWSTR)
r1, _, err := procDeleteMonitorW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pEnvironment))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pMonitorName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function DeleteMonitorW(
  pName: PWideChar;   // LPCWSTR optional
  pEnvironment: PWideChar;   // LPCWSTR optional
  pMonitorName: PWideChar   // LPCWSTR
): BOOL; stdcall;
  external 'winspool.drv' name 'DeleteMonitorW';
result := DllCall("winspool.drv\DeleteMonitorW"
    , "WStr", pName   ; LPCWSTR optional
    , "WStr", pEnvironment   ; LPCWSTR optional
    , "WStr", pMonitorName   ; LPCWSTR
    , "Int")   ; return: BOOL
●DeleteMonitorW(pName, pEnvironment, pMonitorName) = DLL("winspool.drv", "bool DeleteMonitorW(char*, char*, char*)")
# 呼び出し: DeleteMonitorW(pName, pEnvironment, pMonitorName)
# pName : LPCWSTR optional -> "char*"
# pEnvironment : LPCWSTR optional -> "char*"
# pMonitorName : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。