LPWSTR   group=L"administrators";
 nStatus= NetGroupAddUser(NULL,group,lpszUserName);

解决方案 »

  1.   

    弄了半天实在是不明白了,也是unicode型的字符串啊
      

  2.   

    If the function succeeds, the return value is NERR_Success.If the function fails, the return value can be one of the following error codes.Return code Description 
    ERROR_ACCESS_DENIED The user does not have access to the requested information. 
    NERR_InvalidComputer The computer name is invalid. 
    NERR_NotPrimary The operation is allowed only on the primary domain controller of the domain. 
    NERR_SpeGroupOp The operation is not allowed on certain special groups. These groups include user groups, admin groups, local groups, and guest groups. 
    NERR_UserNotFound The user name could not be found. 
    NERR_GroupNotFound The global group name could not be found. 
    你看看具体的返回值吧!~
      

  3.   

    LPWSTR   group=L"Administrators";
    nStatus= NetGroupAddUser(NULL,group,lpszUserName);系统管理员的group不是administrators么?
      

  4.   

    返回值2220,在error lookup中查看就是找不到组名啊具体的就是2220:找不到组名
      

  5.   

    因为这个API是向非本地组添加用户的,而你已经看到存在的用户组名是本地组里的
      

  6.   

    你可以试试NetLocalGroupAddMembers这个API