Win32 API 日本語リファレンス
ホームStorage.FileSystem › EncryptionDisable

EncryptionDisable

関数
指定ディレクトリの暗号化を無効化または有効化する。
DLLADVAPI32.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

// ADVAPI32.dll
#include <windows.h>

BOOL EncryptionDisable(
    LPCWSTR DirPath,
    BOOL Disable
);

パラメーター

名前方向
DirPathLPCWSTRin
DisableBOOLin

戻り値の型: BOOL

各言語での呼び出し定義

// ADVAPI32.dll
#include <windows.h>

BOOL EncryptionDisable(
    LPCWSTR DirPath,
    BOOL Disable
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool EncryptionDisable(
    [MarshalAs(UnmanagedType.LPWStr)] string DirPath,   // LPCWSTR
    bool Disable   // BOOL
);
<DllImport("ADVAPI32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function EncryptionDisable(
    <MarshalAs(UnmanagedType.LPWStr)> DirPath As String,   ' LPCWSTR
    Disable As Boolean   ' BOOL
) As Boolean
End Function
' DirPath : LPCWSTR
' Disable : BOOL
Declare PtrSafe Function EncryptionDisable Lib "advapi32" ( _
    ByVal DirPath As LongPtr, _
    ByVal Disable As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

EncryptionDisable = ctypes.windll.advapi32.EncryptionDisable
EncryptionDisable.restype = wintypes.BOOL
EncryptionDisable.argtypes = [
    wintypes.LPCWSTR,  # DirPath : LPCWSTR
    wintypes.BOOL,  # Disable : BOOL
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('ADVAPI32.dll')
EncryptionDisable = Fiddle::Function.new(
  lib['EncryptionDisable'],
  [
    Fiddle::TYPE_VOIDP,  # DirPath : LPCWSTR
    Fiddle::TYPE_INT,  # Disable : BOOL
  ],
  Fiddle::TYPE_INT)
#[link(name = "advapi32")]
extern "system" {
    fn EncryptionDisable(
        DirPath: *const u16,  // LPCWSTR
        Disable: i32  // BOOL
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", SetLastError = true)]
public static extern bool EncryptionDisable([MarshalAs(UnmanagedType.LPWStr)] string DirPath, bool Disable);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_EncryptionDisable' -Namespace Win32 -PassThru
# $api::EncryptionDisable(DirPath, Disable)
#uselib "ADVAPI32.dll"
#func global EncryptionDisable "EncryptionDisable" sptr, sptr
; EncryptionDisable DirPath, Disable   ; 戻り値は stat
; DirPath : LPCWSTR -> "sptr"
; Disable : BOOL -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "ADVAPI32.dll"
#cfunc global EncryptionDisable "EncryptionDisable" wstr, int
; res = EncryptionDisable(DirPath, Disable)
; DirPath : LPCWSTR -> "wstr"
; Disable : BOOL -> "int"
; BOOL EncryptionDisable(LPCWSTR DirPath, BOOL Disable)
#uselib "ADVAPI32.dll"
#cfunc global EncryptionDisable "EncryptionDisable" wstr, int
; res = EncryptionDisable(DirPath, Disable)
; DirPath : LPCWSTR -> "wstr"
; Disable : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
	procEncryptionDisable = advapi32.NewProc("EncryptionDisable")
)

// DirPath (LPCWSTR), Disable (BOOL)
r1, _, err := procEncryptionDisable.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(DirPath))),
	uintptr(Disable),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function EncryptionDisable(
  DirPath: PWideChar;   // LPCWSTR
  Disable: BOOL   // BOOL
): BOOL; stdcall;
  external 'ADVAPI32.dll' name 'EncryptionDisable';
result := DllCall("ADVAPI32\EncryptionDisable"
    , "WStr", DirPath   ; LPCWSTR
    , "Int", Disable   ; BOOL
    , "Int")   ; return: BOOL
●EncryptionDisable(DirPath, Disable) = DLL("ADVAPI32.dll", "bool EncryptionDisable(char*, bool)")
# 呼び出し: EncryptionDisable(DirPath, Disable)
# DirPath : LPCWSTR -> "char*"
# Disable : BOOL -> "bool"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。