Application skeleton for NtUserAdd()

/*
 * AddUser - skeleton for a user administration tool
 * by O. Dippel, dippel@cross-connect.de
 */

// all functions need UNICODE !
#define UNICODE
#define _UNICODE

#include <windows.h>
// needed include files for user administration
#include <lmcons.h>
#include <lmaccess.h>
#include <lmerr.h>

void Init_USER_INFO_3(LPUSER_INFO_3 pUser) {
	// fill structure ..
}	// end of Init_USER_INFO_3()

void main(void)
{
	// userinfo structure
	USER_INFO_3			NewUser;

	// initialize user structure with meaningful default values
	Init_USER_INFO_3(&NewUser);

	// modify structure, e.g.: user may not change password
	NewUser.usri3_flags|= UF_PASSWD_CANT_CHANGE;

	// add user to the userbase of local computer first parameter == NULL
	if (NetUserAdd(NULL, 3, (LPBYTE)&NewUser, NULL)) == ERR_SUCCESS)
	{
		fwprintf(stdout, TEXT("Successfully created user \"%s\" (%s)\n"), \
			NewUser.usri3_name, NewUser.usri3_full_name);
	} else {
		fwprintf(stderr, TEXT("ERROR in NetUserAdd()\n"));
		return;
	}
}	// end of main()