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

DeletePrinterConnectionA

関数
ネットワークプリンターへの接続を削除する。
DLLwinspool.drv文字セットANSI (-A)呼出規約winapi

シグネチャ

// winspool.drv  (ANSI / -A)
#include <windows.h>

BOOL DeletePrinterConnectionA(
    LPSTR pName
);

パラメーター

名前方向
pNameLPSTRin

戻り値の型: BOOL

各言語での呼び出し定義

// winspool.drv  (ANSI / -A)
#include <windows.h>

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

DeletePrinterConnectionA = ctypes.windll.LoadLibrary("winspool.drv").DeletePrinterConnectionA
DeletePrinterConnectionA.restype = wintypes.BOOL
DeletePrinterConnectionA.argtypes = [
    wintypes.LPCSTR,  # pName : LPSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('winspool.drv')
DeletePrinterConnectionA = Fiddle::Function.new(
  lib['DeletePrinterConnectionA'],
  [
    Fiddle::TYPE_VOIDP,  # pName : LPSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "winspool.drv")]
extern "system" {
    fn DeletePrinterConnectionA(
        pName: *mut u8  // LPSTR
    ) -> 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 DeletePrinterConnectionA([MarshalAs(UnmanagedType.LPStr)] string pName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'winspool.drv_DeletePrinterConnectionA' -Namespace Win32 -PassThru
# $api::DeletePrinterConnectionA(pName)
#uselib "winspool.drv"
#func global DeletePrinterConnectionA "DeletePrinterConnectionA" sptr
; DeletePrinterConnectionA pName   ; 戻り値は stat
; pName : LPSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "winspool.drv"
#cfunc global DeletePrinterConnectionA "DeletePrinterConnectionA" str
; res = DeletePrinterConnectionA(pName)
; pName : LPSTR -> "str"
; BOOL DeletePrinterConnectionA(LPSTR pName)
#uselib "winspool.drv"
#cfunc global DeletePrinterConnectionA "DeletePrinterConnectionA" str
; res = DeletePrinterConnectionA(pName)
; pName : LPSTR -> "str"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winspool_drv = windows.NewLazySystemDLL("winspool.drv")
	procDeletePrinterConnectionA = winspool_drv.NewProc("DeletePrinterConnectionA")
)

// pName (LPSTR)
r1, _, err := procDeletePrinterConnectionA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pName))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function DeletePrinterConnectionA(
  pName: PAnsiChar   // LPSTR
): BOOL; stdcall;
  external 'winspool.drv' name 'DeletePrinterConnectionA';
result := DllCall("winspool.drv\DeletePrinterConnectionA"
    , "AStr", pName   ; LPSTR
    , "Int")   ; return: BOOL
●DeletePrinterConnectionA(pName) = DLL("winspool.drv", "bool DeletePrinterConnectionA(char*)")
# 呼び出し: DeletePrinterConnectionA(pName)
# pName : LPSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。