ホーム › System.WindowsProgramming › AdvInstallFileW
AdvInstallFileW
関数ファイルをコピーしてインストールする(Unicode版)。
シグネチャ
// ADVPACK.dll (Unicode / -W)
#include <windows.h>
HRESULT AdvInstallFileW(
HWND hwnd,
LPCWSTR lpszSourceDir,
LPCWSTR lpszSourceFile,
LPCWSTR lpszDestDir,
LPCWSTR lpszDestFile,
DWORD dwFlags,
DWORD dwReserved
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hwnd | HWND | in |
| lpszSourceDir | LPCWSTR | in |
| lpszSourceFile | LPCWSTR | in |
| lpszDestDir | LPCWSTR | in |
| lpszDestFile | LPCWSTR | in |
| dwFlags | DWORD | in |
| dwReserved | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// ADVPACK.dll (Unicode / -W)
#include <windows.h>
HRESULT AdvInstallFileW(
HWND hwnd,
LPCWSTR lpszSourceDir,
LPCWSTR lpszSourceFile,
LPCWSTR lpszDestDir,
LPCWSTR lpszDestFile,
DWORD dwFlags,
DWORD dwReserved
);[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int AdvInstallFileW(
IntPtr hwnd, // HWND
[MarshalAs(UnmanagedType.LPWStr)] string lpszSourceDir, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpszSourceFile, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpszDestDir, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string lpszDestFile, // LPCWSTR
uint dwFlags, // DWORD
uint dwReserved // DWORD
);<DllImport("ADVPACK.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function AdvInstallFileW(
hwnd As IntPtr, ' HWND
<MarshalAs(UnmanagedType.LPWStr)> lpszSourceDir As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpszSourceFile As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpszDestDir As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpszDestFile As String, ' LPCWSTR
dwFlags As UInteger, ' DWORD
dwReserved As UInteger ' DWORD
) As Integer
End Function' hwnd : HWND
' lpszSourceDir : LPCWSTR
' lpszSourceFile : LPCWSTR
' lpszDestDir : LPCWSTR
' lpszDestFile : LPCWSTR
' dwFlags : DWORD
' dwReserved : DWORD
Declare PtrSafe Function AdvInstallFileW Lib "advpack" ( _
ByVal hwnd As LongPtr, _
ByVal lpszSourceDir As LongPtr, _
ByVal lpszSourceFile As LongPtr, _
ByVal lpszDestDir As LongPtr, _
ByVal lpszDestFile As LongPtr, _
ByVal dwFlags As Long, _
ByVal dwReserved 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
AdvInstallFileW = ctypes.windll.advpack.AdvInstallFileW
AdvInstallFileW.restype = ctypes.c_int
AdvInstallFileW.argtypes = [
wintypes.HANDLE, # hwnd : HWND
wintypes.LPCWSTR, # lpszSourceDir : LPCWSTR
wintypes.LPCWSTR, # lpszSourceFile : LPCWSTR
wintypes.LPCWSTR, # lpszDestDir : LPCWSTR
wintypes.LPCWSTR, # lpszDestFile : LPCWSTR
wintypes.DWORD, # dwFlags : DWORD
wintypes.DWORD, # dwReserved : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVPACK.dll')
AdvInstallFileW = Fiddle::Function.new(
lib['AdvInstallFileW'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND
Fiddle::TYPE_VOIDP, # lpszSourceDir : LPCWSTR
Fiddle::TYPE_VOIDP, # lpszSourceFile : LPCWSTR
Fiddle::TYPE_VOIDP, # lpszDestDir : LPCWSTR
Fiddle::TYPE_VOIDP, # lpszDestFile : LPCWSTR
-Fiddle::TYPE_INT, # dwFlags : DWORD
-Fiddle::TYPE_INT, # dwReserved : DWORD
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "advpack")]
extern "system" {
fn AdvInstallFileW(
hwnd: *mut core::ffi::c_void, // HWND
lpszSourceDir: *const u16, // LPCWSTR
lpszSourceFile: *const u16, // LPCWSTR
lpszDestDir: *const u16, // LPCWSTR
lpszDestFile: *const u16, // LPCWSTR
dwFlags: u32, // DWORD
dwReserved: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode)]
public static extern int AdvInstallFileW(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] string lpszSourceDir, [MarshalAs(UnmanagedType.LPWStr)] string lpszSourceFile, [MarshalAs(UnmanagedType.LPWStr)] string lpszDestDir, [MarshalAs(UnmanagedType.LPWStr)] string lpszDestFile, uint dwFlags, uint dwReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVPACK_AdvInstallFileW' -Namespace Win32 -PassThru
# $api::AdvInstallFileW(hwnd, lpszSourceDir, lpszSourceFile, lpszDestDir, lpszDestFile, dwFlags, dwReserved)#uselib "ADVPACK.dll"
#func global AdvInstallFileW "AdvInstallFileW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; AdvInstallFileW hwnd, lpszSourceDir, lpszSourceFile, lpszDestDir, lpszDestFile, dwFlags, dwReserved ; 戻り値は stat
; hwnd : HWND -> "wptr"
; lpszSourceDir : LPCWSTR -> "wptr"
; lpszSourceFile : LPCWSTR -> "wptr"
; lpszDestDir : LPCWSTR -> "wptr"
; lpszDestFile : LPCWSTR -> "wptr"
; dwFlags : DWORD -> "wptr"
; dwReserved : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVPACK.dll"
#cfunc global AdvInstallFileW "AdvInstallFileW" sptr, wstr, wstr, wstr, wstr, int, int
; res = AdvInstallFileW(hwnd, lpszSourceDir, lpszSourceFile, lpszDestDir, lpszDestFile, dwFlags, dwReserved)
; hwnd : HWND -> "sptr"
; lpszSourceDir : LPCWSTR -> "wstr"
; lpszSourceFile : LPCWSTR -> "wstr"
; lpszDestDir : LPCWSTR -> "wstr"
; lpszDestFile : LPCWSTR -> "wstr"
; dwFlags : DWORD -> "int"
; dwReserved : DWORD -> "int"; HRESULT AdvInstallFileW(HWND hwnd, LPCWSTR lpszSourceDir, LPCWSTR lpszSourceFile, LPCWSTR lpszDestDir, LPCWSTR lpszDestFile, DWORD dwFlags, DWORD dwReserved)
#uselib "ADVPACK.dll"
#cfunc global AdvInstallFileW "AdvInstallFileW" intptr, wstr, wstr, wstr, wstr, int, int
; res = AdvInstallFileW(hwnd, lpszSourceDir, lpszSourceFile, lpszDestDir, lpszDestFile, dwFlags, dwReserved)
; hwnd : HWND -> "intptr"
; lpszSourceDir : LPCWSTR -> "wstr"
; lpszSourceFile : LPCWSTR -> "wstr"
; lpszDestDir : LPCWSTR -> "wstr"
; lpszDestFile : LPCWSTR -> "wstr"
; dwFlags : DWORD -> "int"
; dwReserved : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advpack = windows.NewLazySystemDLL("ADVPACK.dll")
procAdvInstallFileW = advpack.NewProc("AdvInstallFileW")
)
// hwnd (HWND), lpszSourceDir (LPCWSTR), lpszSourceFile (LPCWSTR), lpszDestDir (LPCWSTR), lpszDestFile (LPCWSTR), dwFlags (DWORD), dwReserved (DWORD)
r1, _, err := procAdvInstallFileW.Call(
uintptr(hwnd),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszSourceDir))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszSourceFile))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszDestDir))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszDestFile))),
uintptr(dwFlags),
uintptr(dwReserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction AdvInstallFileW(
hwnd: THandle; // HWND
lpszSourceDir: PWideChar; // LPCWSTR
lpszSourceFile: PWideChar; // LPCWSTR
lpszDestDir: PWideChar; // LPCWSTR
lpszDestFile: PWideChar; // LPCWSTR
dwFlags: DWORD; // DWORD
dwReserved: DWORD // DWORD
): Integer; stdcall;
external 'ADVPACK.dll' name 'AdvInstallFileW';result := DllCall("ADVPACK\AdvInstallFileW"
, "Ptr", hwnd ; HWND
, "WStr", lpszSourceDir ; LPCWSTR
, "WStr", lpszSourceFile ; LPCWSTR
, "WStr", lpszDestDir ; LPCWSTR
, "WStr", lpszDestFile ; LPCWSTR
, "UInt", dwFlags ; DWORD
, "UInt", dwReserved ; DWORD
, "Int") ; return: HRESULT●AdvInstallFileW(hwnd, lpszSourceDir, lpszSourceFile, lpszDestDir, lpszDestFile, dwFlags, dwReserved) = DLL("ADVPACK.dll", "int AdvInstallFileW(void*, char*, char*, char*, char*, dword, dword)")
# 呼び出し: AdvInstallFileW(hwnd, lpszSourceDir, lpszSourceFile, lpszDestDir, lpszDestFile, dwFlags, dwReserved)
# hwnd : HWND -> "void*"
# lpszSourceDir : LPCWSTR -> "char*"
# lpszSourceFile : LPCWSTR -> "char*"
# lpszDestDir : LPCWSTR -> "char*"
# lpszDestFile : LPCWSTR -> "char*"
# dwFlags : DWORD -> "dword"
# dwReserved : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。