枚举注册表

1.工程类型:IS2010 installscript

2.目的:枚举注册表中donet版本,如果注册表中存在的版本与要检测的版本一致,就返回true,否则返回false.

3.具体实现:


function BOOL LISTDonetVer(DefineVer)
  STRING   InstallVer,SPVer;
  LIST   listID;
  STRING nzItem, szSubKey,svString; 
  NUMBER nResult,nReturn, nItem,nvType,nvSize;
  LIST   listSubKeys, listNames;

begin
   listSubKeys = ListCreate(STRINGLIST);
      listNames = ListCreate(STRINGLIST);
      RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
      szSubKey = "SOFTWARE\\Microsoft\\NET Framework Setup\\NDP";
      nReturn = RegDBQueryKey ( szSubKey, REGDB_KEYS, listSubKeys );
     if (nReturn >=0) then
       nResult = ListGetFirstString (listSubKeys, svString);
      // Loop while list items continue to be retrieved.
          while (nResult != END_OF_LIST)
          // Get the next string in the list.
             nResult = ListGetNextString (listSubKeys, svString);
               if(svString=DefineVer)then
                 szSubKey=szSubKey+"\\"+svString;
                 RegDBGetKeyValueEx (szSubKey, "Install", nvType, InstallVer, nvSize);
                 RegDBGetKeyValueEx (szSubKey, "SP", nvType, SPVer, nvSize);
                if( StrCompare(InstallVer,"1")=0)&&(StrCompare(SPVer,"1")>=0) then
                      return  TRUE;
              else
                      return  FALSE;
   
               endif;
           endif; 
        endwhile;
 
     endif;
end;

posted on 2011-09-21 21:17  奕婷  阅读(508)  评论(2编辑  收藏  举报