ホーム › Graphics.Printing › AddPrinterConnection2A
AddPrinterConnection2A
関数詳細情報を指定してプリンター接続を追加する。
シグネチャ
// winspool.drv (ANSI / -A)
#include <windows.h>
BOOL AddPrinterConnection2A(
HWND hWnd, // optional
LPCSTR pszName,
DWORD dwLevel,
void* pConnectionInfo
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hWnd | HWND | inoptional |
| pszName | LPCSTR | in |
| dwLevel | DWORD | in |
| pConnectionInfo | void* | in |
戻り値の型: BOOL
各言語での呼び出し定義
// winspool.drv (ANSI / -A)
#include <windows.h>
BOOL AddPrinterConnection2A(
HWND hWnd, // optional
LPCSTR pszName,
DWORD dwLevel,
void* pConnectionInfo
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("winspool.drv", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool AddPrinterConnection2A(
IntPtr hWnd, // HWND optional
[MarshalAs(UnmanagedType.LPStr)] string pszName, // LPCSTR
uint dwLevel, // DWORD
IntPtr pConnectionInfo // void*
);<DllImport("winspool.drv", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function AddPrinterConnection2A(
hWnd As IntPtr, ' HWND optional
<MarshalAs(UnmanagedType.LPStr)> pszName As String, ' LPCSTR
dwLevel As UInteger, ' DWORD
pConnectionInfo As IntPtr ' void*
) As Boolean
End Function' hWnd : HWND optional
' pszName : LPCSTR
' dwLevel : DWORD
' pConnectionInfo : void*
Declare PtrSafe Function AddPrinterConnection2A Lib "winspool.drv" ( _
ByVal hWnd As LongPtr, _
ByVal pszName As String, _
ByVal dwLevel As Long, _
ByVal pConnectionInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
AddPrinterConnection2A = ctypes.windll.LoadLibrary("winspool.drv").AddPrinterConnection2A
AddPrinterConnection2A.restype = wintypes.BOOL
AddPrinterConnection2A.argtypes = [
wintypes.HANDLE, # hWnd : HWND optional
wintypes.LPCSTR, # pszName : LPCSTR
wintypes.DWORD, # dwLevel : DWORD
ctypes.POINTER(None), # pConnectionInfo : void*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('winspool.drv')
AddPrinterConnection2A = Fiddle::Function.new(
lib['AddPrinterConnection2A'],
[
Fiddle::TYPE_VOIDP, # hWnd : HWND optional
Fiddle::TYPE_VOIDP, # pszName : LPCSTR
-Fiddle::TYPE_INT, # dwLevel : DWORD
Fiddle::TYPE_VOIDP, # pConnectionInfo : void*
],
Fiddle::TYPE_INT)#[link(name = "winspool.drv")]
extern "system" {
fn AddPrinterConnection2A(
hWnd: *mut core::ffi::c_void, // HWND optional
pszName: *const u8, // LPCSTR
dwLevel: u32, // DWORD
pConnectionInfo: *mut () // void*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("winspool.drv", CharSet = CharSet.Ansi)]
public static extern bool AddPrinterConnection2A(IntPtr hWnd, [MarshalAs(UnmanagedType.LPStr)] string pszName, uint dwLevel, IntPtr pConnectionInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winspool.drv_AddPrinterConnection2A' -Namespace Win32 -PassThru
# $api::AddPrinterConnection2A(hWnd, pszName, dwLevel, pConnectionInfo)#uselib "winspool.drv"
#func global AddPrinterConnection2A "AddPrinterConnection2A" sptr, sptr, sptr, sptr
; AddPrinterConnection2A hWnd, pszName, dwLevel, pConnectionInfo ; 戻り値は stat
; hWnd : HWND optional -> "sptr"
; pszName : LPCSTR -> "sptr"
; dwLevel : DWORD -> "sptr"
; pConnectionInfo : void* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "winspool.drv"
#cfunc global AddPrinterConnection2A "AddPrinterConnection2A" sptr, str, int, sptr
; res = AddPrinterConnection2A(hWnd, pszName, dwLevel, pConnectionInfo)
; hWnd : HWND optional -> "sptr"
; pszName : LPCSTR -> "str"
; dwLevel : DWORD -> "int"
; pConnectionInfo : void* -> "sptr"; BOOL AddPrinterConnection2A(HWND hWnd, LPCSTR pszName, DWORD dwLevel, void* pConnectionInfo)
#uselib "winspool.drv"
#cfunc global AddPrinterConnection2A "AddPrinterConnection2A" intptr, str, int, intptr
; res = AddPrinterConnection2A(hWnd, pszName, dwLevel, pConnectionInfo)
; hWnd : HWND optional -> "intptr"
; pszName : LPCSTR -> "str"
; dwLevel : DWORD -> "int"
; pConnectionInfo : void* -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
winspool_drv = windows.NewLazySystemDLL("winspool.drv")
procAddPrinterConnection2A = winspool_drv.NewProc("AddPrinterConnection2A")
)
// hWnd (HWND optional), pszName (LPCSTR), dwLevel (DWORD), pConnectionInfo (void*)
r1, _, err := procAddPrinterConnection2A.Call(
uintptr(hWnd),
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszName))),
uintptr(dwLevel),
uintptr(pConnectionInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction AddPrinterConnection2A(
hWnd: THandle; // HWND optional
pszName: PAnsiChar; // LPCSTR
dwLevel: DWORD; // DWORD
pConnectionInfo: Pointer // void*
): BOOL; stdcall;
external 'winspool.drv' name 'AddPrinterConnection2A';result := DllCall("winspool.drv\AddPrinterConnection2A"
, "Ptr", hWnd ; HWND optional
, "AStr", pszName ; LPCSTR
, "UInt", dwLevel ; DWORD
, "Ptr", pConnectionInfo ; void*
, "Int") ; return: BOOL●AddPrinterConnection2A(hWnd, pszName, dwLevel, pConnectionInfo) = DLL("winspool.drv", "bool AddPrinterConnection2A(void*, char*, dword, void*)")
# 呼び出し: AddPrinterConnection2A(hWnd, pszName, dwLevel, pConnectionInfo)
# hWnd : HWND optional -> "void*"
# pszName : LPCSTR -> "char*"
# dwLevel : DWORD -> "dword"
# pConnectionInfo : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。