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

RemovePrintDeviceObject

関数
印刷デバイスオブジェクトを削除する。
DLLSPOOLSS.dll呼出規約winapi

シグネチャ

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

HRESULT RemovePrintDeviceObject(
    HANDLE hDeviceObject
);

パラメーター

名前方向説明
hDeviceObjectHANDLEin削除する印刷デバイスオブジェクトのハンドル。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT RemovePrintDeviceObject(
    HANDLE hDeviceObject
);
[DllImport("SPOOLSS.dll", ExactSpelling = true)]
static extern int RemovePrintDeviceObject(
    IntPtr hDeviceObject   // HANDLE
);
<DllImport("SPOOLSS.dll", ExactSpelling:=True)>
Public Shared Function RemovePrintDeviceObject(
    hDeviceObject As IntPtr   ' HANDLE
) As Integer
End Function
' hDeviceObject : HANDLE
Declare PtrSafe Function RemovePrintDeviceObject Lib "spoolss" ( _
    ByVal hDeviceObject As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RemovePrintDeviceObject = ctypes.windll.spoolss.RemovePrintDeviceObject
RemovePrintDeviceObject.restype = ctypes.c_int
RemovePrintDeviceObject.argtypes = [
    wintypes.HANDLE,  # hDeviceObject : HANDLE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SPOOLSS.dll')
RemovePrintDeviceObject = Fiddle::Function.new(
  lib['RemovePrintDeviceObject'],
  [
    Fiddle::TYPE_VOIDP,  # hDeviceObject : HANDLE
  ],
  Fiddle::TYPE_INT)
#[link(name = "spoolss")]
extern "system" {
    fn RemovePrintDeviceObject(
        hDeviceObject: *mut core::ffi::c_void  // HANDLE
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SPOOLSS.dll")]
public static extern int RemovePrintDeviceObject(IntPtr hDeviceObject);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SPOOLSS_RemovePrintDeviceObject' -Namespace Win32 -PassThru
# $api::RemovePrintDeviceObject(hDeviceObject)
#uselib "SPOOLSS.dll"
#func global RemovePrintDeviceObject "RemovePrintDeviceObject" sptr
; RemovePrintDeviceObject hDeviceObject   ; 戻り値は stat
; hDeviceObject : HANDLE -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SPOOLSS.dll"
#cfunc global RemovePrintDeviceObject "RemovePrintDeviceObject" sptr
; res = RemovePrintDeviceObject(hDeviceObject)
; hDeviceObject : HANDLE -> "sptr"
; HRESULT RemovePrintDeviceObject(HANDLE hDeviceObject)
#uselib "SPOOLSS.dll"
#cfunc global RemovePrintDeviceObject "RemovePrintDeviceObject" intptr
; res = RemovePrintDeviceObject(hDeviceObject)
; hDeviceObject : HANDLE -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	spoolss = windows.NewLazySystemDLL("SPOOLSS.dll")
	procRemovePrintDeviceObject = spoolss.NewProc("RemovePrintDeviceObject")
)

// hDeviceObject (HANDLE)
r1, _, err := procRemovePrintDeviceObject.Call(
	uintptr(hDeviceObject),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function RemovePrintDeviceObject(
  hDeviceObject: THandle   // HANDLE
): Integer; stdcall;
  external 'SPOOLSS.dll' name 'RemovePrintDeviceObject';
result := DllCall("SPOOLSS\RemovePrintDeviceObject"
    , "Ptr", hDeviceObject   ; HANDLE
    , "Int")   ; return: HRESULT
●RemovePrintDeviceObject(hDeviceObject) = DLL("SPOOLSS.dll", "int RemovePrintDeviceObject(void*)")
# 呼び出し: RemovePrintDeviceObject(hDeviceObject)
# hDeviceObject : HANDLE -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "spoolss" fn RemovePrintDeviceObject(
    hDeviceObject: ?*anyopaque // HANDLE
) callconv(std.os.windows.WINAPI) i32;
proc RemovePrintDeviceObject(
    hDeviceObject: pointer  # HANDLE
): int32 {.importc: "RemovePrintDeviceObject", stdcall, dynlib: "SPOOLSS.dll".}
pragma(lib, "spoolss");
extern(Windows)
int RemovePrintDeviceObject(
    void* hDeviceObject   // HANDLE
);
ccall((:RemovePrintDeviceObject, "SPOOLSS.dll"), stdcall, Int32,
      (Ptr{Cvoid},),
      hDeviceObject)
# hDeviceObject : HANDLE -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t RemovePrintDeviceObject(
    void* hDeviceObject);
]]
local spoolss = ffi.load("spoolss")
-- spoolss.RemovePrintDeviceObject(hDeviceObject)
-- hDeviceObject : HANDLE
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SPOOLSS.dll');
const RemovePrintDeviceObject = lib.func('__stdcall', 'RemovePrintDeviceObject', 'int32_t', ['void *']);
// RemovePrintDeviceObject(hDeviceObject)
// hDeviceObject : HANDLE -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SPOOLSS.dll", {
  RemovePrintDeviceObject: { parameters: ["pointer"], result: "i32" },
});
// lib.symbols.RemovePrintDeviceObject(hDeviceObject)
// hDeviceObject : HANDLE -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t RemovePrintDeviceObject(
    void* hDeviceObject);
C, "SPOOLSS.dll");
// $ffi->RemovePrintDeviceObject(hDeviceObject);
// hDeviceObject : HANDLE
// 構造体/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 Spoolss extends StdCallLibrary {
    Spoolss INSTANCE = Native.load("spoolss", Spoolss.class);
    int RemovePrintDeviceObject(
        Pointer hDeviceObject   // HANDLE
    );
}
@[Link("spoolss")]
lib LibSPOOLSS
  fun RemovePrintDeviceObject = RemovePrintDeviceObject(
    hDeviceObject : Void*   # HANDLE
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef RemovePrintDeviceObjectNative = Int32 Function(Pointer<Void>);
typedef RemovePrintDeviceObjectDart = int Function(Pointer<Void>);
final RemovePrintDeviceObject = DynamicLibrary.open('SPOOLSS.dll')
    .lookupFunction<RemovePrintDeviceObjectNative, RemovePrintDeviceObjectDart>('RemovePrintDeviceObject');
// hDeviceObject : HANDLE -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RemovePrintDeviceObject(
  hDeviceObject: THandle   // HANDLE
): Integer; stdcall;
  external 'SPOOLSS.dll' name 'RemovePrintDeviceObject';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RemovePrintDeviceObject"
  c_RemovePrintDeviceObject :: Ptr () -> IO Int32
-- hDeviceObject : HANDLE -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let removeprintdeviceobject =
  foreign "RemovePrintDeviceObject"
    ((ptr void) @-> returning int32_t)
(* hDeviceObject : HANDLE -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library spoolss (t "SPOOLSS.dll"))
(cffi:use-foreign-library spoolss)

(cffi:defcfun ("RemovePrintDeviceObject" remove-print-device-object :convention :stdcall) :int32
  (h-device-object :pointer))   ; HANDLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RemovePrintDeviceObject = Win32::API::More->new('SPOOLSS',
    'int RemovePrintDeviceObject(HANDLE hDeviceObject)');
# my $ret = $RemovePrintDeviceObject->Call($hDeviceObject);
# hDeviceObject : HANDLE -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。