所以我试图在注册表项之后创建一个文件夹结构。这是我到目前为止所做的
#include "stdafx.h"
#include "windows.h"
#define MAX_KEY_LENGTH 200
#define MAX_VALUE_NAME 16383
DWORD retCode;
void RecursiveQueryKey(HKEY hKey)
{
HKEY nextKey;
WCHAR achKey[MAX_KEY_LENGTH];
DWORD cbName;
DWORD retCode = NULL;
DWORD i=0;
while(retCode !=ERROR_NO_MORE_ITEMS)
{
cbName = MAX_KEY_LENGTH;
retCode = RegEnumKeyEx(hKey, i,achKey,&cbName,NULL,NULL,NULL,NULL);
if (retCode == ERROR_SUCCESS)
{
wprintf(L"(%d) %s\n", i+1, achKey);
WCHAR path[MAX_KEY_LENGTH];
wchar_t *wcsncat(wchar_t *path, const wchar_t *achKey, size_t n);
if(CreateDirectoryEx(TEXT("D:\\csso\\"),achKey, NULL) != 0){
wprintf(L"Directory created in D:\\csso\\%s\n", achKey);
} else {
printf("Directory failed with the error:");
}
wprintf(L"%d\n", GetLastError());
if(RegOpenKeyEx(hKey, achKey, 0, KEY_READ | KEY_WOW64_64KEY, &nextKey) == ERROR_SUCCESS)
{
RecursiveQueryKey(nextKey);
}
}
i++;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
HKEY hKey;
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\Apple Inc."), 0, KEY_READ | KEY_WOW64_64KEY, &hKey) == ERROR_SUCCESS)
{
printf("RegOpenKeyEx() is OK!\n");
RecursiveQueryKey(hKey);
}
else
printf("RegOpenKeyEx() failed!\n");
RegCloseKey(hKey);
}
我对此很陌生,但是当我第一次运行程序时,它说目录已经全部创建但它们没有,当我再次运行它时,我得到错误183(已经存在)。
我真的不确定这里有什么问题。