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