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

PrinterProperties

関数
プリンタのプロパティ設定ダイアログを表示する。
DLLwinspool.drv呼出規約winapi

シグネチャ

// winspool.drv
#include <windows.h>

BOOL PrinterProperties(
    HWND hWnd,
    PRINTER_HANDLE hPrinter
);

パラメーター

名前方向説明
hWndHWNDinプロパティダイアログの親ウィンドウのハンドル。
hPrinterPRINTER_HANDLEinプロパティを表示する対象プリンターのハンドル。

戻り値の型: BOOL

各言語での呼び出し定義

// winspool.drv
#include <windows.h>

BOOL PrinterProperties(
    HWND hWnd,
    PRINTER_HANDLE hPrinter
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("winspool.drv", ExactSpelling = true)]
static extern bool PrinterProperties(
    IntPtr hWnd,   // HWND
    PRINTER_HANDLE hPrinter   // PRINTER_HANDLE
);
<DllImport("winspool.drv", ExactSpelling:=True)>
Public Shared Function PrinterProperties(
    hWnd As IntPtr,   ' HWND
    hPrinter As PRINTER_HANDLE   ' PRINTER_HANDLE
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' hWnd : HWND
' hPrinter : PRINTER_HANDLE
Declare PtrSafe Function PrinterProperties Lib "winspool.drv" ( _
    ByVal hWnd As LongPtr, _
    ByVal hPrinter As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PrinterProperties = ctypes.windll.LoadLibrary("winspool.drv").PrinterProperties
PrinterProperties.restype = wintypes.BOOL
PrinterProperties.argtypes = [
    wintypes.HANDLE,  # hWnd : HWND
    PRINTER_HANDLE,  # hPrinter : PRINTER_HANDLE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('winspool.drv')
PrinterProperties = Fiddle::Function.new(
  lib['PrinterProperties'],
  [
    Fiddle::TYPE_VOIDP,  # hWnd : HWND
    Fiddle::TYPE_VOIDP,  # hPrinter : PRINTER_HANDLE
  ],
  Fiddle::TYPE_INT)
#[link(name = "winspool.drv")]
extern "system" {
    fn PrinterProperties(
        hWnd: *mut core::ffi::c_void,  // HWND
        hPrinter: PRINTER_HANDLE  // PRINTER_HANDLE
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("winspool.drv")]
public static extern bool PrinterProperties(IntPtr hWnd, PRINTER_HANDLE hPrinter);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winspool.drv_PrinterProperties' -Namespace Win32 -PassThru
# $api::PrinterProperties(hWnd, hPrinter)
#uselib "winspool.drv"
#func global PrinterProperties "PrinterProperties" sptr, sptr
; PrinterProperties hWnd, hPrinter   ; 戻り値は stat
; hWnd : HWND -> "sptr"
; hPrinter : PRINTER_HANDLE -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "winspool.drv"
#cfunc global PrinterProperties "PrinterProperties" sptr, int
; res = PrinterProperties(hWnd, hPrinter)
; hWnd : HWND -> "sptr"
; hPrinter : PRINTER_HANDLE -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; BOOL PrinterProperties(HWND hWnd, PRINTER_HANDLE hPrinter)
#uselib "winspool.drv"
#cfunc global PrinterProperties "PrinterProperties" intptr, int
; res = PrinterProperties(hWnd, hPrinter)
; hWnd : HWND -> "intptr"
; hPrinter : PRINTER_HANDLE -> "int"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winspool_drv = windows.NewLazySystemDLL("winspool.drv")
	procPrinterProperties = winspool_drv.NewProc("PrinterProperties")
)

// hWnd (HWND), hPrinter (PRINTER_HANDLE)
r1, _, err := procPrinterProperties.Call(
	uintptr(hWnd),
	uintptr(hPrinter),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function PrinterProperties(
  hWnd: THandle;   // HWND
  hPrinter: PRINTER_HANDLE   // PRINTER_HANDLE
): BOOL; stdcall;
  external 'winspool.drv' name 'PrinterProperties';
result := DllCall("winspool.drv\PrinterProperties"
    , "Ptr", hWnd   ; HWND
    , "Ptr", hPrinter   ; PRINTER_HANDLE
    , "Int")   ; return: BOOL
●PrinterProperties(hWnd, hPrinter) = DLL("winspool.drv", "bool PrinterProperties(void*, void*)")
# 呼び出し: PrinterProperties(hWnd, hPrinter)
# hWnd : HWND -> "void*"
# hPrinter : PRINTER_HANDLE -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef PrinterPropertiesNative = Int32 Function(Pointer<Void>, PRINTER_HANDLE);
typedef PrinterPropertiesDart = int Function(Pointer<Void>, int);
final PrinterProperties = DynamicLibrary.open('winspool.drv')
    .lookupFunction<PrinterPropertiesNative, PrinterPropertiesDart>('PrinterProperties');
// hWnd : HWND -> Pointer<Void>
// hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PrinterProperties(
  hWnd: THandle;   // HWND
  hPrinter: PRINTER_HANDLE   // PRINTER_HANDLE
): BOOL; stdcall;
  external 'winspool.drv' name 'PrinterProperties';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PrinterProperties"
  c_PrinterProperties :: Ptr () -> PRINTER_HANDLE -> IO CInt
-- hWnd : HWND -> Ptr ()
-- hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
-- ※値渡し構造体は GHC FFI で直接渡せません。Ptr で渡すラッパ(C側)経由にしてください。
open Ctypes
open Foreign

let printerproperties =
  foreign "PrinterProperties"
    ((ptr void) @-> PRINTER_HANDLE @-> returning int32_t)
(* hWnd : HWND -> (ptr void) *)
(* hPrinter : PRINTER_HANDLE -> PRINTER_HANDLE *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library winspool.drv (t "winspool.drv"))
(cffi:use-foreign-library winspool.drv)

(cffi:defcfun ("PrinterProperties" printer-properties :convention :stdcall) :int32
  (h-wnd :pointer)   ; HWND
  (h-printer (:struct printer-handle)))   ; PRINTER_HANDLE
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PrinterProperties = Win32::API::More->new('winspool.drv',
    'BOOL PrinterProperties(HANDLE hWnd, LPVOID hPrinter)');
# my $ret = $PrinterProperties->Call($hWnd, $hPrinter);
# hWnd : HWND -> HANDLE
# hPrinter : PRINTER_HANDLE -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型