ホーム › 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 |
| pszInfPath | LPCWSTR | in |
| pszEnvironment | LPCWSTR | inoptional |
| dwFlags | DWORD | in |
| hwnd | HWND | in |
| pszDestInfPath | LPWSTR | out |
| pcchDestInfPath | DWORD* | inout |
戻り値の型: 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 版の利用を推奨。