diff --git a/CcRemote/.vs/CcRemote/v15/.suo b/CcRemote/.vs/CcRemote/v15/.suo index 4aa1d74..491122d 100644 Binary files a/CcRemote/.vs/CcRemote/v15/.suo and b/CcRemote/.vs/CcRemote/v15/.suo differ diff --git a/StartDemo/.vs/StartDemo/v15/.suo b/StartDemo/.vs/StartDemo/v15/.suo new file mode 100644 index 0000000..95cea3b Binary files /dev/null and b/StartDemo/.vs/StartDemo/v15/.suo differ diff --git a/StartDemo/Debug/StartDemo.exe b/StartDemo/Debug/StartDemo.exe new file mode 100644 index 0000000..6983e21 Binary files /dev/null and b/StartDemo/Debug/StartDemo.exe differ diff --git a/StartDemo/StartDemo.sln b/StartDemo/StartDemo.sln new file mode 100644 index 0000000..7d18e38 --- /dev/null +++ b/StartDemo/StartDemo.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.1022 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StartDemo", "StartDemo\StartDemo.vcxproj", "{6BC6014B-5F66-4E3D-B4E6-38D68021CB7D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6BC6014B-5F66-4E3D-B4E6-38D68021CB7D}.Debug|x64.ActiveCfg = Debug|x64 + {6BC6014B-5F66-4E3D-B4E6-38D68021CB7D}.Debug|x64.Build.0 = Debug|x64 + {6BC6014B-5F66-4E3D-B4E6-38D68021CB7D}.Debug|x86.ActiveCfg = Debug|Win32 + {6BC6014B-5F66-4E3D-B4E6-38D68021CB7D}.Debug|x86.Build.0 = Debug|Win32 + {6BC6014B-5F66-4E3D-B4E6-38D68021CB7D}.Release|x64.ActiveCfg = Release|x64 + {6BC6014B-5F66-4E3D-B4E6-38D68021CB7D}.Release|x64.Build.0 = Release|x64 + {6BC6014B-5F66-4E3D-B4E6-38D68021CB7D}.Release|x86.ActiveCfg = Release|Win32 + {6BC6014B-5F66-4E3D-B4E6-38D68021CB7D}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {8DF98FBA-5DA4-49FA-9BC6-EFDD98E2CE5C} + EndGlobalSection +EndGlobal diff --git a/StartDemo/StartDemo/CRegOperate.cpp b/StartDemo/StartDemo/CRegOperate.cpp new file mode 100644 index 0000000..af1af0d --- /dev/null +++ b/StartDemo/StartDemo/CRegOperate.cpp @@ -0,0 +1,192 @@ +#include "CRegOperate.h" + + + +CRegOperate::CRegOperate(HKEY beginKey, TCHAR* path) +{ + + dwType = REG_BINARY | REG_DWORD | REG_EXPAND_SZ | REG_MULTI_SZ | REG_NONE | REG_SZ; + + + //Begin to get HKEY of path. + Query(beginKey, path); + + //test if queue is emptyԶǷΪ + while (!keystack.empty()) + { + + string newPath = keystack.front(); + + keystack.pop(); + + Query(beginKey, newPath.c_str()); + + } + + //Release. + RegCloseKey(beginKey); +} + + +CRegOperate::~CRegOperate() +{ + + +} + + + + +void CRegOperate::Query(HKEY rootKey, const char* path) + +{ + vecKeyName.clear(); + vecKeyName.reserve(200); + +#ifdef COMMAND_OUTPUT + + _tprintf(TEXT("\nProcess: %s :\n"), path); + +#endif + + HKEY hKey; + if (RegOpenKeyEx(rootKey, path, 0, KEY_READ, &hKey) != ERROR_SUCCESS) + { + RegCloseKey(hKey); + return; + } + + + + TCHAR achKey[MAX_KEY_LENGTH]; // buffer for subkey name + DWORD cbName; // size of name string + TCHAR achClass[MAX_PATH] = TEXT(""); // buffer for class name + DWORD cchClassName = MAX_PATH; // size of class string + DWORD cSubKeys = 0; // number of subkeys + DWORD cbMaxSubKey; // longest subkey size + DWORD cchMaxClass; // longest class string + DWORD cValues; // number of values for key + DWORD cchMaxValue; // longest value name + DWORD cbMaxValueData; // longest value data + DWORD cbSecurityDescriptor; // size of security descriptor + FILETIME ftLastWriteTime; // last write time + + DWORD i, retCode; + + + TCHAR achValue[MAX_VALUE_NAME]; + DWORD cchValue = MAX_VALUE_NAME; + + + // Get the class name and the value count. + + retCode = RegQueryInfoKey( + hKey, // key handle + achClass, // buffer for class name + &cchClassName, // size of class string + NULL, // reserved + &cSubKeys, // number of subkeys + &cbMaxSubKey, // longest subkey size + &cchMaxClass, // longest class string + &cValues, // number of values for this key + &cchMaxValue, // longest value name + &cbMaxValueData, // longest value data + &cbSecurityDescriptor, // security descriptor + &ftLastWriteTime); // last write time + + + + // Enumerate the subkeys, until RegEnumKeyEx fails. + + if (cSubKeys) + { + +#ifdef COMMAND_OUTPUT + + printf("Number of subkeys: %d\n", cSubKeys); + +#endif + + for (i = 0; i < cSubKeys; i++) + { + cbName = MAX_KEY_LENGTH; + + retCode = RegEnumKeyEx(hKey, i, + achKey, + &cbName, + NULL, + NULL, + NULL, + &ftLastWriteTime); + + if (retCode == ERROR_SUCCESS) + { + +#ifdef COMMAND_OUTPUT + + _tprintf(TEXT("(%d) %s\n"), i + 1, achKey); + +#endif + + //use achKey to build new path and input it into stack. + + std::string newPath = ""; + + newPath.append(path); + newPath.append("\\"); + newPath.append(achKey); + keystack.push(newPath); + + } + } + } + + // Enumerate the key values. + + if (cValues) + { +#ifdef COMMAND_OUTPUT + + printf("Number of values: %d\n", cValues); + +#endif + + for (i = 0, retCode = ERROR_SUCCESS; i < cValues; i++) + { + cchValue = MAX_VALUE_NAME; + + achValue[0] = '\0'; + + unsigned char vari[70]; + + retCode = RegEnumValue(hKey, i, + achValue, + &cchValue, + NULL, + NULL, + NULL, + NULL); + + if (retCode == ERROR_SUCCESS) + + { + std::string filePath = ""; + TCHAR szBuffer[255] = { 0 }; + DWORD dwNameLen = 255; + DWORD rQ = RegQueryValueEx(hKey, achValue, 0, &dwType, (LPBYTE)szBuffer, &dwNameLen); + + if (rQ == ERROR_SUCCESS) + { + filePath.append(szBuffer); + //ȡļֵvector + vecKeyName.push_back(filePath); + //_tprintf(TEXT("(%d) %s %s\n"), i + 1, achValue, szBuffer); + + } + } + } + } + //release. + RegCloseKey(hKey); +} + diff --git a/StartDemo/StartDemo/CRegOperate.h b/StartDemo/StartDemo/CRegOperate.h new file mode 100644 index 0000000..8dddde9 --- /dev/null +++ b/StartDemo/StartDemo/CRegOperate.h @@ -0,0 +1,33 @@ +#pragma once + + +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + + +class CRegOperate +{ +public: + CRegOperate(HKEY beginKey, TCHAR* path); + ~CRegOperate(); + +private: +#define MAX_KEY_LENGTH 255 +#define MAX_VALUE_NAME 16383 + + DWORD dwType; + queue keystack; + + //ѯֵ + void Query(HKEY rootKey, const char* path); +public: + vector vecKeyName; +}; + diff --git a/StartDemo/StartDemo/Debug/StartDemo.Build.CppClean.log b/StartDemo/StartDemo/Debug/StartDemo.Build.CppClean.log new file mode 100644 index 0000000..69a2289 --- /dev/null +++ b/StartDemo/StartDemo/Debug/StartDemo.Build.CppClean.log @@ -0,0 +1,13 @@ +f:\myapp\ccremote\startdemo\startdemo\debug\vc141.pdb +f:\myapp\ccremote\startdemo\startdemo\debug\vc141.idb +f:\myapp\ccremote\startdemo\startdemo\debug\startdemo.obj +f:\myapp\ccremote\startdemo\startdemo\debug\cregoperate.obj +f:\myapp\ccremote\startdemo\debug\startdemo.exe +f:\myapp\ccremote\startdemo\debug\startdemo.ilk +f:\myapp\ccremote\startdemo\debug\startdemo.pdb +f:\myapp\ccremote\startdemo\startdemo\debug\startdemo.tlog\cl.command.1.tlog +f:\myapp\ccremote\startdemo\startdemo\debug\startdemo.tlog\cl.read.1.tlog +f:\myapp\ccremote\startdemo\startdemo\debug\startdemo.tlog\cl.write.1.tlog +f:\myapp\ccremote\startdemo\startdemo\debug\startdemo.tlog\link.command.1.tlog +f:\myapp\ccremote\startdemo\startdemo\debug\startdemo.tlog\link.read.1.tlog +f:\myapp\ccremote\startdemo\startdemo\debug\startdemo.tlog\link.write.1.tlog diff --git a/StartDemo/StartDemo/Debug/StartDemo.log b/StartDemo/StartDemo/Debug/StartDemo.log new file mode 100644 index 0000000..a23be1c --- /dev/null +++ b/StartDemo/StartDemo/Debug/StartDemo.log @@ -0,0 +1,3 @@ + StartDemo.cpp +f:\myapp\ccremote\startdemo\startdemo\startdemo.cpp(35): warning C4018: “<”: 有符号/无符号不匹配 + StartDemo.vcxproj -> F:\myapp\CcRemote\StartDemo\Debug\StartDemo.exe diff --git a/StartDemo/StartDemo/Debug/StartDemo.tlog/StartDemo.lastbuildstate b/StartDemo/StartDemo/Debug/StartDemo.tlog/StartDemo.lastbuildstate new file mode 100644 index 0000000..06967ab --- /dev/null +++ b/StartDemo/StartDemo/Debug/StartDemo.tlog/StartDemo.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0 +Debug|Win32|F:\myapp\CcRemote\StartDemo\| diff --git a/StartDemo/StartDemo/Debug/cregoperate.obj.enc b/StartDemo/StartDemo/Debug/cregoperate.obj.enc new file mode 100644 index 0000000..f54566d Binary files /dev/null and b/StartDemo/StartDemo/Debug/cregoperate.obj.enc differ diff --git a/StartDemo/StartDemo/Debug/startdemo.obj.enc b/StartDemo/StartDemo/Debug/startdemo.obj.enc new file mode 100644 index 0000000..fc860a2 Binary files /dev/null and b/StartDemo/StartDemo/Debug/startdemo.obj.enc differ diff --git a/StartDemo/StartDemo/StartDemo.cpp b/StartDemo/StartDemo/StartDemo.cpp new file mode 100644 index 0000000..a69cc9a --- /dev/null +++ b/StartDemo/StartDemo/StartDemo.cpp @@ -0,0 +1,43 @@ + + +#include + +#include + +#include + +#include + +#include + +#include + +#include + + +#include "CRegOperate.h" + + +int _tmain(int argc, _TCHAR* argv[]) + +{ + + //64位注册表 + TCHAR N1path[] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"; + //32位注册表 + TCHAR N3path[] = "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run"; + + TCHAR N2path[] = "SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Run"; + //HKEY_CURRENT_USER + CRegOperate test_reg(HKEY_CURRENT_USER, N1path); + + + for (int i = 0; i < test_reg.vecKeyName.size(); i++) { + _tprintf(TEXT("%s\n"),test_reg.vecKeyName[i].c_str()); + } + + system("pause"); + + return 0; + +} diff --git a/StartDemo/StartDemo/StartDemo.vcxproj b/StartDemo/StartDemo/StartDemo.vcxproj new file mode 100644 index 0000000..b2c0efd --- /dev/null +++ b/StartDemo/StartDemo/StartDemo.vcxproj @@ -0,0 +1,167 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {6BC6014B-5F66-4E3D-B4E6-38D68021CB7D} + Win32Proj + StartDemo + 10.0.17763.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + + + Console + true + + + + + + + Level3 + Disabled + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + + + Console + true + + + + + + + Level3 + MaxSpeed + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + + + Console + true + true + true + + + + + + + Level3 + MaxSpeed + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreadedDebug + + + Console + true + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/StartDemo/StartDemo/StartDemo.vcxproj.filters b/StartDemo/StartDemo/StartDemo.vcxproj.filters new file mode 100644 index 0000000..07a4e36 --- /dev/null +++ b/StartDemo/StartDemo/StartDemo.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 源文件 + + + 源文件 + + + + + 头文件 + + + \ No newline at end of file diff --git a/StartDemo/StartDemo/StartDemo.vcxproj.user b/StartDemo/StartDemo/StartDemo.vcxproj.user new file mode 100644 index 0000000..be25078 --- /dev/null +++ b/StartDemo/StartDemo/StartDemo.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/StartDemo/StartDemo/x64/Debug/StartDemo.log b/StartDemo/StartDemo/x64/Debug/StartDemo.log new file mode 100644 index 0000000..431f3f0 --- /dev/null +++ b/StartDemo/StartDemo/x64/Debug/StartDemo.log @@ -0,0 +1,3 @@ + StartDemo.cpp +f:\myapp\ccremote\startdemo\startdemo\startdemo.cpp(205): warning C4101: “vari”: 未引用的局部变量 + StartDemo.vcxproj -> F:\myapp\CcRemote\StartDemo\x64\Debug\StartDemo.exe diff --git a/StartDemo/StartDemo/x64/Debug/StartDemo.tlog/StartDemo.lastbuildstate b/StartDemo/StartDemo/x64/Debug/StartDemo.tlog/StartDemo.lastbuildstate new file mode 100644 index 0000000..54fc19e --- /dev/null +++ b/StartDemo/StartDemo/x64/Debug/StartDemo.tlog/StartDemo.lastbuildstate @@ -0,0 +1,2 @@ +#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0 +Debug|x64|F:\myapp\CcRemote\StartDemo\| diff --git a/StartDemo/x64/Debug/StartDemo.exe b/StartDemo/x64/Debug/StartDemo.exe new file mode 100644 index 0000000..8ab543e Binary files /dev/null and b/StartDemo/x64/Debug/StartDemo.exe differ