<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'return array or vector TCAHR of windows registry key subkeys c++' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'return array or vector TCAHR of windows registry key subkeys c++' posted on the 'Windows programming' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 13:06:56 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 13:06:56 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>return array or vector TCAHR of windows registry key subkeys c++</title>
      <link>http://www.programmersheaven.com/mb/windows/428395/428395/return-array-or-vector-tcahr-of-windows-registry-key-subkeys-c++/</link>
      <description>i have this code in a c void function to get and print subkeys of a windows registry key:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;TCHAR    achKey[MAX_KEY_LENGTH];   // buffer for subkey name
retCode = RegQueryInfoKey(
        hKey,                    // key handle 
        achClass,                // buffer for class name 
        &amp;amp;cchClassName,           // size of class string 
        NULL,                    // reserved 
        &amp;amp;cSubKeys,               // number of subkeys 
        &amp;amp;cbMaxSubKey,            // longest subkey size 
        &amp;amp;cchMaxClass,            // longest class string 
        &amp;amp;cValues,                // number of values for this key 
        &amp;amp;cchMaxValue,            // longest value name 
        &amp;amp;cbMaxValueData,         // longest value data 
        &amp;amp;cbSecurityDescriptor,   // security descriptor 
        &amp;amp;ftLastWriteTime);       // last write time 

    // Enumerate the subkeys, until RegEnumKeyEx fails.

    if (cSubKeys)
    {
        printf( "\nNumber of subkeys: %d\n", cSubKeys);

        for (i=0; i&amp;lt;cSubKeys; i++) 
        { 
            cbName = MAX_KEY_LENGTH;
            retCode = RegEnumKeyEx(hKey, i,
                     achKey, 
                     &amp;amp;cbName, 
                     NULL, 
                     NULL, 
                     NULL, 
                     &amp;amp;ftLastWriteTime); 
            if (retCode == ERROR_SUCCESS) 
            {
                _tprintf(TEXT("(%d) %s\n"), i+1, achKey);
            }
        }
    } &lt;/pre&gt;&lt;br /&gt;
how can i modify to return an array with all the subkeys values,&lt;br /&gt;
I TRIED:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;vector&amp;lt;TCHAR&amp;gt; getSubKeys(HKEY key)
{
    vector&amp;lt;TCHAR&amp;gt;&amp;gt; subkeys;
    ....
    for (i=0; i&amp;lt;cSubKeys; i++) 
    {
        // get subkey name
        subkeys.push_back(TCHAR&amp;gt;(achKey));
    }
    ....
    return subkeys;
}
 &lt;/pre&gt;&lt;br /&gt;
with this change it works but at t_main function when i try to list the vector to the console just show eight(the number of subkeys is correct) numbers like 65000 the same value for the eight vector elements, where's the problem or how can i compile with your code, thanks a lot&lt;br /&gt;
&lt;br /&gt;
thanks&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/windows/428395/428395/return-array-or-vector-tcahr-of-windows-registry-key-subkeys-c++/</guid>
      <pubDate>Sun, 22 Apr 2012 03:37:20 -0700</pubDate>
      <category>Windows programming</category>
    </item>
  </channel>
</rss>