ホーム › Graphics.Printing › DeleteMonitorA
DeleteMonitorA
関数指定のプリントモニターをシステムから削除する。
シグネチャ
// winspool.drv (ANSI / -A)
#include <windows.h>
BOOL DeleteMonitorA(
LPCSTR pName, // optional
LPCSTR pEnvironment, // optional
LPCSTR pMonitorName
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pName | LPCSTR | inoptional | 対象サーバー名を指すポインタ。ローカルならNULLを指定する。 |
| pEnvironment | LPCSTR | inoptional | 対象環境名を指すポインタ。NULLで現在の環境を使う。 |
| pMonitorName | LPCSTR | in | 削除するポートモニターの名前を指すポインタ。 |
戻り値の型: 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 <MarshalAs(UnmanagedType.Bool)> 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 // BOOLfunction 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)。const std = @import("std");
extern "winspool.drv" fn DeleteMonitorA(
pName: [*c]const u8, // LPCSTR optional
pEnvironment: [*c]const u8, // LPCSTR optional
pMonitorName: [*c]const u8 // LPCSTR
) callconv(std.os.windows.WINAPI) i32;proc DeleteMonitorA(
pName: cstring, # LPCSTR optional
pEnvironment: cstring, # LPCSTR optional
pMonitorName: cstring # LPCSTR
): int32 {.importc: "DeleteMonitorA", stdcall, dynlib: "winspool.drv".}pragma(lib, "winspool.drv");
extern(Windows)
int DeleteMonitorA(
const(char)* pName, // LPCSTR optional
const(char)* pEnvironment, // LPCSTR optional
const(char)* pMonitorName // LPCSTR
);ccall((:DeleteMonitorA, "winspool.drv"), stdcall, Int32,
(Cstring, Cstring, Cstring),
pName, pEnvironment, pMonitorName)
# pName : LPCSTR optional -> Cstring
# pEnvironment : LPCSTR optional -> Cstring
# pMonitorName : LPCSTR -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t DeleteMonitorA(
const char* pName,
const char* pEnvironment,
const char* pMonitorName);
]]
local winspool.drv = ffi.load("winspool.drv")
-- winspool.drv.DeleteMonitorA(pName, pEnvironment, pMonitorName)
-- pName : LPCSTR optional
-- pEnvironment : LPCSTR optional
-- pMonitorName : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('winspool.drv');
const DeleteMonitorA = lib.func('__stdcall', 'DeleteMonitorA', 'int32_t', ['str', 'str', 'str']);
// DeleteMonitorA(pName, pEnvironment, pMonitorName)
// pName : LPCSTR optional -> 'str'
// pEnvironment : LPCSTR optional -> 'str'
// pMonitorName : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("winspool.drv", {
DeleteMonitorA: { parameters: ["buffer", "buffer", "buffer"], result: "i32" },
});
// lib.symbols.DeleteMonitorA(pName, pEnvironment, pMonitorName)
// pName : LPCSTR optional -> "buffer"
// pEnvironment : LPCSTR optional -> "buffer"
// pMonitorName : LPCSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t DeleteMonitorA(
const char* pName,
const char* pEnvironment,
const char* pMonitorName);
C, "winspool.drv");
// $ffi->DeleteMonitorA(pName, pEnvironment, pMonitorName);
// pName : LPCSTR optional
// pEnvironment : LPCSTR optional
// pMonitorName : LPCSTR
// 構造体/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 Winspool.drv extends StdCallLibrary {
Winspool.drv INSTANCE = Native.load("winspool.drv", Winspool.drv.class, W32APIOptions.ASCII_OPTIONS);
boolean DeleteMonitorA(
String pName, // LPCSTR optional
String pEnvironment, // LPCSTR optional
String pMonitorName // LPCSTR
);
}@[Link("winspool.drv")]
lib Libwinspool.drv
fun DeleteMonitorA = DeleteMonitorA(
pName : UInt8*, # LPCSTR optional
pEnvironment : UInt8*, # LPCSTR optional
pMonitorName : UInt8* # LPCSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DeleteMonitorANative = Int32 Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>);
typedef DeleteMonitorADart = int Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>);
final DeleteMonitorA = DynamicLibrary.open('winspool.drv')
.lookupFunction<DeleteMonitorANative, DeleteMonitorADart>('DeleteMonitorA');
// pName : LPCSTR optional -> Pointer<Utf8>
// pEnvironment : LPCSTR optional -> Pointer<Utf8>
// pMonitorName : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DeleteMonitorA(
pName: PAnsiChar; // LPCSTR optional
pEnvironment: PAnsiChar; // LPCSTR optional
pMonitorName: PAnsiChar // LPCSTR
): BOOL; stdcall;
external 'winspool.drv' name 'DeleteMonitorA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DeleteMonitorA"
c_DeleteMonitorA :: CString -> CString -> CString -> IO CInt
-- pName : LPCSTR optional -> CString
-- pEnvironment : LPCSTR optional -> CString
-- pMonitorName : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let deletemonitora =
foreign "DeleteMonitorA"
(string @-> string @-> string @-> returning int32_t)
(* pName : LPCSTR optional -> string *)
(* pEnvironment : LPCSTR optional -> string *)
(* pMonitorName : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winspool.drv (t "winspool.drv"))
(cffi:use-foreign-library winspool.drv)
(cffi:defcfun ("DeleteMonitorA" delete-monitor-a :convention :stdcall) :int32
(p-name :string) ; LPCSTR optional
(p-environment :string) ; LPCSTR optional
(p-monitor-name :string)) ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DeleteMonitorA = Win32::API::More->new('winspool.drv',
'BOOL DeleteMonitorA(LPCSTR pName, LPCSTR pEnvironment, LPCSTR pMonitorName)');
# my $ret = $DeleteMonitorA->Call($pName, $pEnvironment, $pMonitorName);
# pName : LPCSTR optional -> LPCSTR
# pEnvironment : LPCSTR optional -> LPCSTR
# pMonitorName : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f DeleteMonitorW (Unicode版) — 指定のプリントモニターをシステムから削除する。