ホーム › Graphics.Printing › UploadPrinterDriverPackageW
UploadPrinterDriverPackageW
関数プリンタードライバーパッケージをサーバーへアップロードする。
シグネチャ
// winspool.drv (Unicode / -W)
#include <windows.h>
HRESULT UploadPrinterDriverPackageW(
LPCWSTR pszServer, // optional
LPCWSTR pszInfPath,
LPCWSTR pszEnvironment, // optional
DWORD dwFlags,
HWND hwnd,
LPWSTR pszDestInfPath,
DWORD* pcchDestInfPath
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszServer | LPCWSTR | inoptional | ドライバパッケージをアップロードする対象サーバー名(Unicode)。NULLでローカル。 |
| pszInfPath | LPCWSTR | in | アップロードするドライバパッケージのINFファイルへのパス(Unicode)。 |
| pszEnvironment | LPCWSTR | inoptional | 対象アーキテクチャ環境名(Unicode)。NULLで現在の環境を使用する。 |
| dwFlags | DWORD | in | アップロード動作を制御するフラグ。UPDP_SILENT_UPLOAD等を指定する。 |
| hwnd | HWND | in | UI表示の親となるウィンドウハンドル。サイレント時はNULL可。 |
| pszDestInfPath | LPWSTR | out | アップロード先のINFパスを受け取る出力バッファ(Unicode)。 |
| pcchDestInfPath | DWORD* | inout | pszDestInfPathバッファのサイズ(文字数)を入出力するポインタ。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// winspool.drv (Unicode / -W)
#include <windows.h>
HRESULT UploadPrinterDriverPackageW(
LPCWSTR pszServer, // optional
LPCWSTR pszInfPath,
LPCWSTR pszEnvironment, // optional
DWORD dwFlags,
HWND hwnd,
LPWSTR pszDestInfPath,
DWORD* pcchDestInfPath
);[DllImport("winspool.drv", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int UploadPrinterDriverPackageW(
[MarshalAs(UnmanagedType.LPWStr)] string pszServer, // LPCWSTR optional
[MarshalAs(UnmanagedType.LPWStr)] string pszInfPath, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string pszEnvironment, // LPCWSTR optional
uint dwFlags, // DWORD
IntPtr hwnd, // HWND
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszDestInfPath, // LPWSTR out
ref uint pcchDestInfPath // DWORD* in/out
);<DllImport("winspool.drv", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function UploadPrinterDriverPackageW(
<MarshalAs(UnmanagedType.LPWStr)> pszServer As String, ' LPCWSTR optional
<MarshalAs(UnmanagedType.LPWStr)> pszInfPath As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> pszEnvironment As String, ' LPCWSTR optional
dwFlags As UInteger, ' DWORD
hwnd As IntPtr, ' HWND
<MarshalAs(UnmanagedType.LPWStr)> pszDestInfPath As System.Text.StringBuilder, ' LPWSTR out
ByRef pcchDestInfPath As UInteger ' DWORD* in/out
) As Integer
End Function' pszServer : LPCWSTR optional
' pszInfPath : LPCWSTR
' pszEnvironment : LPCWSTR optional
' dwFlags : DWORD
' hwnd : HWND
' pszDestInfPath : LPWSTR out
' pcchDestInfPath : DWORD* in/out
Declare PtrSafe Function UploadPrinterDriverPackageW Lib "winspool.drv" ( _
ByVal pszServer As LongPtr, _
ByVal pszInfPath As LongPtr, _
ByVal pszEnvironment As LongPtr, _
ByVal dwFlags As Long, _
ByVal hwnd As LongPtr, _
ByVal pszDestInfPath As LongPtr, _
ByRef pcchDestInfPath As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
UploadPrinterDriverPackageW = ctypes.windll.LoadLibrary("winspool.drv").UploadPrinterDriverPackageW
UploadPrinterDriverPackageW.restype = ctypes.c_int
UploadPrinterDriverPackageW.argtypes = [
wintypes.LPCWSTR, # pszServer : LPCWSTR optional
wintypes.LPCWSTR, # pszInfPath : LPCWSTR
wintypes.LPCWSTR, # pszEnvironment : LPCWSTR optional
wintypes.DWORD, # dwFlags : DWORD
wintypes.HANDLE, # hwnd : HWND
wintypes.LPWSTR, # pszDestInfPath : LPWSTR out
ctypes.POINTER(wintypes.DWORD), # pcchDestInfPath : DWORD* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('winspool.drv')
UploadPrinterDriverPackageW = Fiddle::Function.new(
lib['UploadPrinterDriverPackageW'],
[
Fiddle::TYPE_VOIDP, # pszServer : LPCWSTR optional
Fiddle::TYPE_VOIDP, # pszInfPath : LPCWSTR
Fiddle::TYPE_VOIDP, # pszEnvironment : LPCWSTR optional
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # hwnd : HWND
Fiddle::TYPE_VOIDP, # pszDestInfPath : LPWSTR out
Fiddle::TYPE_VOIDP, # pcchDestInfPath : DWORD* in/out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "winspool.drv")]
extern "system" {
fn UploadPrinterDriverPackageW(
pszServer: *const u16, // LPCWSTR optional
pszInfPath: *const u16, // LPCWSTR
pszEnvironment: *const u16, // LPCWSTR optional
dwFlags: u32, // DWORD
hwnd: *mut core::ffi::c_void, // HWND
pszDestInfPath: *mut u16, // LPWSTR out
pcchDestInfPath: *mut u32 // DWORD* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("winspool.drv", CharSet = CharSet.Unicode)]
public static extern int UploadPrinterDriverPackageW([MarshalAs(UnmanagedType.LPWStr)] string pszServer, [MarshalAs(UnmanagedType.LPWStr)] string pszInfPath, [MarshalAs(UnmanagedType.LPWStr)] string pszEnvironment, uint dwFlags, IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszDestInfPath, ref uint pcchDestInfPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winspool.drv_UploadPrinterDriverPackageW' -Namespace Win32 -PassThru
# $api::UploadPrinterDriverPackageW(pszServer, pszInfPath, pszEnvironment, dwFlags, hwnd, pszDestInfPath, pcchDestInfPath)#uselib "winspool.drv"
#func global UploadPrinterDriverPackageW "UploadPrinterDriverPackageW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; UploadPrinterDriverPackageW pszServer, pszInfPath, pszEnvironment, dwFlags, hwnd, varptr(pszDestInfPath), varptr(pcchDestInfPath) ; 戻り値は stat
; pszServer : LPCWSTR optional -> "wptr"
; pszInfPath : LPCWSTR -> "wptr"
; pszEnvironment : LPCWSTR optional -> "wptr"
; dwFlags : DWORD -> "wptr"
; hwnd : HWND -> "wptr"
; pszDestInfPath : LPWSTR out -> "wptr"
; pcchDestInfPath : DWORD* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "winspool.drv" #cfunc global UploadPrinterDriverPackageW "UploadPrinterDriverPackageW" wstr, wstr, wstr, int, sptr, var, var ; res = UploadPrinterDriverPackageW(pszServer, pszInfPath, pszEnvironment, dwFlags, hwnd, pszDestInfPath, pcchDestInfPath) ; pszServer : LPCWSTR optional -> "wstr" ; pszInfPath : LPCWSTR -> "wstr" ; pszEnvironment : LPCWSTR optional -> "wstr" ; dwFlags : DWORD -> "int" ; hwnd : HWND -> "sptr" ; pszDestInfPath : LPWSTR out -> "var" ; pcchDestInfPath : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "winspool.drv" #cfunc global UploadPrinterDriverPackageW "UploadPrinterDriverPackageW" wstr, wstr, wstr, int, sptr, sptr, sptr ; res = UploadPrinterDriverPackageW(pszServer, pszInfPath, pszEnvironment, dwFlags, hwnd, varptr(pszDestInfPath), varptr(pcchDestInfPath)) ; pszServer : LPCWSTR optional -> "wstr" ; pszInfPath : LPCWSTR -> "wstr" ; pszEnvironment : LPCWSTR optional -> "wstr" ; dwFlags : DWORD -> "int" ; hwnd : HWND -> "sptr" ; pszDestInfPath : LPWSTR out -> "sptr" ; pcchDestInfPath : DWORD* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT UploadPrinterDriverPackageW(LPCWSTR pszServer, LPCWSTR pszInfPath, LPCWSTR pszEnvironment, DWORD dwFlags, HWND hwnd, LPWSTR pszDestInfPath, DWORD* pcchDestInfPath) #uselib "winspool.drv" #cfunc global UploadPrinterDriverPackageW "UploadPrinterDriverPackageW" wstr, wstr, wstr, int, intptr, var, var ; res = UploadPrinterDriverPackageW(pszServer, pszInfPath, pszEnvironment, dwFlags, hwnd, pszDestInfPath, pcchDestInfPath) ; pszServer : LPCWSTR optional -> "wstr" ; pszInfPath : LPCWSTR -> "wstr" ; pszEnvironment : LPCWSTR optional -> "wstr" ; dwFlags : DWORD -> "int" ; hwnd : HWND -> "intptr" ; pszDestInfPath : LPWSTR out -> "var" ; pcchDestInfPath : DWORD* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT UploadPrinterDriverPackageW(LPCWSTR pszServer, LPCWSTR pszInfPath, LPCWSTR pszEnvironment, DWORD dwFlags, HWND hwnd, LPWSTR pszDestInfPath, DWORD* pcchDestInfPath) #uselib "winspool.drv" #cfunc global UploadPrinterDriverPackageW "UploadPrinterDriverPackageW" wstr, wstr, wstr, int, intptr, intptr, intptr ; res = UploadPrinterDriverPackageW(pszServer, pszInfPath, pszEnvironment, dwFlags, hwnd, varptr(pszDestInfPath), varptr(pcchDestInfPath)) ; pszServer : LPCWSTR optional -> "wstr" ; pszInfPath : LPCWSTR -> "wstr" ; pszEnvironment : LPCWSTR optional -> "wstr" ; dwFlags : DWORD -> "int" ; hwnd : HWND -> "intptr" ; pszDestInfPath : LPWSTR out -> "intptr" ; pcchDestInfPath : DWORD* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winspool_drv = windows.NewLazySystemDLL("winspool.drv")
procUploadPrinterDriverPackageW = winspool_drv.NewProc("UploadPrinterDriverPackageW")
)
// pszServer (LPCWSTR optional), pszInfPath (LPCWSTR), pszEnvironment (LPCWSTR optional), dwFlags (DWORD), hwnd (HWND), pszDestInfPath (LPWSTR out), pcchDestInfPath (DWORD* in/out)
r1, _, err := procUploadPrinterDriverPackageW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszServer))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszInfPath))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszEnvironment))),
uintptr(dwFlags),
uintptr(hwnd),
uintptr(pszDestInfPath),
uintptr(pcchDestInfPath),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction UploadPrinterDriverPackageW(
pszServer: PWideChar; // LPCWSTR optional
pszInfPath: PWideChar; // LPCWSTR
pszEnvironment: PWideChar; // LPCWSTR optional
dwFlags: DWORD; // DWORD
hwnd: THandle; // HWND
pszDestInfPath: PWideChar; // LPWSTR out
pcchDestInfPath: Pointer // DWORD* in/out
): Integer; stdcall;
external 'winspool.drv' name 'UploadPrinterDriverPackageW';result := DllCall("winspool.drv\UploadPrinterDriverPackageW"
, "WStr", pszServer ; LPCWSTR optional
, "WStr", pszInfPath ; LPCWSTR
, "WStr", pszEnvironment ; LPCWSTR optional
, "UInt", dwFlags ; DWORD
, "Ptr", hwnd ; HWND
, "Ptr", pszDestInfPath ; LPWSTR out
, "Ptr", pcchDestInfPath ; DWORD* in/out
, "Int") ; return: HRESULT●UploadPrinterDriverPackageW(pszServer, pszInfPath, pszEnvironment, dwFlags, hwnd, pszDestInfPath, pcchDestInfPath) = DLL("winspool.drv", "int UploadPrinterDriverPackageW(char*, char*, char*, dword, void*, char*, void*)")
# 呼び出し: UploadPrinterDriverPackageW(pszServer, pszInfPath, pszEnvironment, dwFlags, hwnd, pszDestInfPath, pcchDestInfPath)
# pszServer : LPCWSTR optional -> "char*"
# pszInfPath : LPCWSTR -> "char*"
# pszEnvironment : LPCWSTR optional -> "char*"
# dwFlags : DWORD -> "dword"
# hwnd : HWND -> "void*"
# pszDestInfPath : LPWSTR out -> "char*"
# pcchDestInfPath : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "winspool.drv" fn UploadPrinterDriverPackageW(
pszServer: [*c]const u16, // LPCWSTR optional
pszInfPath: [*c]const u16, // LPCWSTR
pszEnvironment: [*c]const u16, // LPCWSTR optional
dwFlags: u32, // DWORD
hwnd: ?*anyopaque, // HWND
pszDestInfPath: [*c]u16, // LPWSTR out
pcchDestInfPath: [*c]u32 // DWORD* in/out
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc UploadPrinterDriverPackageW(
pszServer: WideCString, # LPCWSTR optional
pszInfPath: WideCString, # LPCWSTR
pszEnvironment: WideCString, # LPCWSTR optional
dwFlags: uint32, # DWORD
hwnd: pointer, # HWND
pszDestInfPath: ptr uint16, # LPWSTR out
pcchDestInfPath: ptr uint32 # DWORD* in/out
): int32 {.importc: "UploadPrinterDriverPackageW", stdcall, dynlib: "winspool.drv".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "winspool.drv");
extern(Windows)
int UploadPrinterDriverPackageW(
const(wchar)* pszServer, // LPCWSTR optional
const(wchar)* pszInfPath, // LPCWSTR
const(wchar)* pszEnvironment, // LPCWSTR optional
uint dwFlags, // DWORD
void* hwnd, // HWND
wchar* pszDestInfPath, // LPWSTR out
uint* pcchDestInfPath // DWORD* in/out
);ccall((:UploadPrinterDriverPackageW, "winspool.drv"), stdcall, Int32,
(Cwstring, Cwstring, Cwstring, UInt32, Ptr{Cvoid}, Ptr{UInt16}, Ptr{UInt32}),
pszServer, pszInfPath, pszEnvironment, dwFlags, hwnd, pszDestInfPath, pcchDestInfPath)
# pszServer : LPCWSTR optional -> Cwstring
# pszInfPath : LPCWSTR -> Cwstring
# pszEnvironment : LPCWSTR optional -> Cwstring
# dwFlags : DWORD -> UInt32
# hwnd : HWND -> Ptr{Cvoid}
# pszDestInfPath : LPWSTR out -> Ptr{UInt16}
# pcchDestInfPath : DWORD* in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t UploadPrinterDriverPackageW(
const uint16_t* pszServer,
const uint16_t* pszInfPath,
const uint16_t* pszEnvironment,
uint32_t dwFlags,
void* hwnd,
uint16_t* pszDestInfPath,
uint32_t* pcchDestInfPath);
]]
local winspool.drv = ffi.load("winspool.drv")
-- winspool.drv.UploadPrinterDriverPackageW(pszServer, pszInfPath, pszEnvironment, dwFlags, hwnd, pszDestInfPath, pcchDestInfPath)
-- pszServer : LPCWSTR optional
-- pszInfPath : LPCWSTR
-- pszEnvironment : LPCWSTR optional
-- dwFlags : DWORD
-- hwnd : HWND
-- pszDestInfPath : LPWSTR out
-- pcchDestInfPath : DWORD* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('winspool.drv');
const UploadPrinterDriverPackageW = lib.func('__stdcall', 'UploadPrinterDriverPackageW', 'int32_t', ['str16', 'str16', 'str16', 'uint32_t', 'void *', 'uint16_t *', 'uint32_t *']);
// UploadPrinterDriverPackageW(pszServer, pszInfPath, pszEnvironment, dwFlags, hwnd, pszDestInfPath, pcchDestInfPath)
// pszServer : LPCWSTR optional -> 'str16'
// pszInfPath : LPCWSTR -> 'str16'
// pszEnvironment : LPCWSTR optional -> 'str16'
// dwFlags : DWORD -> 'uint32_t'
// hwnd : HWND -> 'void *'
// pszDestInfPath : LPWSTR out -> 'uint16_t *'
// pcchDestInfPath : DWORD* in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("winspool.drv", {
UploadPrinterDriverPackageW: { parameters: ["buffer", "buffer", "buffer", "u32", "pointer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.UploadPrinterDriverPackageW(pszServer, pszInfPath, pszEnvironment, dwFlags, hwnd, pszDestInfPath, pcchDestInfPath)
// pszServer : LPCWSTR optional -> "buffer"
// pszInfPath : LPCWSTR -> "buffer"
// pszEnvironment : LPCWSTR optional -> "buffer"
// dwFlags : DWORD -> "u32"
// hwnd : HWND -> "pointer"
// pszDestInfPath : LPWSTR out -> "buffer"
// pcchDestInfPath : DWORD* in/out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t UploadPrinterDriverPackageW(
const uint16_t* pszServer,
const uint16_t* pszInfPath,
const uint16_t* pszEnvironment,
uint32_t dwFlags,
void* hwnd,
uint16_t* pszDestInfPath,
uint32_t* pcchDestInfPath);
C, "winspool.drv");
// $ffi->UploadPrinterDriverPackageW(pszServer, pszInfPath, pszEnvironment, dwFlags, hwnd, pszDestInfPath, pcchDestInfPath);
// pszServer : LPCWSTR optional
// pszInfPath : LPCWSTR
// pszEnvironment : LPCWSTR optional
// dwFlags : DWORD
// hwnd : HWND
// pszDestInfPath : LPWSTR out
// pcchDestInfPath : DWORD* in/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 Winspool.drv extends StdCallLibrary {
Winspool.drv INSTANCE = Native.load("winspool.drv", Winspool.drv.class, W32APIOptions.UNICODE_OPTIONS);
int UploadPrinterDriverPackageW(
WString pszServer, // LPCWSTR optional
WString pszInfPath, // LPCWSTR
WString pszEnvironment, // LPCWSTR optional
int dwFlags, // DWORD
Pointer hwnd, // HWND
char[] pszDestInfPath, // LPWSTR out
IntByReference pcchDestInfPath // DWORD* in/out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("winspool.drv")]
lib Libwinspool.drv
fun UploadPrinterDriverPackageW = UploadPrinterDriverPackageW(
pszServer : UInt16*, # LPCWSTR optional
pszInfPath : UInt16*, # LPCWSTR
pszEnvironment : UInt16*, # LPCWSTR optional
dwFlags : UInt32, # DWORD
hwnd : Void*, # HWND
pszDestInfPath : UInt16*, # LPWSTR out
pcchDestInfPath : UInt32* # DWORD* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef UploadPrinterDriverPackageWNative = Int32 Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, Uint32, Pointer<Void>, Pointer<Utf16>, Pointer<Uint32>);
typedef UploadPrinterDriverPackageWDart = int Function(Pointer<Utf16>, Pointer<Utf16>, Pointer<Utf16>, int, Pointer<Void>, Pointer<Utf16>, Pointer<Uint32>);
final UploadPrinterDriverPackageW = DynamicLibrary.open('winspool.drv')
.lookupFunction<UploadPrinterDriverPackageWNative, UploadPrinterDriverPackageWDart>('UploadPrinterDriverPackageW');
// pszServer : LPCWSTR optional -> Pointer<Utf16>
// pszInfPath : LPCWSTR -> Pointer<Utf16>
// pszEnvironment : LPCWSTR optional -> Pointer<Utf16>
// dwFlags : DWORD -> Uint32
// hwnd : HWND -> Pointer<Void>
// pszDestInfPath : LPWSTR out -> Pointer<Utf16>
// pcchDestInfPath : DWORD* in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function UploadPrinterDriverPackageW(
pszServer: PWideChar; // LPCWSTR optional
pszInfPath: PWideChar; // LPCWSTR
pszEnvironment: PWideChar; // LPCWSTR optional
dwFlags: DWORD; // DWORD
hwnd: THandle; // HWND
pszDestInfPath: PWideChar; // LPWSTR out
pcchDestInfPath: Pointer // DWORD* in/out
): Integer; stdcall;
external 'winspool.drv' name 'UploadPrinterDriverPackageW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "UploadPrinterDriverPackageW"
c_UploadPrinterDriverPackageW :: CWString -> CWString -> CWString -> Word32 -> Ptr () -> CWString -> Ptr Word32 -> IO Int32
-- pszServer : LPCWSTR optional -> CWString
-- pszInfPath : LPCWSTR -> CWString
-- pszEnvironment : LPCWSTR optional -> CWString
-- dwFlags : DWORD -> Word32
-- hwnd : HWND -> Ptr ()
-- pszDestInfPath : LPWSTR out -> CWString
-- pcchDestInfPath : DWORD* in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let uploadprinterdriverpackagew =
foreign "UploadPrinterDriverPackageW"
((ptr uint16_t) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> (ptr void) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning int32_t)
(* pszServer : LPCWSTR optional -> (ptr uint16_t) *)
(* pszInfPath : LPCWSTR -> (ptr uint16_t) *)
(* pszEnvironment : LPCWSTR optional -> (ptr uint16_t) *)
(* dwFlags : DWORD -> uint32_t *)
(* hwnd : HWND -> (ptr void) *)
(* pszDestInfPath : LPWSTR out -> (ptr uint16_t) *)
(* pcchDestInfPath : DWORD* in/out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library winspool.drv (t "winspool.drv"))
(cffi:use-foreign-library winspool.drv)
(cffi:defcfun ("UploadPrinterDriverPackageW" upload-printer-driver-package-w :convention :stdcall) :int32
(psz-server (:string :encoding :utf-16le)) ; LPCWSTR optional
(psz-inf-path (:string :encoding :utf-16le)) ; LPCWSTR
(psz-environment (:string :encoding :utf-16le)) ; LPCWSTR optional
(dw-flags :uint32) ; DWORD
(hwnd :pointer) ; HWND
(psz-dest-inf-path :pointer) ; LPWSTR out
(pcch-dest-inf-path :pointer)) ; DWORD* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $UploadPrinterDriverPackageW = Win32::API::More->new('winspool.drv',
'int UploadPrinterDriverPackageW(LPCWSTR pszServer, LPCWSTR pszInfPath, LPCWSTR pszEnvironment, DWORD dwFlags, HANDLE hwnd, LPWSTR pszDestInfPath, LPVOID pcchDestInfPath)');
# my $ret = $UploadPrinterDriverPackageW->Call($pszServer, $pszInfPath, $pszEnvironment, $dwFlags, $hwnd, $pszDestInfPath, $pcchDestInfPath);
# pszServer : LPCWSTR optional -> LPCWSTR
# pszInfPath : LPCWSTR -> LPCWSTR
# pszEnvironment : LPCWSTR optional -> LPCWSTR
# dwFlags : DWORD -> DWORD
# hwnd : HWND -> HANDLE
# pszDestInfPath : LPWSTR out -> LPWSTR
# pcchDestInfPath : DWORD* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f UploadPrinterDriverPackageA (ANSI版) — プリンタードライバーパッケージをサーバーへアップロードする。