Link to home
Start Free TrialLog in
Avatar of mreha
mreha

asked on

WinVerifyTrust API

What do you need in your development environment to
use the WinVerifyTrust() API? When I use the API it
gives an error 'linked to missing export ADVAPI32.DLL:
WinVerifyTrust'.

The following sample code is used in a simple
dialog box app to test the API. I have a personal
and private key to digitally sign code with. I have
tested the keys out using the tools in the ActiveX
SDK. The error happens when I run the test app,
not when the API is being invoked.

// Test the Win Veriy Trust API
void CWinVerifyDlg::OnTestButton()
{
   HRESULT hResult;
   GUID ActionID;
   GUID SubjectType = WIN_TRUST_SUBJTYPE_PE_IMAGE;
   WIN_TRUST_ACTDATA_SUBJECT_ONLY ActionData;
   WIN_TRUST_SUBJECT_FILE SubjectFile;

   SubjectFile.hFile = 0;
   SubjectFile.lpPath = (LPCWSTR)"\\Test\\Authent\\SwUpdate.exe";
   ActionData.SubjectType = &SubjectType;
   ActionData.Subject = &SubjectFile;
   
   hResult = ::WinVerifyTrust      (this->GetSafeHwnd (), &ActionID, &ActionData);
   switch (hResult)
   {
      case ERROR_SUCCESS:
         AfxMessageBox ("Trusted Code!");
         break;
      case TRUST_E_SUBJECT_NOT_TRUSTED:
         AfxMessageBox ("Not Trusted Code!");
         break;
      case TRUST_E_PROVIDER_UNKNOWN:
         AfxMessageBox ("Provider Unknown!");
         break;
      case TRUST_E_ACTION_UNKNOWN:
         AfxMessageBox ("Action Unknown!");
         break;
      case TRUST_E_SUBJECT_FORM_UNKNOWN:
         AfxMessageBox ("Form Unknown!");
         break;
      default:
         AfxMessageBox ("Error Unknown!");
         break;
   }
}
ASKER CERTIFIED SOLUTION
Avatar of mikeblas
mikeblas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial