阅读:2207回复:8
regsavekey 为什么不成功?
openStatus = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
keyPath, 0, KEY_ALL_ACCESS, &key) ; if (openStatus != ERROR_SUCCESS) { printf("failed! \n"); } else { STATUS = RegSaveKey(key, FileName, NULL); // openStatus = RegLoadKey(HKEY_LOCAL_MACHINE, keyPath, FileName); if (STATUS == ERROR_SUCCESS) { printf("ok! \n"); } } RegCloseKey(key); return 0; 为什么总是不能返回ERROR_SUCCESS ,既调用成功呢? |
|
沙发#
发布于:2005-06-20 23:07
FileName的值是什么?
|
|
|
板凳#
发布于:2005-06-21 11:48
指向一个文件名:如
CHAR FileName[]="D:\\test0005"; 谢谢! |
|
地板#
发布于:2005-06-21 11:50
HKEY key = NULL;
CHAR keyPath[] = "SOFTWARE\\3721"; LONG openStatus,STATUS; CHAR FileName[]="D:\\test0005"; |
|
地下室#
发布于:2005-06-21 16:21
Windows NT/2000/XP: If the file already exists, the function fails with the ERROR_ALREADY_EXISTS error.
Windows 95/98/Me: If the file already exists, the function fails with the ERROR_REGISTRY_IO_FAILED error. |
|
|
5楼#
发布于:2005-06-22 09:55
保证 文件名 不存在!
我用不同文件名 |
|
6楼#
发布于:2005-06-22 17:30
HANDLE htok;
OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &htok); TOKEN_PRIVILEGES tp; tp.PrivilegeCount = 1; tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; if ( !LookupPrivilegeValue( 0, SE_BACKUP_NAME, &tp.Privileges[0].Luid ) ) return; TOKEN_PRIVILEGES tpOld; DWORD cbOld = sizeof(tpOld); if ( !AdjustTokenPrivileges( htok, FALSE, &tp, cbOld, &tpOld, &cbOld ) ) return; HKEY key = NULL; CHAR keyPath[] = "SOFTWARE\\3721"; LONG openStatus,STATUS; CHAR FileName[]="D:\\test0005"; openStatus = RegOpenKeyEx (HKEY_LOCAL_MACHINE, keyPath, 0, KEY_ALL_ACCESS, &key); if (openStatus != ERROR_SUCCESS) { printf("failed! \n"); } else { STATUS = RegSaveKey(key, FileName, NULL); if (STATUS == ERROR_SUCCESS) { printf("ok! \n"); } } RegCloseKey(key); |
|
|
7楼#
发布于:2005-06-30 10:06
多谢了,这两天没上驱网
已搞定! 怎么没法给分了? |
|
8楼#
发布于:2005-06-30 16:27
不客气,我也不知道怎么给分.
这个论坛改版后很不爽,我来得少多了. |
|
|