I want to create a desktop application in windows by c++.
In this application I would like to invoke Windows Security dialog as Chrome whenever we want to show the password.
When I add the code below to my project and build then an error occurred:
Severity Code Description Project File Line Suppression State Error LNK2019 unresolved external symbol imp__CredUIPromptForWindowsCredentialsW@36 referenced in function "int stdcall ShowWindowsSecurityDialog(struct HWND *)" (?ShowWindowsSecurityDialog@@YGHPAUHWND@@@Z) TestPromptWindowsSecurity D:\Works\Learn\WindowsApp\TestPromptWindowsSecurity\TestPromptWindowsSecurity\TestPromptWindowsSecurity.obj 1
Here is my code. I put it in ShowWindowsSecurityDialog method and call it after click button.
INT_PTR CALLBACK ShowWindowsSecurityDialog(HWND hDlg)
{
DWORD dwResult;
PVOID pvInAuthBlob = NULL;
ULONG cbInAuthBlob = 0;
PVOID pvAuthBlob = NULL;
ULONG cbAuthBlob = 0;
CREDUI_INFOW ui;
ULONG ulAuthPackage = 0;
BOOL fSave = FALSE;
ui.cbSize = sizeof(ui);
ui.hwndParent = hDlg;
ui.pszMessageText = L"The Proxy Server requires user name and password";
ui.pszCaptionText = L"Proxy Authentication";
ui.hbmBanner = NULL;
dwResult = CredUIPromptForWindowsCredentialsW(
&ui, // Customizing information
0, // Error code to display
&ulAuthPackage, // Authorization package
pvInAuthBlob, // Credential byte array
cbInAuthBlob, // Size of credential input buffer
&pvAuthBlob, // Output credential byte array
&cbAuthBlob, // Size of credential byte array
&fSave, // Select the save check box.
CREDUIWIN_GENERIC);
if (dwResult == NO_ERROR)
{
}
else
{
}
return (INT_PTR)FALSE;
}
What is wrong here ? How can I make this function ?