程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> 注冊表Demo

注冊表Demo

編輯:C++入門知識

一、獲取安裝程序信息

 #include <windows.h>
 #include <iostream>
 #include <>
 #include <vector>
 
   
 
        strName;                
      strDisplayName;        
      strPublisher;        
      strVersion;            
      strDisPlayVersion;    
      strInstallLocation;    
  
  GetAppInfoA(HKEY hKey, LPCSTR lpszAppName, LPCSTR lpszKeyValueName,  &        
     iRet = RegOpenKeyExA(hKey, lpszAppName, , KEY_ALL_ACCESS, &      (iRet !=           -  
     DWORD dwKeyValueType =     DWORD dwKeyValueDataSize =  
     iRet = RegQueryValueExA(hInstallAppKey, lpszKeyValueName, NULL, &dwKeyValueType, NULL, &      (iRet ==                    (iRet !=            -  
      (dwKeyValueType !=              
     LPSTR lpszKeyValueData =  [dwKeyValueDataSize +      memset(lpszKeyValueData, , dwKeyValueDataSize +  
     iRet = RegQueryValueExA(hInstallAppKey, lpszKeyValueName, NULL, &dwKeyValueType, (LPBYTE)lpszKeyValueData, &      (iRet !=             -  
     strKeyValue =   
        
  GetAllInstalledAppInfoA(vector<ApplicationInfoA> &            LPCSTR lpszSubKey =      iRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, lpszSubKey, , KEY_ALL_ACCESS, &      (iRet !=           -  
      
     iRet =             &         &          &         &         &        (iRet !=            -  
      DWORD dwNameLen = dwMaxSubKeyNameLen +      LPSTR lpszSubKeyName =   
      (dwIndex = ; dwIndex < dwSubKeysCnt; ++          dwNameLen = dwMaxSubKeyNameLen +          memset(lpszSubKeyName,  
         iRet = RegEnumKeyExA(hKey, dwIndex, lpszSubKeyName, &          (iRet !=                 -  
          appInfo.strName =         GetAppInfoA(hKey, lpszSubKeyName,          GetAppInfoA(hKey, lpszSubKeyName,          GetAppInfoA(hKey, lpszSubKeyName,          GetAppInfoA(hKey, lpszSubKeyName,          GetAppInfoA(hKey, lpszSubKeyName,    
   
        
  main( argc,  **      cout <<  << 
     vector<ApplicationInfoA>     cout << GetAllInstalledAppInfoA(vecAppInfo) << 
      (vector<ApplicationInfoA>::const_iterator iter = vecAppInfo.begin(); iter != vecAppInfo.end(); ++          cout <<  <<         cout <<  << iter->strName <<         cout <<  << iter->strDisplayName <<         cout <<  << iter->strPublisher <<         cout <<  << iter->strVersion <<         cout <<  << iter->strDisPlayVersion <<         cout <<  << iter->strInstallLocation <<         cout <<  <<         cout <<         cout <<      
       }

二、添加環境變量

  _CRT_SECURE_NO_WARNINGS
 
 #include <windows.h>
 #include <iostream>
 #include <>
 
   
             LPCSTR lpszSubKey =  
     iRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, lpszSubKey, , KEY_ALL_ACCESS, &      (ERROR_SUCCESS !=          cout <<  <<          -  
     LPCSTR lpszKeyValueName =      DWORD dwKeyValueType =     DWORD dwKeyValueDataSize =  
     iRet = RegQueryValueExA(hKey, lpszKeyValueName, NULL, &dwKeyValueType, NULL, &      (ERROR_FILE_NOT_FOUND !=          iRet = RegSetValueExA(hKey, lpszKeyValueName, , REG_EXPAND_SZ, ( BYTE*),           (ERROR_SUCCESS !=              cout <<  <<               -         (ERROR_SUCCESS !=          cout <<  <<           -        (REG_EXPAND_SZ !=          cout <<  <<         cout << dwKeyValueType <<           -  
      *lpszKeyValueData =  [dwKeyValueDataSize +      memset(lpszKeyValueData, , dwKeyValueDataSize +  
     iRet = RegQueryValueExA(hKey, lpszKeyValueName, NULL, &dwKeyValueType, (LPBYTE)lpszKeyValueData, &      (ERROR_SUCCESS !=          cout <<  <<            -  
     unsigned  iLen =     iLen +=      *lpszKeyValueData_New =  [iLen +      memset(lpszKeyValueData_New, , iLen +      sprintf(lpszKeyValueData_New,      iRet = RegSetValueExA(hKey, lpszKeyValueName, , REG_EXPAND_SZ, ( BYTE*)lpszKeyValueData_New, iLen +       (ERROR_SUCCESS !=          cout <<  <<             -  
   
  
        
  main( argc,  *      cout << AddPathEnvValue() <<       }

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved