• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            zhiye_wang

            向星空仰望的越深,越發(fā)現(xiàn)自己的渺小

              C++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              31 隨筆 :: 1 文章 :: 2 評(píng)論 :: 0 Trackbacks
             創(chuàng)建鍵 RegCreateKeyEx

              1 int SetRecordVideoSavedDays(int newSavedDays)
              2 {
              3     HKEY hSubKey = NULL;
              4     LONG lRet    = 0;
              5     DWORD dwType = 0;
              6     int iRet     = 0;
              7     
              8     do 
              9     {
             10         if (newSavedDays < 0)
             11         {
             12             printf("error: input negative number\n");
             13             break;
             14         }
             15         lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Cloudsoar 3C\\ServerInfo",
             16                                 0, NULL, REG_OPTION_NON_VOLATILE, 
             17                                 KEY_ALL_ACCESS, NULL, &hSubKey, NULL);       
             18         if (ERROR_SUCCESS != lRet)
             19         {
             20             printf("Create Reg failed\n");
             21             break;
             22         }
             23         
             24         lRet = RegSetValueEx(hSubKey, "VideoSavedDays"0, REG_DWORD, (BYTE*)&newSavedDays, sizeof(newSavedDays));
             25         if (ERROR_SUCCESS != lRet)
             26         {
             27             printf("Set reg value VideoSavedDays failed\n");
             28             break;
             29         }
             30         
             31         iRet = (int)newSavedDays;
             32     } while (0);
             33     
             34     if(NULL != hSubKey)
             35     {
             36         RegCloseKey(hSubKey);
             37         hSubKey = NULL;
             38     }
             39   
             40     
             41     return iRet;
             42 }
             43 
             44 // parameter1: out, save video saved path
             45 // parameter2: in, save path length
             46 BOOL GetRecordVideoSavedPath(char *pchPath,int pathBufLen)
             47 {
             48     HKEY hSubKey    = NULL;
             49     LONG lRet       = 0;
             50     DWORD dwType    = 0;
             51     DWORD dwPathLen = pathBufLen;
             52     BOOL bRet       = FALSE;
             53     
             54     do 
             55     {
             56         lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
             57                             "SOFTWARE\\Cloudsoar 3C\\ServerInfo",
             58                             0, KEY_READ, &hSubKey);
             59         if (ERROR_SUCCESS != lRet)
             60         {
             61             printf("Open reg value VideoSavedPath failed\n");
             62             break;
             63         }
             64         
             65         lRet = RegQueryValueEx(hSubKey, "VideoSavedPath"
             66                                 0&dwType, (LPBYTE)pchPath, &dwPathLen);
             67         if (ERROR_SUCCESS != lRet)
             68         {
             69             printf("Query reg value VideoSavedPath failed\n");
             70             break;
             71         }
             72         
             73         bRet = TRUE;
             74         
             75     } while (0);
             76     
             77     RegCloseKey(hSubKey);
             78   
             79     return bRet;
             80 }
             81 
             82 BOOL SetRecordVideoSavePath(char *pchNewPath)
             83 {
             84     HKEY hSubKey  = NULL;
             85     LONG lRet     = 0;
             86     DWORD dwType  = 0;
             87     DWORD dwState = 0;
             88     BOOL bRet     = FALSE;
             89 
             90     do 
             91     {
             92         if (NULL == pchNewPath)
             93         {
             94             printf("error: input negative new path\n");
             95             break;
             96         }
             97         lRet = RegCreateKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Cloudsoar 3C\\ServerInfo",
             98             0, NULL, REG_OPTION_NON_VOLATILE, 
             99             KEY_ALL_ACCESS, NULL, &hSubKey, &dwState);       
            100         if (ERROR_SUCCESS != lRet)
            101         {
            102             printf("Create Reg VideoSavedPath failed\n");
            103             break;
            104         }
            105         
            106         lRet = RegSetValueEx(hSubKey, "VideoSavedPath"0, REG_SZ, (PBYTE)pchNewPath, sizeof(pchNewPath));
            107         if (ERROR_SUCCESS != lRet)
            108         {
            109             printf("Set reg value VideoSavedPath failed\n");
            110             break;
            111         }
            112 
            113         bRet = TRUE;
            114     } while (0);
            115 
            116     RegCloseKey(hSubKey);
            117 
            118     return bRet;
            119 }

            函數(shù)原型
             1 LONG RegCreateKeyEx(
             2 HKEY hKey, // handle to open key
             3 LPCTSTR lpSubKey, // subkey name
             4 DWORD Reserved, // reserved
             5 LPTSTR lpClass, // class string
             6 DWORD dwOptions, // special options
             7 REGSAM samDesired, // desired security access
             8 LPSECURITY_ATTRIBUTES lpSecurityAttributes, // inheritance
             9 PHKEY phkResult, // key handle
            10 LPDWORD lpdwDisposition // disposition value buffer
            11 );
            參數(shù)說明
             1 hKey:   要打開鍵的句柄或以下預(yù)定義句柄
             2 HKEY_CLASSES_ROOT
             3 HKEY_CURRENT_USER
             4 HKEY_LOCAL_MACHINE
             5 HKEY_USERS
             6 lpSubKey:   指向一個(gè)用于定義子鍵路徑的字符串
             7 Reserved,dwOptions,samDesired:   置0
             8 lpClass,lpSecurityAttributes:   置NULL
             9 phkResult:   用于接收鍵句柄
            10 lpdwDisposition:   接收的相關(guān)信息,取值如下
            11 REG_CREATED_NEW_KEY   創(chuàng)建成功
            12 REG_OPENED_EXISTING_KEY    鍵已存在

            打開鍵 RegOpenKeyEx
            函數(shù)原型
            1 LONG RegOpenKeyEx(
            2     HKEY hKey, // handle to open key
            3     LPCTSTR lpSubKey, // subkey name
            4     DWORD ulOptions, // reserved
            5     REGSAM samDesired, // security access mask
            6     PHKEY phkResult // handle to open key
            7 );

            參數(shù)說明
            1 hKey:     要打開鍵的句柄或以下預(yù)定義句柄
            2 HKEY_CLASSES_ROOT
            3 HKEY_CURRENT_USER
            4 HKEY_LOCAL_MACHINE
            5 HKEY_USERS
            6 lpSubKey:   指向一個(gè)用于定義子鍵路徑的字符串
            7 ulOptions:   保留位,置0
            8 samDesired:   打開鍵后鍵的操作權(quán)限
            9 phResult:   接收打開的鍵的句柄

            修改/添加鍵值 RegSetValueEx
            函數(shù)原型
            1 LONG RegSetValueEx(
            2     HKEY hKey, // handle to key
            3     LPCTSTR lpValueName, // value name
            4     DWORD Reserved, // reserved
            5     DWORD dwType, // value type
            6     CONST BYTE *lpData, // value data
            7     DWORD cbData // size of value data
            8 );

            參數(shù)說明
             1 hKey:   打開鍵的句柄或以下預(yù)定義句柄
             2 HKEY_CLASSES_ROOT
             3 HKEY_CURRENT_USER
             4 HKEY_LOCAL_MACHINE
             5 HKEY_USERS
             6 lpValueName:   鍵值的名稱
             7 Reserved:   保留位,置0
             8 dwType:   鍵值的類型
             9 lpData:   鍵值
            10 cbData:   鍵值數(shù)據(jù)長(zhǎng)度
            posted on 2015-01-12 17:22 zhiye_wang 閱讀(153) 評(píng)論(0)  編輯 收藏 引用 所屬分類: windows
            一本综合久久国产二区| 久久www免费人成看片| 99久久无码一区人妻| 久久成人18免费网站| 久久99热这里只有精品国产| 久久精品国产亚洲AV嫖农村妇女| 国产精品一久久香蕉产线看| 久久伊人五月天论坛| 久久精品水蜜桃av综合天堂| 国产精品免费久久久久影院| 久久免费看黄a级毛片| 久久久精品波多野结衣| 久久无码人妻一区二区三区| 久久人搡人人玩人妻精品首页| 久久久久人妻一区精品| 久久国产亚洲高清观看| 久久男人AV资源网站| 久久国产精品国产自线拍免费| 久久午夜免费视频| 999久久久国产精品| 久久AV高清无码| 久久AV无码精品人妻糸列| 一本大道久久东京热无码AV | 久久国产精品成人影院| 久久噜噜久久久精品66| 亚洲午夜精品久久久久久人妖| 嫩草伊人久久精品少妇AV| 久久精品国产99国产精品亚洲| 久久久久亚洲精品无码网址| 久久精品国产亚洲沈樵| 久久精品国产秦先生| 久久青青草原国产精品免费| 久久A级毛片免费观看| 久久婷婷五月综合色高清| 日韩人妻无码精品久久久不卡 | 久久电影网2021| 国产精品18久久久久久vr| 日本久久久久久中文字幕| 久久久久久a亚洲欧洲aⅴ| 一本一道久久精品综合| 国产成人AV综合久久|