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

PTGetPrintDeviceResources

関数
印刷デバイスのリソース情報を取得する。
DLLprntvpt.dll呼出規約winapi対応OSWindows 10 以降

シグネチャ

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

HRESULT PTGetPrintDeviceResources(
    HPTPROVIDER hProvider,
    LPCWSTR pszLocaleName,
    IStream* pPrintTicket,   // optional
    IStream* pDeviceResources,
    LPWSTR* pbstrErrorMessage   // optional
);

パラメーター

名前方向説明
hProviderHPTPROVIDERinPTOpenProviderで取得したプロバイダのハンドル。
pszLocaleNameLPCWSTRinリソースの言語を指定するロケール名(Unicode)。
pPrintTicketIStream*inoptional基準とする印刷チケットを保持するIStream。NULL可。
pDeviceResourcesIStream*in取得したPrintDeviceResources(XML)を受け取るIStream。
pbstrErrorMessageLPWSTR*outoptionalエラー時の説明文字列(BSTR)を受け取るポインタ。NULL可。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT PTGetPrintDeviceResources(
    HPTPROVIDER hProvider,
    LPCWSTR pszLocaleName,
    IStream* pPrintTicket,   // optional
    IStream* pDeviceResources,
    LPWSTR* pbstrErrorMessage   // optional
);
[DllImport("prntvpt.dll", ExactSpelling = true)]
static extern int PTGetPrintDeviceResources(
    IntPtr hProvider,   // HPTPROVIDER
    [MarshalAs(UnmanagedType.LPWStr)] string pszLocaleName,   // LPCWSTR
    IntPtr pPrintTicket,   // IStream* optional
    IntPtr pDeviceResources,   // IStream*
    IntPtr pbstrErrorMessage   // LPWSTR* optional, out
);
<DllImport("prntvpt.dll", ExactSpelling:=True)>
Public Shared Function PTGetPrintDeviceResources(
    hProvider As IntPtr,   ' HPTPROVIDER
    <MarshalAs(UnmanagedType.LPWStr)> pszLocaleName As String,   ' LPCWSTR
    pPrintTicket As IntPtr,   ' IStream* optional
    pDeviceResources As IntPtr,   ' IStream*
    pbstrErrorMessage As IntPtr   ' LPWSTR* optional, out
) As Integer
End Function
' hProvider : HPTPROVIDER
' pszLocaleName : LPCWSTR
' pPrintTicket : IStream* optional
' pDeviceResources : IStream*
' pbstrErrorMessage : LPWSTR* optional, out
Declare PtrSafe Function PTGetPrintDeviceResources Lib "prntvpt" ( _
    ByVal hProvider As LongPtr, _
    ByVal pszLocaleName As LongPtr, _
    ByVal pPrintTicket As LongPtr, _
    ByVal pDeviceResources As LongPtr, _
    ByVal pbstrErrorMessage As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PTGetPrintDeviceResources = ctypes.windll.prntvpt.PTGetPrintDeviceResources
PTGetPrintDeviceResources.restype = ctypes.c_int
PTGetPrintDeviceResources.argtypes = [
    wintypes.HANDLE,  # hProvider : HPTPROVIDER
    wintypes.LPCWSTR,  # pszLocaleName : LPCWSTR
    ctypes.c_void_p,  # pPrintTicket : IStream* optional
    ctypes.c_void_p,  # pDeviceResources : IStream*
    ctypes.c_void_p,  # pbstrErrorMessage : LPWSTR* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('prntvpt.dll')
PTGetPrintDeviceResources = Fiddle::Function.new(
  lib['PTGetPrintDeviceResources'],
  [
    Fiddle::TYPE_VOIDP,  # hProvider : HPTPROVIDER
    Fiddle::TYPE_VOIDP,  # pszLocaleName : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pPrintTicket : IStream* optional
    Fiddle::TYPE_VOIDP,  # pDeviceResources : IStream*
    Fiddle::TYPE_VOIDP,  # pbstrErrorMessage : LPWSTR* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "prntvpt")]
extern "system" {
    fn PTGetPrintDeviceResources(
        hProvider: *mut core::ffi::c_void,  // HPTPROVIDER
        pszLocaleName: *const u16,  // LPCWSTR
        pPrintTicket: *mut core::ffi::c_void,  // IStream* optional
        pDeviceResources: *mut core::ffi::c_void,  // IStream*
        pbstrErrorMessage: *mut *mut u16  // LPWSTR* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("prntvpt.dll")]
public static extern int PTGetPrintDeviceResources(IntPtr hProvider, [MarshalAs(UnmanagedType.LPWStr)] string pszLocaleName, IntPtr pPrintTicket, IntPtr pDeviceResources, IntPtr pbstrErrorMessage);
"@
$api = Add-Type -MemberDefinition $sig -Name 'prntvpt_PTGetPrintDeviceResources' -Namespace Win32 -PassThru
# $api::PTGetPrintDeviceResources(hProvider, pszLocaleName, pPrintTicket, pDeviceResources, pbstrErrorMessage)
#uselib "prntvpt.dll"
#func global PTGetPrintDeviceResources "PTGetPrintDeviceResources" sptr, sptr, sptr, sptr, sptr
; PTGetPrintDeviceResources hProvider, pszLocaleName, pPrintTicket, pDeviceResources, varptr(pbstrErrorMessage)   ; 戻り値は stat
; hProvider : HPTPROVIDER -> "sptr"
; pszLocaleName : LPCWSTR -> "sptr"
; pPrintTicket : IStream* optional -> "sptr"
; pDeviceResources : IStream* -> "sptr"
; pbstrErrorMessage : LPWSTR* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "prntvpt.dll"
#cfunc global PTGetPrintDeviceResources "PTGetPrintDeviceResources" sptr, wstr, sptr, sptr, var
; res = PTGetPrintDeviceResources(hProvider, pszLocaleName, pPrintTicket, pDeviceResources, pbstrErrorMessage)
; hProvider : HPTPROVIDER -> "sptr"
; pszLocaleName : LPCWSTR -> "wstr"
; pPrintTicket : IStream* optional -> "sptr"
; pDeviceResources : IStream* -> "sptr"
; pbstrErrorMessage : LPWSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT PTGetPrintDeviceResources(HPTPROVIDER hProvider, LPCWSTR pszLocaleName, IStream* pPrintTicket, IStream* pDeviceResources, LPWSTR* pbstrErrorMessage)
#uselib "prntvpt.dll"
#cfunc global PTGetPrintDeviceResources "PTGetPrintDeviceResources" intptr, wstr, intptr, intptr, var
; res = PTGetPrintDeviceResources(hProvider, pszLocaleName, pPrintTicket, pDeviceResources, pbstrErrorMessage)
; hProvider : HPTPROVIDER -> "intptr"
; pszLocaleName : LPCWSTR -> "wstr"
; pPrintTicket : IStream* optional -> "intptr"
; pDeviceResources : IStream* -> "intptr"
; pbstrErrorMessage : LPWSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	prntvpt = windows.NewLazySystemDLL("prntvpt.dll")
	procPTGetPrintDeviceResources = prntvpt.NewProc("PTGetPrintDeviceResources")
)

// hProvider (HPTPROVIDER), pszLocaleName (LPCWSTR), pPrintTicket (IStream* optional), pDeviceResources (IStream*), pbstrErrorMessage (LPWSTR* optional, out)
r1, _, err := procPTGetPrintDeviceResources.Call(
	uintptr(hProvider),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszLocaleName))),
	uintptr(pPrintTicket),
	uintptr(pDeviceResources),
	uintptr(pbstrErrorMessage),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function PTGetPrintDeviceResources(
  hProvider: THandle;   // HPTPROVIDER
  pszLocaleName: PWideChar;   // LPCWSTR
  pPrintTicket: Pointer;   // IStream* optional
  pDeviceResources: Pointer;   // IStream*
  pbstrErrorMessage: PPWideChar   // LPWSTR* optional, out
): Integer; stdcall;
  external 'prntvpt.dll' name 'PTGetPrintDeviceResources';
result := DllCall("prntvpt\PTGetPrintDeviceResources"
    , "Ptr", hProvider   ; HPTPROVIDER
    , "WStr", pszLocaleName   ; LPCWSTR
    , "Ptr", pPrintTicket   ; IStream* optional
    , "Ptr", pDeviceResources   ; IStream*
    , "Ptr", pbstrErrorMessage   ; LPWSTR* optional, out
    , "Int")   ; return: HRESULT
●PTGetPrintDeviceResources(hProvider, pszLocaleName, pPrintTicket, pDeviceResources, pbstrErrorMessage) = DLL("prntvpt.dll", "int PTGetPrintDeviceResources(void*, char*, void*, void*, void*)")
# 呼び出し: PTGetPrintDeviceResources(hProvider, pszLocaleName, pPrintTicket, pDeviceResources, pbstrErrorMessage)
# hProvider : HPTPROVIDER -> "void*"
# pszLocaleName : LPCWSTR -> "char*"
# pPrintTicket : IStream* optional -> "void*"
# pDeviceResources : IStream* -> "void*"
# pbstrErrorMessage : LPWSTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef PTGetPrintDeviceResourcesNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Pointer<Utf16>>);
typedef PTGetPrintDeviceResourcesDart = int Function(Pointer<Void>, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Pointer<Utf16>>);
final PTGetPrintDeviceResources = DynamicLibrary.open('prntvpt.dll')
    .lookupFunction<PTGetPrintDeviceResourcesNative, PTGetPrintDeviceResourcesDart>('PTGetPrintDeviceResources');
// hProvider : HPTPROVIDER -> Pointer<Void>
// pszLocaleName : LPCWSTR -> Pointer<Utf16>
// pPrintTicket : IStream* optional -> Pointer<Void>
// pDeviceResources : IStream* -> Pointer<Void>
// pbstrErrorMessage : LPWSTR* optional, out -> Pointer<Pointer<Utf16>>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PTGetPrintDeviceResources(
  hProvider: THandle;   // HPTPROVIDER
  pszLocaleName: PWideChar;   // LPCWSTR
  pPrintTicket: Pointer;   // IStream* optional
  pDeviceResources: Pointer;   // IStream*
  pbstrErrorMessage: PPWideChar   // LPWSTR* optional, out
): Integer; stdcall;
  external 'prntvpt.dll' name 'PTGetPrintDeviceResources';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PTGetPrintDeviceResources"
  c_PTGetPrintDeviceResources :: Ptr () -> CWString -> Ptr () -> Ptr () -> Ptr CWString -> IO Int32
-- hProvider : HPTPROVIDER -> Ptr ()
-- pszLocaleName : LPCWSTR -> CWString
-- pPrintTicket : IStream* optional -> Ptr ()
-- pDeviceResources : IStream* -> Ptr ()
-- pbstrErrorMessage : LPWSTR* optional, out -> Ptr CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ptgetprintdeviceresources =
  foreign "PTGetPrintDeviceResources"
    ((ptr void) @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> (ptr (ptr uint16_t)) @-> returning int32_t)
(* hProvider : HPTPROVIDER -> (ptr void) *)
(* pszLocaleName : LPCWSTR -> (ptr uint16_t) *)
(* pPrintTicket : IStream* optional -> (ptr void) *)
(* pDeviceResources : IStream* -> (ptr void) *)
(* pbstrErrorMessage : LPWSTR* optional, out -> (ptr (ptr uint16_t)) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library prntvpt (t "prntvpt.dll"))
(cffi:use-foreign-library prntvpt)

(cffi:defcfun ("PTGetPrintDeviceResources" ptget-print-device-resources :convention :stdcall) :int32
  (h-provider :pointer)   ; HPTPROVIDER
  (psz-locale-name (:string :encoding :utf-16le))   ; LPCWSTR
  (p-print-ticket :pointer)   ; IStream* optional
  (p-device-resources :pointer)   ; IStream*
  (pbstr-error-message :pointer))   ; LPWSTR* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PTGetPrintDeviceResources = Win32::API::More->new('prntvpt',
    'int PTGetPrintDeviceResources(HANDLE hProvider, LPCWSTR pszLocaleName, LPVOID pPrintTicket, LPVOID pDeviceResources, LPVOID pbstrErrorMessage)');
# my $ret = $PTGetPrintDeviceResources->Call($hProvider, $pszLocaleName, $pPrintTicket, $pDeviceResources, $pbstrErrorMessage);
# hProvider : HPTPROVIDER -> HANDLE
# pszLocaleName : LPCWSTR -> LPCWSTR
# pPrintTicket : IStream* optional -> LPVOID
# pDeviceResources : IStream* -> LPVOID
# pbstrErrorMessage : LPWSTR* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型