ホーム › Storage.FileSystem › GetExpandedNameW
GetExpandedNameW
関数圧縮ファイルの元のファイル名を取得する(Unicode版)。
シグネチャ
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
INT GetExpandedNameW(
LPWSTR lpszSource,
LPWSTR lpszBuffer
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpszSource | LPWSTR | in |
| lpszBuffer | LPWSTR | out |
戻り値の型: INT
各言語での呼び出し定義
// KERNEL32.dll (Unicode / -W)
#include <windows.h>
INT GetExpandedNameW(
LPWSTR lpszSource,
LPWSTR lpszBuffer
);[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern int GetExpandedNameW(
[MarshalAs(UnmanagedType.LPWStr)] string lpszSource, // LPWSTR
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszBuffer // LPWSTR out
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetExpandedNameW(
<MarshalAs(UnmanagedType.LPWStr)> lpszSource As String, ' LPWSTR
<MarshalAs(UnmanagedType.LPWStr)> lpszBuffer As System.Text.StringBuilder ' LPWSTR out
) As Integer
End Function' lpszSource : LPWSTR
' lpszBuffer : LPWSTR out
Declare PtrSafe Function GetExpandedNameW Lib "kernel32" ( _
ByVal lpszSource As LongPtr, _
ByVal lpszBuffer 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
GetExpandedNameW = ctypes.windll.kernel32.GetExpandedNameW
GetExpandedNameW.restype = ctypes.c_int
GetExpandedNameW.argtypes = [
wintypes.LPCWSTR, # lpszSource : LPWSTR
wintypes.LPWSTR, # lpszBuffer : LPWSTR out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
GetExpandedNameW = Fiddle::Function.new(
lib['GetExpandedNameW'],
[
Fiddle::TYPE_VOIDP, # lpszSource : LPWSTR
Fiddle::TYPE_VOIDP, # lpszBuffer : LPWSTR out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "kernel32")]
extern "system" {
fn GetExpandedNameW(
lpszSource: *mut u16, // LPWSTR
lpszBuffer: *mut u16 // LPWSTR out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern int GetExpandedNameW([MarshalAs(UnmanagedType.LPWStr)] string lpszSource, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszBuffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetExpandedNameW' -Namespace Win32 -PassThru
# $api::GetExpandedNameW(lpszSource, lpszBuffer)#uselib "KERNEL32.dll"
#func global GetExpandedNameW "GetExpandedNameW" wptr, wptr
; GetExpandedNameW lpszSource, varptr(lpszBuffer) ; 戻り値は stat
; lpszSource : LPWSTR -> "wptr"
; lpszBuffer : LPWSTR out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global GetExpandedNameW "GetExpandedNameW" wstr, var ; res = GetExpandedNameW(lpszSource, lpszBuffer) ; lpszSource : LPWSTR -> "wstr" ; lpszBuffer : LPWSTR out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global GetExpandedNameW "GetExpandedNameW" wstr, sptr ; res = GetExpandedNameW(lpszSource, varptr(lpszBuffer)) ; lpszSource : LPWSTR -> "wstr" ; lpszBuffer : LPWSTR out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; INT GetExpandedNameW(LPWSTR lpszSource, LPWSTR lpszBuffer) #uselib "KERNEL32.dll" #cfunc global GetExpandedNameW "GetExpandedNameW" wstr, var ; res = GetExpandedNameW(lpszSource, lpszBuffer) ; lpszSource : LPWSTR -> "wstr" ; lpszBuffer : LPWSTR out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; INT GetExpandedNameW(LPWSTR lpszSource, LPWSTR lpszBuffer) #uselib "KERNEL32.dll" #cfunc global GetExpandedNameW "GetExpandedNameW" wstr, intptr ; res = GetExpandedNameW(lpszSource, varptr(lpszBuffer)) ; lpszSource : LPWSTR -> "wstr" ; lpszBuffer : LPWSTR out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procGetExpandedNameW = kernel32.NewProc("GetExpandedNameW")
)
// lpszSource (LPWSTR), lpszBuffer (LPWSTR out)
r1, _, err := procGetExpandedNameW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszSource))),
uintptr(lpszBuffer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // INTfunction GetExpandedNameW(
lpszSource: PWideChar; // LPWSTR
lpszBuffer: PWideChar // LPWSTR out
): Integer; stdcall;
external 'KERNEL32.dll' name 'GetExpandedNameW';result := DllCall("KERNEL32\GetExpandedNameW"
, "WStr", lpszSource ; LPWSTR
, "Ptr", lpszBuffer ; LPWSTR out
, "Int") ; return: INT●GetExpandedNameW(lpszSource, lpszBuffer) = DLL("KERNEL32.dll", "int GetExpandedNameW(char*, char*)")
# 呼び出し: GetExpandedNameW(lpszSource, lpszBuffer)
# lpszSource : LPWSTR -> "char*"
# lpszBuffer : LPWSTR out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。