locked
C++ Windows Runtime Component not loading winevt.h

    Question

  • The following code does not work. Can you help?
    This is a C++ Windows Runtime Component project. I just added a class with the below code and the error I get back are C2065 EVT_HANDLE is undefined and IntelliSense: identifier "EVT_HANDLE" is undefined.

    #include <Windows.h>
    #include <winevt.h>
    #include "pch.h"
    #include "Class2.h"
     
    Class2::Class2(){}
    Class2::~Class2(){}
     
    EVT_HANDLE Class2::ConnectToRemote(LPWSTR lpwszComputerNameLPWSTR lpwszDomainLPWSTR lpwszUserLPWSTR lpwszPassword){
     
    	EVT_HANDLE hRemote = NULL;
    	EVT_RPC_LOGIN Credentials;
     
    	RtlZeroMemory(&Credentials, sizeof(EVT_RPC_LOGIN));
    	Credentials.Server = lpwszComputerName;
    	Credentials.Domain = lpwszDomain;
    	Credentials.User = lpwszUser;
    	Credentials.Password = lpwszPassword;
    	Credentials.Flags = EvtRpcLoginAuthNegotiate;
     
    	// This call creates a remote session context; it does not actually
    	// create a connection to the remote computer. The connection to
    	// the remote computer happens when you use the context.
    	hRemote = EvtOpenSession(EvtRpcLogin, &Credentials, 0, 0);
     
    	SecureZeroMemory(&Credentials, sizeof(EVT_RPC_LOGIN));
     
    	return hRemote;
     
    }
     
    
    Thursday, August 07, 2014 10:17 PM

Answers