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

DeleteMonitorA

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

シグネチャ

// winspool.drv  (ANSI / -A)
#include <windows.h>

BOOL DeleteMonitorA(
    LPCSTR pName,   // optional
    LPCSTR pEnvironment,   // optional
    LPCSTR pMonitorName
);

パラメーター

名前方向
pNameLPCSTRinoptional
pEnvironmentLPCSTRinoptional
pMonitorNameLPCSTRin

戻り値の型: BOOL

各言語での呼び出し定義

// winspool.drv  (ANSI / -A)
#include <windows.h>

BOOL DeleteMonitorA(
    LPCSTR pName,   // optional
    LPCSTR pEnvironment,   // optional
    LPCSTR pMonitorName
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("winspool.drv", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool DeleteMonitorA(
    [MarshalAs(UnmanagedType.LPStr)] string pName,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string pEnvironment,   // LPCSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string pMonitorName   // LPCSTR
);
<DllImport("winspool.drv", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DeleteMonitorA(
    <MarshalAs(UnmanagedType.LPStr)> pName As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> pEnvironment As String,   ' LPCSTR optional
    <MarshalAs(UnmanagedType.LPStr)> pMonitorName As String   ' LPCSTR
) As Boolean
End Function
' pName : LPCSTR optional
' pEnvironment : LPCSTR optional
' pMonitorName : LPCSTR
Declare PtrSafe Function DeleteMonitorA Lib "winspool.drv" ( _
    ByVal pName As String, _
    ByVal pEnvironment As String, _
    ByVal pMonitorName As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

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

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

var (
	winspool_drv = windows.NewLazySystemDLL("winspool.drv")
	procDeleteMonitorA = winspool_drv.NewProc("DeleteMonitorA")
)

// pName (LPCSTR optional), pEnvironment (LPCSTR optional), pMonitorName (LPCSTR)
r1, _, err := procDeleteMonitorA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pName))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pEnvironment))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pMonitorName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function DeleteMonitorA(
  pName: PAnsiChar;   // LPCSTR optional
  pEnvironment: PAnsiChar;   // LPCSTR optional
  pMonitorName: PAnsiChar   // LPCSTR
): BOOL; stdcall;
  external 'winspool.drv' name 'DeleteMonitorA';
result := DllCall("winspool.drv\DeleteMonitorA"
    , "AStr", pName   ; LPCSTR optional
    , "AStr", pEnvironment   ; LPCSTR optional
    , "AStr", pMonitorName   ; LPCSTR
    , "Int")   ; return: BOOL
●DeleteMonitorA(pName, pEnvironment, pMonitorName) = DLL("winspool.drv", "bool DeleteMonitorA(char*, char*, char*)")
# 呼び出し: DeleteMonitorA(pName, pEnvironment, pMonitorName)
# pName : LPCSTR optional -> "char*"
# pEnvironment : LPCSTR optional -> "char*"
# pMonitorName : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。