1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| #include "stdafx.h"
#define _WIN32_DCOM
//#define UNICODE
#include <iostream>
using namespace std;
#include <comdef.h>
#include <Wbemidl.h>
# pragma comment(lib, "wbemuuid.lib")
# pragma comment(lib, "credui.lib")
# pragma comment(lib, "comsuppw.lib")
#include <wincred.h>
#include <strsafe.h>
#include <string.h>
int __cdecl main(int argc, char **argv)
{
CREDENTIAL *mycred = new CREDENTIAL ;
mycred->Flags=0;
mycred->TargetName =(LPWSTR) "wtn01";
mycred->CredentialBlob=(LPBYTE) "password";
mycred->CredentialBlobSize= sizeof((LPWSTR) "password");
//mycred->AttributeCount=0;
//mycred->Attributes = 0;
mycred->Comment=(LPWSTR) "comment";
mycred->Type= CRED_TYPE_DOMAIN_PASSWORD;
mycred->Persist=CRED_PERSIST_SESSION;
mycred->UserName =(LPWSTR)"user@wgs.priv";
printf("%i",mycred);
CredWrite(mycred ,NULL);
getchar();
return 0; // Program successfully completed.
} |
Partager