ホーム › Security.Credentials › CredIsProtectedA
CredIsProtectedA
関数資格情報文字列が保護されているか判定する。
シグネチャ
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
BOOL CredIsProtectedA(
LPSTR pszProtectedCredentials,
CRED_PROTECTION_TYPE* pProtectionType
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pszProtectedCredentials | LPSTR | in |
| pProtectionType | CRED_PROTECTION_TYPE* | out |
戻り値の型: BOOL
各言語での呼び出し定義
// ADVAPI32.dll (ANSI / -A)
#include <windows.h>
BOOL CredIsProtectedA(
LPSTR pszProtectedCredentials,
CRED_PROTECTION_TYPE* pProtectionType
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("ADVAPI32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool CredIsProtectedA(
[MarshalAs(UnmanagedType.LPStr)] string pszProtectedCredentials, // LPSTR
out int pProtectionType // CRED_PROTECTION_TYPE* out
);<DllImport("ADVAPI32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CredIsProtectedA(
<MarshalAs(UnmanagedType.LPStr)> pszProtectedCredentials As String, ' LPSTR
<Out> ByRef pProtectionType As Integer ' CRED_PROTECTION_TYPE* out
) As Boolean
End Function' pszProtectedCredentials : LPSTR
' pProtectionType : CRED_PROTECTION_TYPE* out
Declare PtrSafe Function CredIsProtectedA Lib "advapi32" ( _
ByVal pszProtectedCredentials As String, _
ByRef pProtectionType As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CredIsProtectedA = ctypes.windll.advapi32.CredIsProtectedA
CredIsProtectedA.restype = wintypes.BOOL
CredIsProtectedA.argtypes = [
wintypes.LPCSTR, # pszProtectedCredentials : LPSTR
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')
CredIsProtectedA = Fiddle::Function.new(
lib['CredIsProtectedA'],
[
Fiddle::TYPE_VOIDP, # pszProtectedCredentials : LPSTR
Fiddle::TYPE_VOIDP, # pProtectionType : CRED_PROTECTION_TYPE* out
],
Fiddle::TYPE_INT)#[link(name = "advapi32")]
extern "system" {
fn CredIsProtectedA(
pszProtectedCredentials: *mut u8, // LPSTR
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.Ansi, SetLastError = true)]
public static extern bool CredIsProtectedA([MarshalAs(UnmanagedType.LPStr)] string pszProtectedCredentials, out int pProtectionType);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVAPI32_CredIsProtectedA' -Namespace Win32 -PassThru
# $api::CredIsProtectedA(pszProtectedCredentials, pProtectionType)#uselib "ADVAPI32.dll"
#func global CredIsProtectedA "CredIsProtectedA" sptr, sptr
; CredIsProtectedA pszProtectedCredentials, pProtectionType ; 戻り値は stat
; pszProtectedCredentials : LPSTR -> "sptr"
; pProtectionType : CRED_PROTECTION_TYPE* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVAPI32.dll"
#cfunc global CredIsProtectedA "CredIsProtectedA" str, int
; res = CredIsProtectedA(pszProtectedCredentials, pProtectionType)
; pszProtectedCredentials : LPSTR -> "str"
; pProtectionType : CRED_PROTECTION_TYPE* out -> "int"; BOOL CredIsProtectedA(LPSTR pszProtectedCredentials, CRED_PROTECTION_TYPE* pProtectionType)
#uselib "ADVAPI32.dll"
#cfunc global CredIsProtectedA "CredIsProtectedA" str, int
; res = CredIsProtectedA(pszProtectedCredentials, pProtectionType)
; pszProtectedCredentials : LPSTR -> "str"
; pProtectionType : CRED_PROTECTION_TYPE* out -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advapi32 = windows.NewLazySystemDLL("ADVAPI32.dll")
procCredIsProtectedA = advapi32.NewProc("CredIsProtectedA")
)
// pszProtectedCredentials (LPSTR), pProtectionType (CRED_PROTECTION_TYPE* out)
r1, _, err := procCredIsProtectedA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszProtectedCredentials))),
uintptr(pProtectionType),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CredIsProtectedA(
pszProtectedCredentials: PAnsiChar; // LPSTR
pProtectionType: Pointer // CRED_PROTECTION_TYPE* out
): BOOL; stdcall;
external 'ADVAPI32.dll' name 'CredIsProtectedA';result := DllCall("ADVAPI32\CredIsProtectedA"
, "AStr", pszProtectedCredentials ; LPSTR
, "Ptr", pProtectionType ; CRED_PROTECTION_TYPE* out
, "Int") ; return: BOOL●CredIsProtectedA(pszProtectedCredentials, pProtectionType) = DLL("ADVAPI32.dll", "bool CredIsProtectedA(char*, void*)")
# 呼び出し: CredIsProtectedA(pszProtectedCredentials, pProtectionType)
# pszProtectedCredentials : LPSTR -> "char*"
# pProtectionType : CRED_PROTECTION_TYPE* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。