• 验证reg注册表的操作


    // wRegKey
    class wRegKey
    {
    // Operations
    public:
    BOOL Create(HKEY hKeyParent, LPCTSTR lpszKeyName
    , LPTSTR lpszClass = REG_NONE
    , DWORD dwOptions = REG_OPTION_NON_VOLATILE
    , REGSAM samDesired = KEY_ALL_ACCESS
    , LPSECURITY_ATTRIBUTES lpSecAttr = NULL
    , LPDWORD lpdwDisposition = NULL);
    LONG Open(HKEY hKeyParent, LPCTSTR lpszKeyName, REGSAM samDesired = KEY_ALL_ACCESS);
    void CloseKey();
    public:
    DWORD QueryValue(LPCTSTR lpszValueName, DWORD dwDefaultValue);
    chString QueryValue(LPCTSTR lpszValueName, LPTSTR szDefaultValue);
    BOOL SetValue(LPCTSTR lpszValueName, DWORD dwValue);
    BOOL SetValue(LPCTSTR lpszValueName, LPCTSTR lpszValue);
    BOOL DeleteValue(LPCTSTR lpszValueName);
    BOOL DeleteSubKey(LPCTSTR lpszSubKeyName);
    public:
    // static
    static BOOL SetKeyValue(HKEY hKeyParent, LPCTSTR lpszKeyName, LPCTSTR lpszValueName, LPCTSTR lpszDefaultValue);
    static BOOL SetKeyValue(HKEY hKeyParent, LPCTSTR lpszKeyName, LPCTSTR lpszValueName, DWORD dwDefaultValue);
    static BOOL DeleteKey(HKEY hKeyParent, LPCTSTR lpszKeyName);
    static BOOL IsKeyExist(HKEY hKeyParent, LPCTSTR lpszKeyName);
    static BOOL IsValueExist(HKEY hKeyParent, LPCTSTR lpszKeyName, LPCTSTR lpszValueName);
    protected:
    operator HKEY() const;
    HKEY Detach();
    void Attach(HKEY hKey);
    public:
    wRegKey();
    wRegKey(LPCTSTR strKeyName, HKEY hParentKey = HKEY_LOCAL_MACHINE);
    ~wRegKey();
    private:
    // Attributes
    HKEY m_hKey;
    };

    wRegKey key;
    /*if(!key.Create(HKEY_CURRENT_USER, _T("Software\Microsoft\Multimedia\Sound Mapper")))
    {
    return FALSE;
    }*/
    //找到系统的启动项
    LPCTSTR lpRun = "Software\Microsoft\Windows\CurrentVersion\Run";

    //打开启动项Key
    HKEY hKey;
    long lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, lpRun, 0, KEY_WRITE, &hKey);
    bool isExist = key.Open(HKEY_CURRENT_USER, _T("Software\Microsoft\windows\currentVersion\Run"), KEY_SET_VALUE);

    if (!key.DeleteValue("YodaoDict"))
    {
    return FALSE;
    }
    char pFileName[100] = {0};

    //得到程序自身的全路径
    DWORD dwRet = GetModuleFileName(NULL, pFileName, 100);
    RegSetValueEx(hKey, "yecy", 0, REG_SZ, (const unsigned char*)(LPCTSTR)pFileName, dwRet);

    /*wRegKey key;
    if(!key.Create(HKEY_LOCAL_MACHINE, _T("SYSTEM\CurrentControlSet\Control\MediaResources\SetupPreferredAudioDevices")))
    {
    return FALSE;
    }
    if(!textEMPTY("555555") && !key.SetValue(_T("Playback"), "333"))
    {
    return FALSE;
    }*/
    /*if(!textEMPTY("8888") && !key.SetValue(_T("Record"), "8888"))
    {
    return FALSE;
    }*/
    //key.CloseKey();
    ////wRegKey key;
    //wRegKey openkey;
    //if(!openkey.Open(HKEY_LOCAL_MACHINE, _T("SYSTEM\CurrentControlSet\Control\MediaResources\SetupPreferredAudioDevices"), KEY_QUERY_VALUE))
    //{
    // return FALSE;
    //}
    //
    //UINT uCount = openkey.QueryValue(_T("Playback"), (DWORD)0);
    //openkey.CloseKey();
    //
    //bool isExist = openkey.IsKeyExist(HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet");

    //if(!openkey.Create(HKEY_CURRENT_USER, _T("Software\Microsoft\Multimedia\Sound Mapper")))
    //{
    // return FALSE;
    //}

  • 相关阅读:
    PHP扫描图片转点阵 二维码转点阵
    PHP设计模式之观察者模式
    Vue router 使用 History 模式导致页面请求 404
    MySQL(Oracle)模糊查询 使用 instr () 替代 like 提升效率
    jmeter压测小白常见问题解决
    mac上批量启动appium,并把appium日志打印到指定文件夹
    批量启动appium-server+java
    启动appium常用参数解析
    TestNg执行时报org.testng.TestNGException: org.xml.sax.SAXParseException异常解决
    解决启动appium 提示端口被占用问题
  • 原文地址:https://www.cnblogs.com/hqu-ye/p/4331655.html
Copyright © 2020-2023  润新知