Win32 API 日本語リファレンス
ホームDevices.DeviceAndDriverInstallation › SetupUninstallOEMInfW

SetupUninstallOEMInfW

関数
インストール済みのOEM製INFファイルをアンインストールする(Unicode)。
DLLSETUPAPI.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows XP 以降

シグネチャ

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

BOOL SetupUninstallOEMInfW(
    LPCWSTR InfFileName,
    DWORD Flags,
    void* Reserved   // optional
);

パラメーター

名前方向
InfFileNameLPCWSTRin
FlagsDWORDin
Reservedvoid*optional

戻り値の型: BOOL

各言語での呼び出し定義

// SETUPAPI.dll  (Unicode / -W)
#include <windows.h>

BOOL SetupUninstallOEMInfW(
    LPCWSTR InfFileName,
    DWORD Flags,
    void* Reserved   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool SetupUninstallOEMInfW(
    [MarshalAs(UnmanagedType.LPWStr)] string InfFileName,   // LPCWSTR
    uint Flags,   // DWORD
    IntPtr Reserved   // void* optional
);
<DllImport("SETUPAPI.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function SetupUninstallOEMInfW(
    <MarshalAs(UnmanagedType.LPWStr)> InfFileName As String,   ' LPCWSTR
    Flags As UInteger,   ' DWORD
    Reserved As IntPtr   ' void* optional
) As Boolean
End Function
' InfFileName : LPCWSTR
' Flags : DWORD
' Reserved : void* optional
Declare PtrSafe Function SetupUninstallOEMInfW Lib "setupapi" ( _
    ByVal InfFileName As LongPtr, _
    ByVal Flags As Long, _
    ByVal Reserved As LongPtr) 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

SetupUninstallOEMInfW = ctypes.windll.setupapi.SetupUninstallOEMInfW
SetupUninstallOEMInfW.restype = wintypes.BOOL
SetupUninstallOEMInfW.argtypes = [
    wintypes.LPCWSTR,  # InfFileName : LPCWSTR
    wintypes.DWORD,  # Flags : DWORD
    ctypes.POINTER(None),  # Reserved : void* optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SETUPAPI.dll')
SetupUninstallOEMInfW = Fiddle::Function.new(
  lib['SetupUninstallOEMInfW'],
  [
    Fiddle::TYPE_VOIDP,  # InfFileName : LPCWSTR
    -Fiddle::TYPE_INT,  # Flags : DWORD
    Fiddle::TYPE_VOIDP,  # Reserved : void* optional
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "setupapi")]
extern "system" {
    fn SetupUninstallOEMInfW(
        InfFileName: *const u16,  // LPCWSTR
        Flags: u32,  // DWORD
        Reserved: *mut ()  // void* optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SETUPAPI.dll", CharSet = CharSet.Unicode)]
public static extern bool SetupUninstallOEMInfW([MarshalAs(UnmanagedType.LPWStr)] string InfFileName, uint Flags, IntPtr Reserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SETUPAPI_SetupUninstallOEMInfW' -Namespace Win32 -PassThru
# $api::SetupUninstallOEMInfW(InfFileName, Flags, Reserved)
#uselib "SETUPAPI.dll"
#func global SetupUninstallOEMInfW "SetupUninstallOEMInfW" wptr, wptr, wptr
; SetupUninstallOEMInfW InfFileName, Flags, Reserved   ; 戻り値は stat
; InfFileName : LPCWSTR -> "wptr"
; Flags : DWORD -> "wptr"
; Reserved : void* optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SETUPAPI.dll"
#cfunc global SetupUninstallOEMInfW "SetupUninstallOEMInfW" wstr, int, sptr
; res = SetupUninstallOEMInfW(InfFileName, Flags, Reserved)
; InfFileName : LPCWSTR -> "wstr"
; Flags : DWORD -> "int"
; Reserved : void* optional -> "sptr"
; BOOL SetupUninstallOEMInfW(LPCWSTR InfFileName, DWORD Flags, void* Reserved)
#uselib "SETUPAPI.dll"
#cfunc global SetupUninstallOEMInfW "SetupUninstallOEMInfW" wstr, int, intptr
; res = SetupUninstallOEMInfW(InfFileName, Flags, Reserved)
; InfFileName : LPCWSTR -> "wstr"
; Flags : DWORD -> "int"
; Reserved : void* optional -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	setupapi = windows.NewLazySystemDLL("SETUPAPI.dll")
	procSetupUninstallOEMInfW = setupapi.NewProc("SetupUninstallOEMInfW")
)

// InfFileName (LPCWSTR), Flags (DWORD), Reserved (void* optional)
r1, _, err := procSetupUninstallOEMInfW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(InfFileName))),
	uintptr(Flags),
	uintptr(Reserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SetupUninstallOEMInfW(
  InfFileName: PWideChar;   // LPCWSTR
  Flags: DWORD;   // DWORD
  Reserved: Pointer   // void* optional
): BOOL; stdcall;
  external 'SETUPAPI.dll' name 'SetupUninstallOEMInfW';
result := DllCall("SETUPAPI\SetupUninstallOEMInfW"
    , "WStr", InfFileName   ; LPCWSTR
    , "UInt", Flags   ; DWORD
    , "Ptr", Reserved   ; void* optional
    , "Int")   ; return: BOOL
●SetupUninstallOEMInfW(InfFileName, Flags, Reserved) = DLL("SETUPAPI.dll", "bool SetupUninstallOEMInfW(char*, dword, void*)")
# 呼び出し: SetupUninstallOEMInfW(InfFileName, Flags, Reserved)
# InfFileName : LPCWSTR -> "char*"
# Flags : DWORD -> "dword"
# Reserved : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。