<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=37408&amp;view=findpost&amp;p=241963</guid>
        <pubDate>Sun, 24 Feb 2002 13:33:48 +0000</pubDate>
        <title>реестр</title>
        <link>https://forum.sources.ru/index.php?showtopic=37408&amp;view=findpost&amp;p=241963</link>
        <description><![CDATA[Stiff: А вообще вот пример <br><br><br>The following example demonstrates the use of the RegQueryInfoKey, RegEnumKey, and RegEnumValue functions. The hKey parameter passed to each function is a handle to an open key. This key must be opened before the function call and closed afterward. <br><br>// QueryKey - enumerates the subkeys of a given key and the associated <br>// &nbsp; &nbsp;values and then copies the information about the keys and values <br>// &nbsp; &nbsp;into a pair of edit controls and list boxes. <br>// hDlg - dialog box that contains the edit controls and list boxes <br>// hKey - key whose subkeys and values are to be enumerated <br> <br>VOID QueryKey(HWND hDlg, HANDLE hKey) <br>{ <br> &nbsp; &nbsp;CHAR &nbsp; &nbsp; achKey[MAX_PATH]; <br> &nbsp; &nbsp;CHAR &nbsp; &nbsp; achClass[MAX_PATH] = &quot;&quot;; &nbsp;// buffer for class name <br> &nbsp; &nbsp;DWORD &nbsp; &nbsp;cchClassName = MAX_PATH; &nbsp;// length of class string <br> &nbsp; &nbsp;DWORD &nbsp; &nbsp;cSubKeys; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // number of subkeys <br> &nbsp; &nbsp;DWORD &nbsp; &nbsp;cbMaxSubKey; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// longest subkey size <br> &nbsp; &nbsp;DWORD &nbsp; &nbsp;cchMaxClass; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// longest class string <br> &nbsp; &nbsp;DWORD &nbsp; &nbsp;cValues; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// number of values for key <br> &nbsp; &nbsp;DWORD &nbsp; &nbsp;cchMaxValue; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// longest value name <br> &nbsp; &nbsp;DWORD &nbsp; &nbsp;cbMaxValueData; &nbsp; &nbsp; &nbsp; // longest value data <br> &nbsp; &nbsp;DWORD &nbsp; &nbsp;cbSecurityDescriptor; // size of security descriptor <br> &nbsp; &nbsp;FILETIME ftLastWriteTime; &nbsp; &nbsp; &nbsp;// last write time <br> <br> &nbsp; &nbsp;DWORD i, j; <br> &nbsp; &nbsp;DWORD retCode, retValue; <br> <br> &nbsp; &nbsp;CHAR &nbsp;achValue[MAX_VALUE_NAME]; <br> &nbsp; &nbsp;DWORD cchValue = MAX_VALUE_NAME; <br> &nbsp; &nbsp;CHAR &nbsp;achBuff[80]; <br> <br> &nbsp; &nbsp;// Get the class name and the value count. <br> &nbsp; &nbsp;RegQueryInfoKey(hKey, &nbsp; &nbsp; &nbsp; &nbsp;// key handle <br> &nbsp; &nbsp; &nbsp; &nbsp;achClass, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// buffer for class name <br> &nbsp; &nbsp; &nbsp; &nbsp;&amp;cchClassName, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // length of class string <br> &nbsp; &nbsp; &nbsp; &nbsp;NULL, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// reserved <br> &nbsp; &nbsp; &nbsp; &nbsp;&amp;cSubKeys, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // number of subkeys <br> &nbsp; &nbsp; &nbsp; &nbsp;&amp;cbMaxSubKey, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// longest subkey size <br> &nbsp; &nbsp; &nbsp; &nbsp;&amp;cchMaxClass, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// longest class string <br> &nbsp; &nbsp; &nbsp; &nbsp;&amp;cValues, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// number of values for this key <br> &nbsp; &nbsp; &nbsp; &nbsp;&amp;cchMaxValue, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// longest value name <br> &nbsp; &nbsp; &nbsp; &nbsp;&amp;cbMaxValueData, &nbsp; &nbsp; &nbsp; &nbsp; // longest value data <br> &nbsp; &nbsp; &nbsp; &nbsp;&amp;cbSecurityDescriptor, &nbsp; // security descriptor <br> &nbsp; &nbsp; &nbsp; &nbsp;&amp;ftLastWriteTime); &nbsp; &nbsp; &nbsp; // last write time <br> <br> &nbsp; &nbsp;SetDlgItemText(hDlg, IDE_CLASS, achClass); <br> &nbsp; &nbsp;SetDlgItemInt(hDlg, IDE_CVALUES, cValues, FALSE); <br> <br> &nbsp; &nbsp;SendMessage(GetDlgItem(hDlg, IDL_LISTBOX), <br> &nbsp; &nbsp; &nbsp; &nbsp;LB_ADDSTRING, 0, (LONG) &quot;..&quot;); <br> <br> &nbsp; &nbsp;// Enumerate the child keys, looping until RegEnumKey fails. Then <br> &nbsp; &nbsp;// get the name of each child key and copy it into the list box. <br><br> &nbsp; &nbsp;SetCursor(LoadCursor(NULL, IDC_WAIT)); <br> &nbsp; &nbsp;for (i = 0, retCode = ERROR_SUCCESS; <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;retCode == ERROR_SUCCESS; i++) <br> &nbsp; &nbsp;{ <br> &nbsp; &nbsp; &nbsp; &nbsp;retCode = RegEnumKey(hKey, i, achKey, MAX_PATH); <br> &nbsp; &nbsp; &nbsp; &nbsp;if (retCode == (DWORD)ERROR_SUCCESS) <br> &nbsp; &nbsp; &nbsp; &nbsp;{<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(GetDlgItem(hDlg, IDL_LISTBOX), <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LB_ADDSTRING, 0, (LONG) achKey); <br> &nbsp; &nbsp; &nbsp; &nbsp;}<br> &nbsp; &nbsp;} <br> &nbsp; &nbsp;SetCursor(LoadCursor (NULL, IDC_ARROW)); <br> <br> &nbsp; &nbsp;// Enumerate the key values. <br> &nbsp; &nbsp;SetCursor(LoadCursor(NULL, IDC_WAIT)); <br> <br> &nbsp; &nbsp;if (cValues) <br> &nbsp; &nbsp;{<br> &nbsp; &nbsp; &nbsp; &nbsp;for (j = 0, retValue = ERROR_SUCCESS; <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;j &lt; cValues; j++) <br> &nbsp; &nbsp; &nbsp; &nbsp;{ <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cchValue = MAX_VALUE_NAME; <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;achValue[0] = '{text}'; <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;retValue = RegEnumValue(hKey, j, achValue, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&amp;cchValue, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NULL, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NULL, &nbsp; &nbsp;// &amp;dwType, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NULL, &nbsp; &nbsp;// &amp;bData, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;NULL); &nbsp; // &amp;bcData <br> <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (retValue != (DWORD) ERROR_SUCCESS &amp;&amp; <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;retValue != ERROR_INSUFFICIENT_BUFFER) <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{ <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wsprintf (achBuff, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&quot;Line:\%d 0 based index = \%d, retValue = \%d, &quot; <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &quot;ValueLen = \%d&quot;, <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; __LINE__, j, retValue, cchValue); <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MessageBox (hDlg, achBuff, &quot;Debug&quot;, MB_OK); <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;} <br> <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;achBuff[0] = '{text}'; <br> <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Add each value to a list box. <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (!lstrlen(achValue)) <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;lstrcpy(achValue, &quot;&lt;NO NAME&gt;&quot;); <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;wsprintf(achBuff, &quot;\%d) \%s &quot;, j, achValue); <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(GetDlgItem(hDlg,IDL_LISTBOX2), <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LB_ADDSTRING, 0, (LONG) achBuff); <br> &nbsp; &nbsp; &nbsp; &nbsp;} <br> <br> &nbsp; &nbsp;SetCursor(LoadCursor(NULL, IDC_ARROW)); <br>} <br>Microsoft Platform SDK, February 2001 Edition.<br>This content last built on Thursday, February 01, 2001.<br>]]></description>
        <author>Stiff</author>
        <category>Visual C++ / MFC / WTL</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=37408&amp;view=findpost&amp;p=241962</guid>
        <pubDate>Sun, 24 Feb 2002 13:08:15 +0000</pubDate>
        <title>реестр</title>
        <link>https://forum.sources.ru/index.php?showtopic=37408&amp;view=findpost&amp;p=241962</link>
        <description><![CDATA[Stiff: А когда во второй раз вызываешь ф-ию опять выдает ошибку &quot;More data is availible&quot;]]></description>
        <author>Stiff</author>
        <category>Visual C++ / MFC / WTL</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=37408&amp;view=findpost&amp;p=241961</guid>
        <pubDate>Sun, 24 Feb 2002 12:44:51 +0000</pubDate>
        <title>реестр</title>
        <link>https://forum.sources.ru/index.php?showtopic=37408&amp;view=findpost&amp;p=241961</link>
        <description><![CDATA[Stiff: Читай SDK<br><br>dwIndex : <br>[in] Specifies the index of the value to retrieve. This parameter should be zero for the first call to the RegEnumValue function and then be incremented for subsequent calls. <br><br>Понял ??? <br>Нет ??? Тогда &nbsp; int index = 0; индекс д. б. = 0 когда ты первый раз вызываешь ф-ию RegEnumValue <br>У меня работает !<br>]]></description>
        <author>Stiff</author>
        <category>Visual C++ / MFC / WTL</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=37408&amp;view=findpost&amp;p=241960</guid>
        <pubDate>Sun, 24 Feb 2002 11:28:27 +0000</pubDate>
        <title>реестр</title>
        <link>https://forum.sources.ru/index.php?showtopic=37408&amp;view=findpost&amp;p=241960</link>
        <description><![CDATA[delitant: Программа открывает HKEY_CURRENT_USER\Software<br>Если там нет раздела Sms то она создает его, плюс, создает несколько параметров и записывает в них данные. И заканчивает свою работу. <br>При следующем запуске раздел Sms уже создан. И программа ПЫТАЕТСЯ прочесть данные в этом разделе. И вот ту начинается полная лажа. Плиз если не сложно  откомпилируйте и посмотрите. Также есть другая проблема при чтении данных. Этот участок кода я закомментировал (как получить прочесть число) так как он дает переполнение буфера. Заранее благодарен за помощь.   <br><br>#include &lt;windows.h&gt;<br>#include &lt;iostream.h&gt;<br>main()<br>{<br>      HKEY hKey,hKey2;<br>      DWORD s = 5, n = 200;<br>      DWORD Disp = REG_OPENED_EXISTING_KEY;<br>      char *from = new char[128];<br>      char *to = new char[128];<br>      char *buf = new char[128];<br>long lnRes = RegOpenKeyEx(HKEY_CURRENT_USER,&quot;Software&quot;,0,KEY_ALL_ACCESS,&amp;hKey);<br>      if( lnRes != ERROR_SUCCESS )  return 0;<br>      lnRes = RegOpenKeyEx(hKey,&quot;Sms&quot;,0,KEY_ALL_ACCESS,&amp;hKey2);<br>      if( lnRes == ERROR_SUCCESS )<br>      {<br>            int index = 1;<br>            DWORD l = 128;<br>            UINT number, sleep;<br>            RegEnumValue(hKey2,index,buf,&amp;l,0l,NULL,(unsigned char *)from,&amp;l);<br>            cout&lt;&lt;index&lt;&lt;&quot; : &quot;&lt;&lt;buf&lt;&lt;&quot;\t&quot;&lt;&lt;from&lt;&lt;&quot;\n&quot;;<br>            ZeroMemory( buf,128 );<br>            index++;<br>            RegEnumValue(hKey2,index,buf,&amp;l,0l,NULL,(unsigned char *)to,&amp;l);<br>            cout&lt;&lt;index&lt;&lt;&quot; : &quot;&lt;&lt;buf&lt;&lt;&quot;\t&quot;&lt;&lt;to&lt;&lt;&quot;\n&quot;;<br>            ZeroMemory( buf,128 );<br>/*            l = sizeof(int);<br>            index++;<br>            RegEnumValue(hKey2,index,buf,&amp;l,0l, NULL,(unsigned char *)number,&amp;l);<br>            cout&lt;&lt;index&lt;&lt;&quot; : &quot;&lt;&lt;buf&lt;&lt;&quot;\t&quot;&lt;&lt;number&lt;&lt;&quot;\n&quot;;<br>            ZeroMemory( buf,128 );<br>            index++;<br>            RegEnumValue(hKey2,index,buf,&amp;l,0l, NULL,(unsigned char *)sleep,&amp;l);<br>            cout&lt;&lt;index&lt;&lt;&quot; : &quot;&lt;&lt;buf&lt;&lt;&quot;\t&quot;&lt;&lt;sleep&lt;&lt;&quot;\n&quot;;<br>            ZeroMemory( buf,128 );              */<br>      }<br>      else<br>      {      <br>            lnRes = RegCreateKeyEx(hKey,&quot;Sms&quot;,0,NULL,REG_OPTION_NON_VOLATILE,<br>                        KEY_ALL_ACCESS, NULL,&amp;hKey,&amp;Disp);<br>            if( lnRes != ERROR_SUCCESS )  return 0;<br>            RegSetValueEx(hKey,&quot;FROM&quot;,0,REG_SZ,(const unsigned char *)&quot;hello&quot;,5);<br>            RegSetValueEx(hKey,&quot;TO&quot;,0,REG_SZ,(const unsigned char *)&quot;lalala&quot;,6);<br>            RegSetValueEx(hKey,&quot;Number&quot;,0,REG_DWORD,(const unsigned char *)&amp;n,sizeof(n));<br>            RegSetValueEx(hKey,&quot;Sleep&quot;,0,REG_DWORD,(const unsigned char *)&amp;s,sizeof(s));<br>      }<br>      RegCloseKey(hKey);<br>      RegCloseKey(hKey2);<br>      return 0;<br>}<br>]]></description>
        <author>delitant</author>
        <category>Visual C++ / MFC / WTL</category>
      </item>
	
      </channel>
      </rss>
	