diff --git a/dlls/advapi32/advapi32.spec b/dlls/advapi32/advapi32.spec index 5de5cc265f8..728d7546811 100644 --- a/dlls/advapi32/advapi32.spec +++ b/dlls/advapi32/advapi32.spec @@ -103,7 +103,7 @@ # @ stub CreateTraceInstanceId @ stdcall CreateWellKnownSid(long ptr ptr ptr) # @ stub CredDeleteA -# @ stub CredDeleteW +@ stdcall CredDeleteW(wstr long long) @ stdcall CredEnumerateA(str long ptr ptr) @ stdcall CredEnumerateW(wstr long ptr ptr) @ stdcall CredFree(ptr) diff --git a/dlls/advapi32/cred.c b/dlls/advapi32/cred.c index 00df9b3a1d1..714d1aff8c4 100644 --- a/dlls/advapi32/cred.c +++ b/dlls/advapi32/cred.c @@ -384,6 +384,58 @@ static LPWSTR get_key_name_for_target(LPCWSTR target_name, DWORD type) return key_name; } +/****************************************************************************** + * CredDeleteW [ADVAPI32.@] + */ +BOOL WINAPI CredDeleteW(LPCWSTR TargetName, DWORD Type, DWORD Flags) +{ + HKEY hkeyMgr; + DWORD ret; + LPWSTR key_name; + + TRACE("(%s, %d, 0x%x)\n", debugstr_w(TargetName), Type, Flags); + + if (!TargetName) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + if (Type != CRED_TYPE_GENERIC && Type != CRED_TYPE_DOMAIN_PASSWORD) + { + FIXME("unhandled type %d\n", Type); + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + if (Flags) + { + FIXME("unhandled flags 0x%x\n", Flags); + SetLastError(ERROR_INVALID_FLAGS); + return FALSE; + } + + ret = open_cred_mgr_key(&hkeyMgr, TRUE); + if (ret != ERROR_SUCCESS) + { + WARN("couldn't open/create manager key, error %d\n", ret); + SetLastError(ERROR_NO_SUCH_LOGON_SESSION); + return FALSE; + } + + key_name = get_key_name_for_target(TargetName, Type); + ret = RegDeleteKeyW(hkeyMgr, key_name); + HeapFree(GetProcessHeap(), 0, key_name); + RegCloseKey(hkeyMgr); + if (ret != ERROR_SUCCESS) + { + SetLastError(ERROR_NOT_FOUND); + return FALSE; + } + + return TRUE; +} + /****************************************************************************** * CredFree [ADVAPI32.@] */