Hola amigos del foro, estoy trabajando en una app que necesita CreateProcessWithLogonW estoy trabajando en MicrosoftVisual C++ pero me esta dando el siguiente problem: error C2065: 'CreateProcessWithLogonW' : undeclared identifier. El codigo que estoy utilizando es basado en Microsoft
Código:
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <sstream>
#include <fstream>
#include <stdlib.h>
#include <windows.h>
#include <userenv.h>
#define _WIN32_WINNT 0x0500
const LOGON_WITH_PROFILE = 0x00000001;
void wmain(int argc, WCHAR *argv[])
{
DWORD dwSize;
HANDLE hToken;
LPVOID lpvEnv;
PROCESS_INFORMATION pi = {0};
STARTUPINFO si = {0};
WCHAR szUserProfile[256] = L"";
si.cb = sizeof(STARTUPINFO);
if (argc != 4)
{
wprintf(L"Usage: %s [user@domain] [password] [cmd]", argv[0]);
wprintf(L"\n\n");
return;
}
//
// TO DO: change NULL to '.' to use local account database
//
if (!LogonUser(argv[1], NULL, argv[2], LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT, &hToken))
return 1;
if (!CreateEnvironmentBlock(&lpvEnv, hToken, TRUE))
return 1;
dwSize = sizeof(szUserProfile)/sizeof(WCHAR);
if (!GetUserProfileDirectory(hToken, szUserProfile, &dwSize))
return 1;
//
// TO DO: change NULL to '.' to use local account database
//
if (!CreateProcessWithLogonW(argv[1], NULL, argv[2],
LOGON_WITH_PROFILE, NULL, argv[3],
CREATE_UNICODE_ENVIRONMENT, lpvEnv, szUserProfile,
&si, &pi))
return 1;
if (!DestroyEnvironmentBlock(lpvEnv))
return 1;
CloseHandle(hToken);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
}