ホーム › Security.Credentials › CredIsProtectedW
CredIsProtectedW
関数資格情報文字列が保護されているか判定する。
シグネチャ
// ADVAPI32.dll (Unicode / -W)
#include <windows.h>
BOOL CredIsProtectedW(
LPWSTR pszProtectedCredentials,
CRED_PROTECTION_TYPE* pProtectionType
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszProtectedCredentials | LPWSTR | in |
| pProtectionType | CRED_PROTECTION_TYPE* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// ADVAPI32.dll (Unicode / -W)
#include <windows.h>
BOOL CredIsProtectedW(
LPWSTR pszProtectedCredentials,
CRED_PROTECTION_TYPE* pProtectionType
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool CredIsProtectedW(
[MarshalAs(UnmanagedType.LPWStr)] string pszProtectedCredentials, // LPWSTR
out int pProtectionType // CRED_PROTECTION_TYPE* out
);<DllImport("ADVAPI32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CredIsProtectedW(
<MarshalAs(UnmanagedType.LPWStr)> pszProtectedCredentials As String, ' LPWSTR
<Out> ByRef pProtectionType As Integer ' CRED_PROTECTION_TYPE* out
) As Boolean
End Function' pszProtectedCredentials : LPWSTR
' pProtectionType : CRED_PROTECTION_TYPE* out
Declare PtrSafe Function CredIsProtectedW Lib "advapi32" ( _
ByVal pszProtectedCredentials As LongPtr, _
ByRef pProtectionType As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CredIsProtectedW = ctypes.windll.advapi32.CredIsProtectedW
CredIsProtectedW.restype = wintypes.BOOL
CredIsProtectedW.argtypes = [
wintypes.LPCWSTR, # pszProtectedCredentials : LPWSTR
ctypes.c_void_p, # pProtectionType : CRED_PROTECTION_TYPE* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVAPI32.dll')
CredIsProtectedW = Fiddle::Function.new(
lib['CredIsProtectedW'],
[
Fiddle::TYPE_VOIDP, # pszProtectedCredentials : LPWSTR
Fiddle::TYPE_VOIDP, # pProtectionType : CRED_PROTECTION_TYPE* out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "advapi32")]
extern "system" {
fn CredIsProtectedW(
pszProtectedCredentials: *mut u16, // LPWSTR
pProtectionType: *mut i32 // CRED_PROTECTION_TYPE* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool CredIsProtectedW([MarshalAs(UnmanagedType.LPWStr)] string pszProtectedCredentials, out int pProtectionType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_CredIsProtectedW' -Namespace Win32 -PassThru
# $api::CredIsProtectedW(pszProtectedCredentials, pProtectionType)#uselib "ADVAPI32.dll"
#func global CredIsProtectedW "CredIsProtectedW" wptr, wptr
; CredIsProtectedW pszProtectedCredentials, pProtectionType ; 戻り値は stat
; pszProtectedCredentials : LPWSTR -> "wptr"
; pProtectionType : CRED_PROTECTION_TYPE* out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVAPI32.dll"
#cfunc global CredIsProtectedW "CredIsProtectedW" wstr, int
; res = CredIsProtectedW(pszProtectedCredentials, pProtectionType)
; pszProtectedCredentials : LPWSTR -> "wstr"
; pProtectionType : CRED_PROTECTION_TYPE* out -> "int"; BOOL CredIsProtectedW(LPWSTR pszProtectedCredentials, CRED_PROTECTION_TYPE* pProtectionType)
#uselib "ADVAPI32.dll"
#cfunc global CredIsProtectedW "CredIsProtectedW" wstr, int
; res = CredIsProtectedW(pszProtectedCredentials, pProtectionType)
; pszProtectedCredentials : LPWSTR -> "wstr"
; pProtectionType : CRED_PROTECTION_TYPE* out -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procCredIsProtectedW = advapi32.NewProc("CredIsProtectedW")
)
// pszProtectedCredentials (LPWSTR), pProtectionType (CRED_PROTECTION_TYPE* out)
r1, _, err := procCredIsProtectedW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszProtectedCredentials))),
uintptr(pProtectionType),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CredIsProtectedW(
pszProtectedCredentials: PWideChar; // LPWSTR
pProtectionType: Pointer // CRED_PROTECTION_TYPE* out
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'CredIsProtectedW';result := DllCall("ADVAPI32\CredIsProtectedW"
, "WStr", pszProtectedCredentials ; LPWSTR
, "Ptr", pProtectionType ; CRED_PROTECTION_TYPE* out
, "Int") ; return: BOOL●CredIsProtectedW(pszProtectedCredentials, pProtectionType) = DLL("ADVAPI32.dll", "bool CredIsProtectedW(char*, void*)")
# 呼び出し: CredIsProtectedW(pszProtectedCredentials, pProtectionType)
# pszProtectedCredentials : LPWSTR -> "char*"
# pProtectionType : CRED_PROTECTION_TYPE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。