ホーム › Security.EnterpriseData › ProtectFileToEnterpriseIdentity
ProtectFileToEnterpriseIdentity
関数指定ファイルまたはフォルダーを企業IDで暗号化保護する。
シグネチャ
// efswrt.dll
#include <windows.h>
HRESULT ProtectFileToEnterpriseIdentity(
LPCWSTR fileOrFolderPath,
LPCWSTR identity
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| fileOrFolderPath | LPCWSTR | in |
| identity | LPCWSTR | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// efswrt.dll
#include <windows.h>
HRESULT ProtectFileToEnterpriseIdentity(
LPCWSTR fileOrFolderPath,
LPCWSTR identity
);[DllImport("efswrt.dll", ExactSpelling = true)]
static extern int ProtectFileToEnterpriseIdentity(
[MarshalAs(UnmanagedType.LPWStr)] string fileOrFolderPath, // LPCWSTR
[MarshalAs(UnmanagedType.LPWStr)] string identity // LPCWSTR
);<DllImport("efswrt.dll", ExactSpelling:=True)>
Public Shared Function ProtectFileToEnterpriseIdentity(
<MarshalAs(UnmanagedType.LPWStr)> fileOrFolderPath As String, ' LPCWSTR
<MarshalAs(UnmanagedType.LPWStr)> identity As String ' LPCWSTR
) As Integer
End Function' fileOrFolderPath : LPCWSTR
' identity : LPCWSTR
Declare PtrSafe Function ProtectFileToEnterpriseIdentity Lib "efswrt" ( _
ByVal fileOrFolderPath As LongPtr, _
ByVal identity As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ProtectFileToEnterpriseIdentity = ctypes.windll.efswrt.ProtectFileToEnterpriseIdentity
ProtectFileToEnterpriseIdentity.restype = ctypes.c_int
ProtectFileToEnterpriseIdentity.argtypes = [
wintypes.LPCWSTR, # fileOrFolderPath : LPCWSTR
wintypes.LPCWSTR, # identity : LPCWSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('efswrt.dll')
ProtectFileToEnterpriseIdentity = Fiddle::Function.new(
lib['ProtectFileToEnterpriseIdentity'],
[
Fiddle::TYPE_VOIDP, # fileOrFolderPath : LPCWSTR
Fiddle::TYPE_VOIDP, # identity : LPCWSTR
],
Fiddle::TYPE_INT)#[link(name = "efswrt")]
extern "system" {
fn ProtectFileToEnterpriseIdentity(
fileOrFolderPath: *const u16, // LPCWSTR
identity: *const u16 // LPCWSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("efswrt.dll")]
public static extern int ProtectFileToEnterpriseIdentity([MarshalAs(UnmanagedType.LPWStr)] string fileOrFolderPath, [MarshalAs(UnmanagedType.LPWStr)] string identity);
"@
$api = Add-Type -MemberDefinition $sig -Name 'efswrt_ProtectFileToEnterpriseIdentity' -Namespace Win32 -PassThru
# $api::ProtectFileToEnterpriseIdentity(fileOrFolderPath, identity)#uselib "efswrt.dll"
#func global ProtectFileToEnterpriseIdentity "ProtectFileToEnterpriseIdentity" sptr, sptr
; ProtectFileToEnterpriseIdentity fileOrFolderPath, identity ; 戻り値は stat
; fileOrFolderPath : LPCWSTR -> "sptr"
; identity : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "efswrt.dll"
#cfunc global ProtectFileToEnterpriseIdentity "ProtectFileToEnterpriseIdentity" wstr, wstr
; res = ProtectFileToEnterpriseIdentity(fileOrFolderPath, identity)
; fileOrFolderPath : LPCWSTR -> "wstr"
; identity : LPCWSTR -> "wstr"; HRESULT ProtectFileToEnterpriseIdentity(LPCWSTR fileOrFolderPath, LPCWSTR identity)
#uselib "efswrt.dll"
#cfunc global ProtectFileToEnterpriseIdentity "ProtectFileToEnterpriseIdentity" wstr, wstr
; res = ProtectFileToEnterpriseIdentity(fileOrFolderPath, identity)
; fileOrFolderPath : LPCWSTR -> "wstr"
; identity : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
efswrt = windows.NewLazySystemDLL("efswrt.dll")
procProtectFileToEnterpriseIdentity = efswrt.NewProc("ProtectFileToEnterpriseIdentity")
)
// fileOrFolderPath (LPCWSTR), identity (LPCWSTR)
r1, _, err := procProtectFileToEnterpriseIdentity.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(fileOrFolderPath))),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(identity))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ProtectFileToEnterpriseIdentity(
fileOrFolderPath: PWideChar; // LPCWSTR
identity: PWideChar // LPCWSTR
): Integer; stdcall;
external 'efswrt.dll' name 'ProtectFileToEnterpriseIdentity';result := DllCall("efswrt\ProtectFileToEnterpriseIdentity"
, "WStr", fileOrFolderPath ; LPCWSTR
, "WStr", identity ; LPCWSTR
, "Int") ; return: HRESULT●ProtectFileToEnterpriseIdentity(fileOrFolderPath, identity) = DLL("efswrt.dll", "int ProtectFileToEnterpriseIdentity(char*, char*)")
# 呼び出し: ProtectFileToEnterpriseIdentity(fileOrFolderPath, identity)
# fileOrFolderPath : LPCWSTR -> "char*"
# identity : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。