我想在HKEY_USERS下创建子键,使用RegCreateKeyEx没成功,单步跟踪调试,说是参数不正确
请问除了用RegCreateKeyEx,还有别的办法吗?
LResult = RegCreateKeyEx(
HKEY_USERS,
(LPCTSTR)strKey,
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_CREATE_SUB_KEY,
NULL,
&hKEY,
&DwDisp
);
if(LResult != ERROR_SUCCESS)
{
LPTSTR lpBuffer ; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,LResult, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpBuffer, 0, NULL ) ;
LocalFree( lpBuffer ) ;
cout << "Error Creat SubKey" << endl;
}
请问除了用RegCreateKeyEx,还有别的办法吗?
LResult = RegCreateKeyEx(
HKEY_USERS,
(LPCTSTR)strKey,
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_CREATE_SUB_KEY,
NULL,
&hKEY,
&DwDisp
);
if(LResult != ERROR_SUCCESS)
{
LPTSTR lpBuffer ; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,LResult, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpBuffer, 0, NULL ) ;
LocalFree( lpBuffer ) ;
cout << "Error Creat SubKey" << endl;
}
HKEY_USERS
HKEY_LOCAL_MACHINE
下面就是不允许当前用户创建的..
除非进入更深的一层子键.其他位置测试 过都可以.
你想新增一个用户??
不知LZ有何应用...
我想在下面添加用户,并导入用户配置文件
http://topic.csdn.net/t/20050224/13/3803202.html
http://www.99ydy.com/html/20050120/17/3741735.html
至于配置信息,网页上也说的有,不过它是加载dll来调用函数的,LZ自己查看下吧.
可以不? 我这里暂时CSDN对旧数据不能搜索了.添加用户这类 这问题应该以前问的有.The following code sample demonstrates how to add a user account and assign a privilege level using a call to the NetUserAdd function. The code sample fills in the members of the USER_INFO_1 structure and calls NetUserAdd, specifying information level 1.
#ifndef UNICODE
#define UNICODE
#endif
#include <stdio.h>
#include <windows.h>
#include <lm.h>
int wmain(int argc, wchar_t *argv[])
{
USER_INFO_1 ui;
DWORD dwLevel = 1;
DWORD dwError = 0;
NET_API_STATUS nStatus;
if (argc != 3)
{
fwprintf(stderr, L"Usage: %s \\\\ServerName UserName\n", argv[0]);
exit(1);
}
//
// Set up the USER_INFO_1 structure.
// USER_PRIV_USER: name identifies a user,
// rather than an administrator or a guest.
// UF_SCRIPT: required for LAN Manager 2.0 and
// Windows NT and later.
//
ui.usri1_name = argv[2];
ui.usri1_password = argv[2];
ui.usri1_priv = USER_PRIV_USER;
ui.usri1_home_dir = NULL;
ui.usri1_comment = NULL;
ui.usri1_flags = UF_SCRIPT;
ui.usri1_script_path = NULL;
//
// Call the NetUserAdd function, specifying level 1.
//
nStatus = NetUserAdd(argv[1],
dwLevel,
(LPBYTE)&ui,
&dwError);
//
// If the call succeeds, inform the user.
//
if (nStatus == NERR_Success)
fwprintf(stderr, L"User %s has been successfully added on %s\n",
argv[2], argv[1]);
//
// Otherwise, print the system error.
//
else
fprintf(stderr, "A system error has occurred: %d\n", nStatus);
return 0;
}
Requirements
Client: Requires Windows XP, Windows 2000 Professional, or Windows NT Workstation.
Server: Requires Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header: Declared in Lmaccess.h; include Lm.h.
Library: Use Netapi32.lib.