windows c++获取开机启动项

#include
#include
#include

#define RUN_LOCATION "Software\\Microsoft\\Windows\\CurrentVersion\\Run"

int main() {
    HKEY hKey;
    LONG result;

    // 打开注册表键
    result = RegOpenKeyExA(HKEY_CURRENT_USER, RUN_LOCATION, 0, KEY_READ, &hKey);
    if (result != ERROR_SUCCESS) {
        std::cout << "无法打开注册表项" << std::endl;
        return 1;
    }

    char valueName[255];
    char valueData[255];
    DWORD valueNameSize = sizeof(valueName);
    DWORD valueDataSize = sizeof(valueData);

    std::cout << "开机启动项列表:" << std::endl;

    // 枚举注册表项的值
    for (DWORD i = 0;; i++) {
        result = RegEnumValueA(hKey, i, valueName, &valueNameSize, NULL, NULL, (LPBYTE)valueData, &valueDataSize);

你可能感兴趣的:(c++,windows)