diff --git a/images/.keep b/images/.keep new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/images/1.png b/images/1.png new file mode 100644 index 0000000000000000000000000000000000000000..01adb52e7002d5bf92c12d942d6439b193762ac7 Binary files /dev/null and b/images/1.png differ diff --git a/images/10.png b/images/10.png new file mode 100644 index 0000000000000000000000000000000000000000..fb60778c134f2b00c15b5f77c171da8cbcb6b88e Binary files /dev/null and b/images/10.png differ diff --git a/images/11.25.1.png b/images/11.25.1.png new file mode 100644 index 0000000000000000000000000000000000000000..8f99ba130b146a369314ebce5792cbc0293cba8b Binary files /dev/null and b/images/11.25.1.png differ diff --git a/images/11.25.2.png b/images/11.25.2.png new file mode 100644 index 0000000000000000000000000000000000000000..bb4816082b30660b6a79c149bf0396608c8de2a2 Binary files /dev/null and b/images/11.25.2.png differ diff --git a/images/11.25.3.png b/images/11.25.3.png new file mode 100644 index 0000000000000000000000000000000000000000..9afa6461f00ae485b81845f1c24ade70ba4df085 Binary files /dev/null and b/images/11.25.3.png differ diff --git a/images/11.25.4.png b/images/11.25.4.png new file mode 100644 index 0000000000000000000000000000000000000000..bda936f4a6c04753fcb1536f15c880285e359e2a Binary files /dev/null and b/images/11.25.4.png differ diff --git a/images/11.25.5.png b/images/11.25.5.png new file mode 100644 index 0000000000000000000000000000000000000000..cfa0c62d4616e5e8758017f63e0194b837badba3 Binary files /dev/null and b/images/11.25.5.png differ diff --git a/images/11.25.6.png b/images/11.25.6.png new file mode 100644 index 0000000000000000000000000000000000000000..b71660bd22b8afd48fcf8bc0b9a900d5db491eb6 Binary files /dev/null and b/images/11.25.6.png differ diff --git a/images/11.png b/images/11.png new file mode 100644 index 0000000000000000000000000000000000000000..e878c07489e78245b58549b0c4f0ad61b1453b3d Binary files /dev/null and b/images/11.png differ diff --git a/images/12.png b/images/12.png new file mode 100644 index 0000000000000000000000000000000000000000..f95a2793a037a13b3778ed37fdc002bf1c74219a Binary files /dev/null and b/images/12.png differ diff --git a/images/13.png b/images/13.png new file mode 100644 index 0000000000000000000000000000000000000000..07783de1e0ca1cb2d38ed767902f2d6552c574d6 Binary files /dev/null and b/images/13.png differ diff --git a/images/14.png b/images/14.png new file mode 100644 index 0000000000000000000000000000000000000000..184fd066d14c7586e0575f49dfb3a22b07b70332 Binary files /dev/null and b/images/14.png differ diff --git a/images/15.png b/images/15.png new file mode 100644 index 0000000000000000000000000000000000000000..381d7e333eb5fc010996bcf6915fbdaf8dcfc4d6 Binary files /dev/null and b/images/15.png differ diff --git a/images/16.png b/images/16.png new file mode 100644 index 0000000000000000000000000000000000000000..c80bfd38df6e5c99a490ffc6f71a50981c643914 Binary files /dev/null and b/images/16.png differ diff --git a/images/17.png b/images/17.png new file mode 100644 index 0000000000000000000000000000000000000000..0bbd7f71ec9830c6a897ea5611383605bd52a7f7 Binary files /dev/null and b/images/17.png differ diff --git a/images/2.png b/images/2.png new file mode 100644 index 0000000000000000000000000000000000000000..510f452aceaab335e9a9c8dc5049a9a9622394bf Binary files /dev/null and b/images/2.png differ diff --git a/images/3.png b/images/3.png new file mode 100644 index 0000000000000000000000000000000000000000..6c1862dcb4ccee0ebcc8c019fc78035837342bd5 Binary files /dev/null and b/images/3.png differ diff --git a/images/4.png b/images/4.png new file mode 100644 index 0000000000000000000000000000000000000000..fc32cea95825e2050463d84e9da8d63ddf5b470e Binary files /dev/null and b/images/4.png differ diff --git a/images/5.png b/images/5.png new file mode 100644 index 0000000000000000000000000000000000000000..5e34cf12243ad37ac715d510939d88476c29d07f Binary files /dev/null and b/images/5.png differ diff --git a/images/6.png b/images/6.png new file mode 100644 index 0000000000000000000000000000000000000000..3778b442e4e7c9ed2ed1ff765cb8c9b8895e449b Binary files /dev/null and b/images/6.png differ diff --git a/images/7.png b/images/7.png new file mode 100644 index 0000000000000000000000000000000000000000..9b644bb3788b228a796864877a4011abbab9d5fa Binary files /dev/null and b/images/7.png differ diff --git a/images/8.png b/images/8.png new file mode 100644 index 0000000000000000000000000000000000000000..8b895df08123e60a0a6725ffe079f77d6ba3c8ea Binary files /dev/null and b/images/8.png differ diff --git a/images/9.png b/images/9.png new file mode 100644 index 0000000000000000000000000000000000000000..1819ed2c7958150144f4a7215f70690c1d504f0b Binary files /dev/null and b/images/9.png differ diff --git a/images/image.png b/images/image.png new file mode 100644 index 0000000000000000000000000000000000000000..42ca3ece7a7f5ce23e5cc87e38d81211754d510f Binary files /dev/null and b/images/image.png differ diff --git a/lab_2_7.md b/lab_2_7.md new file mode 100644 index 0000000000000000000000000000000000000000..765968040f4a467127e27479dac17d9c4d5cade0 --- /dev/null +++ b/lab_2_7.md @@ -0,0 +1,69 @@ +# 注册表结构和注册表值类型 + + + + + +*** + +## 1 结构 + +包含关于一个注册表值的信息。列表中的RegQueryMultipleValues函数使用此结构。 + +```cpp +typedef struct value_entW { + LPWSTR ve_valuename; + DWORD ve_valuelen; + DWORD_PTR ve_valueptr; + DWORD ve_type; +} VALENTW, *PVALENTW; +``` + +**ve_valuename** +要检索的值的名称。请确保在调用RegQueryMultipleValues之前设置此成员然后再调用RegQueryMultipleValues。 + +**ve_valuelen** +ve_valueptr所指向的数据的大小,以字节为单位。 + +**ve_valueptr** +一个指向值输入数据的指针。这是一个指针,指向在lpValueBuf缓冲区中返回的值的数据的指针,由RegQueryMultipleValues填写的缓冲区中的值的指针。 + +**ve_type** +ve_valueptr所指向的数据类型。关于可能的类型列表可能的类型,请看注册表值类型。 + + +## 2 值的类型 + +下面的例子是走一个REG_MULTI_SZ字符串。 +```cpp +#include +#include +#include + +void SampleSzz(PTSTR pszz) +{ + _tprintf(_TEXT("\tBegin multi-sz string\n")); + while (*pszz) + { + _tprintf(_TEXT("\t\t%s\n"), pszz); + pszz = pszz + _tcslen(pszz) + 1; + } + _tprintf(_TEXT("\tEnd multi-sz\n")); +} + +int __cdecl main(int argc, char **argv) +{ + // Because the compiler adds a \0 at the end of quoted strings, + // there are two \0 terminators at the end. + + _tprintf(_TEXT("Conventional multi-sz string:\n")); + SampleSzz(_TEXT("String1\0String2\0String3\0LastString\0")); + + _tprintf(_TEXT("\nTest case with no strings:\n")); + SampleSzz(_TEXT("")); + + return 0; +} +``` + + diff --git a/lab_2_8.md b/lab_2_8.md new file mode 100644 index 0000000000000000000000000000000000000000..44e7bcec6246e93dcac9073569eb7544190a3090 --- /dev/null +++ b/lab_2_8.md @@ -0,0 +1,122 @@ +# 枚举注册表子键 + + + + +*** + +这个经验样本使用RegQueryInfoKey、RegEnumKeyEx,和RegEnumValue函数来列举指定键的子键。传递给每个函数的hKey参数是一个打开的钥匙的句柄。这个键必须在函数调用前被打开调用之前打开之后关闭。 + +```cpp +// QueryKey - 枚举键的子键及其相关值。 +// hKey - 要列举其子键和值的键。 + +#include +#include +#include + +#define MAX_KEY_LENGTH 255 +#define MAX_VALUE_NAME 16383 + +void QueryKey(HKEY hKey) +{ + TCHAR achKey[MAX_KEY_LENGTH]; // 子键名称的缓冲区 + DWORD cbName; // 名称字符串的大小 + TCHAR achClass[MAX_PATH] = TEXT(""); // 类名的缓冲区 + DWORD cchClassName = MAX_PATH; // 类字符串的大小 + DWORD cSubKeys=0; // 子密钥的数量 + DWORD cbMaxSubKey; // 最大的子键尺寸 + DWORD cchMaxClass; // 最长级别的字符串 + DWORD cValues; // 键值的数量 + DWORD cchMaxValue; // 最长的值名称 + DWORD cbMaxValueData; // 最长值数据 + DWORD cbSecurityDescriptor; // 安全描述符的大小 + FILETIME ftLastWriteTime; // 最后写入时间 + + DWORD i, retCode; + + TCHAR achValue[MAX_VALUE_NAME]; + DWORD cchValue = MAX_VALUE_NAME; + + // 获取类的名称和值的数量。 + retCode = RegQueryInfoKey( + hKey, // 钥匙柄 + achClass, // 类名的缓冲区 + &cchClassName, // 类字符串的大小 + NULL, // 保留 + &cSubKeys, // 子密钥的数量 + &cbMaxSubKey, // 最长的子键尺寸 + &cchMaxClass, // 最长级别的字符串 + &cValues, // 这个键的值的数量 + &cchMaxValue, // 最长的值名称 + &cbMaxValueData, // 最长值数据 + &cbSecurityDescriptor, //安全描述符 + &ftLastWriteTime); // 最后写作时间 + + //枚举子键,直到RegEnumKeyEx失败。 + + if (cSubKeys) + { + printf( "\nNumber of subkeys: %d\n", cSubKeys); + + for (i=0; i