[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

WinVerifyTrust API

Posted on 1997-03-08
1
Medium Priority
?
933 Views
Last Modified: 2013-11-19
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;
   }
}
0
Comment
Question by:mreha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 11

Accepted Solution

by:
mikeblas earned 140 total points
ID: 1300224
It sounds like you're using a beta version of the ActiveX SDK.  You should upgrade to a supported version.

The WinVerifyTrust() function isn't implemented by ADVAPI32.DLL.  It is, instead, implemented by WINTRUST.DLL.  From the symptoms you describe, it sounds like you've got a bad version of ADVAPI32.LIB, and you need to find a copy of WINTRUST.LIB (and, at runtime, WINTRUST.DLL) that has the function exported.

This line of code, by the way:

   SubjectFile.lpPath = (LPCWSTR)"\\Test\\Authent\\SwUpdate.exe";

includes an invalid cast. You should have coded:

   SubjectFile.lpPath = L"\\Test\\Authent\\SwUpdate.exe";

.B ekiM

0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question