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