代码测试?
GWI 2006-04-14 10:45:38 //---------------------------------------------------------------------------
#include <vcl.h>
#include <windows.h>
#include <stdio.h>
#include <lm.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btn1Click(TObject *Sender)
{
PUSER_INFO_3 pUsr = NULL;
NET_API_STATUS netRet = 0;
DWORD dwParmError = 0;
wchar_t temp[5][200];
pUsr->usri3_name =StringToWideChar("yy", temp[0], 200); //yy是用户名
netRet = NetUserGetInfo( NULL, pUsr->usri3_name, 3, (LPBYTE *)&pUsr);
if( netRet == NERR_Success )
{
pUsr->usri3_password_expired = TRUE;
netRet = NetUserSetInfo( NULL, pUsr->usri3_name, 3, (LPBYTE)pUsr, &dwParmError);
if( netRet == NERR_Success )
printf("User %S will need to change password at next logon", pUsr->usri3_name);
else printf("Error %d occurred. Parm Error %d returned.\n", netRet, dwParmError);
NetApiBufferFree( pUsr);
}
else
printf("NetUserGetInfo failed: %d\n",netRet);
}
//---------------------------------------------------------------------------
其效果是要达到"提示用户第一次登录时修改密码".
该代码出自
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/netmgmt/forcing_a_user_to_change_the_logon_password.asp
该代码可以编译通过,但是无法运行????????????????????????