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