ホーム › Storage.FileSystem › SetUserFileEncryptionKey
SetUserFileEncryptionKey
関数ファイル暗号化に使うユーザーの証明書鍵を設定する。
シグネチャ
// ADVAPI32.dll
#include <windows.h>
DWORD SetUserFileEncryptionKey(
ENCRYPTION_CERTIFICATE* pEncryptionCertificate // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pEncryptionCertificate | ENCRYPTION_CERTIFICATE* | inoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// ADVAPI32.dll
#include <windows.h>
DWORD SetUserFileEncryptionKey(
ENCRYPTION_CERTIFICATE* pEncryptionCertificate // optional
);[DllImport("ADVAPI32.dll", ExactSpelling = true)]
static extern uint SetUserFileEncryptionKey(
IntPtr pEncryptionCertificate // ENCRYPTION_CERTIFICATE* optional
);<DllImport("ADVAPI32.dll", ExactSpelling:=True)>
Public Shared Function SetUserFileEncryptionKey(
pEncryptionCertificate As IntPtr ' ENCRYPTION_CERTIFICATE* optional
) As UInteger
End Function' pEncryptionCertificate : ENCRYPTION_CERTIFICATE* optional
Declare PtrSafe Function SetUserFileEncryptionKey Lib "advapi32" ( _
ByVal pEncryptionCertificate As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SetUserFileEncryptionKey = ctypes.windll.advapi32.SetUserFileEncryptionKey
SetUserFileEncryptionKey.restype = wintypes.DWORD
SetUserFileEncryptionKey.argtypes = [
ctypes.c_void_p, # pEncryptionCertificate : ENCRYPTION_CERTIFICATE* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
SetUserFileEncryptionKey = Fiddle::Function.new(
lib['SetUserFileEncryptionKey'],
[
Fiddle::TYPE_VOIDP, # pEncryptionCertificate : ENCRYPTION_CERTIFICATE* optional
],
-Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn SetUserFileEncryptionKey(
pEncryptionCertificate: *mut ENCRYPTION_CERTIFICATE // ENCRYPTION_CERTIFICATE* optional
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVAPI32.dll")]
public static extern uint SetUserFileEncryptionKey(IntPtr pEncryptionCertificate);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_SetUserFileEncryptionKey' -Namespace Win32 -PassThru
# $api::SetUserFileEncryptionKey(pEncryptionCertificate)#uselib "ADVAPI32.dll"
#func global SetUserFileEncryptionKey "SetUserFileEncryptionKey" sptr
; SetUserFileEncryptionKey varptr(pEncryptionCertificate) ; 戻り値は stat
; pEncryptionCertificate : ENCRYPTION_CERTIFICATE* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "ADVAPI32.dll" #cfunc global SetUserFileEncryptionKey "SetUserFileEncryptionKey" var ; res = SetUserFileEncryptionKey(pEncryptionCertificate) ; pEncryptionCertificate : ENCRYPTION_CERTIFICATE* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "ADVAPI32.dll" #cfunc global SetUserFileEncryptionKey "SetUserFileEncryptionKey" sptr ; res = SetUserFileEncryptionKey(varptr(pEncryptionCertificate)) ; pEncryptionCertificate : ENCRYPTION_CERTIFICATE* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD SetUserFileEncryptionKey(ENCRYPTION_CERTIFICATE* pEncryptionCertificate) #uselib "ADVAPI32.dll" #cfunc global SetUserFileEncryptionKey "SetUserFileEncryptionKey" var ; res = SetUserFileEncryptionKey(pEncryptionCertificate) ; pEncryptionCertificate : ENCRYPTION_CERTIFICATE* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD SetUserFileEncryptionKey(ENCRYPTION_CERTIFICATE* pEncryptionCertificate) #uselib "ADVAPI32.dll" #cfunc global SetUserFileEncryptionKey "SetUserFileEncryptionKey" intptr ; res = SetUserFileEncryptionKey(varptr(pEncryptionCertificate)) ; pEncryptionCertificate : ENCRYPTION_CERTIFICATE* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procSetUserFileEncryptionKey = advapi32.NewProc("SetUserFileEncryptionKey")
)
// pEncryptionCertificate (ENCRYPTION_CERTIFICATE* optional)
r1, _, err := procSetUserFileEncryptionKey.Call(
uintptr(pEncryptionCertificate),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SetUserFileEncryptionKey(
pEncryptionCertificate: Pointer // ENCRYPTION_CERTIFICATE* optional
): DWORD; stdcall;
external 'ADVAPI32.dll' name 'SetUserFileEncryptionKey';result := DllCall("ADVAPI32\SetUserFileEncryptionKey"
, "Ptr", pEncryptionCertificate ; ENCRYPTION_CERTIFICATE* optional
, "UInt") ; return: DWORD●SetUserFileEncryptionKey(pEncryptionCertificate) = DLL("ADVAPI32.dll", "dword SetUserFileEncryptionKey(void*)")
# 呼び出し: SetUserFileEncryptionKey(pEncryptionCertificate)
# pEncryptionCertificate : ENCRYPTION_CERTIFICATE* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。