﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Timothy&#039;s Space &#187; enumerate</title>
	<atom:link href="http://www.xiaozhou.net/tag/enumerate/feed" rel="self" type="application/rss+xml" />
	<link>http://www.xiaozhou.net</link>
	<description>君看一叶舟，出没风波里</description>
	<lastBuildDate>Tue, 07 Feb 2012 04:28:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>枚举注册表键名与键值</title>
		<link>http://www.xiaozhou.net/vcdevelopment/enumerate-the-registry-key-name-and-key-value-2004-10-21.htm</link>
		<comments>http://www.xiaozhou.net/vcdevelopment/enumerate-the-registry-key-name-and-key-value-2004-10-21.htm#comments</comments>
		<pubDate>Thu, 21 Oct 2004 07:22:35 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[VC开发]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[key]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[value]]></category>
		<category><![CDATA[枚举]]></category>
		<category><![CDATA[注册表]]></category>
		<category><![CDATA[键值]]></category>

		<guid isPermaLink="false">http://localhost/wordpress/?p=32</guid>
		<description><![CDATA[枚举注册表键名与键值的一个函数： // QueryKey &#8211; Enumerates the subkeys of key, and the associated // values, then copies the information about the keys and values // into a pair of edit controls and list boxes. // hDlg &#8211; Dialog box that contains the edit controls and list boxes. // hKey &#8211; Key whose subkeys and values are [...]]]></description>
			<content:encoded><![CDATA[<p>枚举注册表键名与键值的一个函数：</p>
<p>// QueryKey &#8211; Enumerates the subkeys of key, and the associated<br />
//    values, then copies the information about the keys and values<br />
//    into a pair of edit controls and list boxes.<br />
// hDlg &#8211; Dialog box that contains the edit controls and list boxes.<br />
// hKey &#8211; Key whose subkeys and values are to be enumerated.</p>
<p>void QueryKey(HWND hDlg, HANDLE hKey)<br />
{<br />
    CHAR     achKey[MAX_PATH];<br />
    CHAR     achClass[MAX_PATH] = &#8220;&#8221;;  // buffer for class name<br />
    DWORD    cchClassName = MAX_PATH;  // size of class string<br />
    DWORD    cSubKeys;                 // number of subkeys<br />
    DWORD    cbMaxSubKey;              // longest subkey size<br />
    DWORD    cchMaxClass;              // longest class string<br />
    DWORD    cValues;              // number of values for key<br />
    DWORD    cchMaxValue;          // longest value name<br />
    DWORD    cbMaxValueData;       // longest value data<br />
    DWORD    cbSecurityDescriptor; // size of security descriptor<br />
    FILETIME ftLastWriteTime;      // last write time</p>
<p>    DWORD i, j;<br />
    DWORD retCode, retValue;</p>
<p>    CHAR  achValue[MAX_VALUE_NAME];<br />
    DWORD cchValue = MAX_VALUE_NAME;<br />
    CHAR  achBuff[80];</p>
<p>    // Get the class name and the value count.<br />
    RegQueryInfoKey(hKey,        // key handle<br />
        achClass,                // buffer for class name<br />
        &#038;cchClassName,           // size of class string<br />
        NULL,                    // reserved<br />
        &#038;cSubKeys,               // number of subkeys<br />
        &#038;cbMaxSubKey,            // longest subkey size<br />
        &#038;cchMaxClass,            // longest class string<br />
        &#038;cValues,                // number of values for this key<br />
        &#038;cchMaxValue,            // longest value name<br />
        &#038;cbMaxValueData,         // longest value data<br />
        &#038;cbSecurityDescriptor,   // security descriptor<br />
        &#038;ftLastWriteTime);       // last write time</p>
<p>    SetDlgItemText(hDlg, IDE_CLASS, achClass);<br />
    SetDlgItemInt(hDlg, IDE_CVALUES, cValues, FALSE);</p>
<p>    SendMessage(GetDlgItem(hDlg, IDL_LISTBOX),<br />
        LB_ADDSTRING, 0, (LONG) &#8220;..&#8221;);</p>
<p>    // Enumerate the child keys, until RegEnumKeyEx fails. Then<br />
    // get the name of each child key and copy it into the list box.</p>
<p>    SetCursor(LoadCursor(NULL, IDC_WAIT));<br />
    for (i = 0, retCode = ERROR_SUCCESS;<br />
            retCode == ERROR_SUCCESS; i++)<br />
    {<br />
        retCode = RegEnumKeyEx(hKey,<br />
                     i,<br />
                     achKey,<br />
                     MAX_PATH,<br />
                     NULL,<br />
                     NULL,<br />
                     NULL,<br />
                     &#038;ftLastWriteTime);<br />
        if (retCode == (DWORD)ERROR_SUCCESS)<br />
        {<br />
            SendMessage(GetDlgItem(hDlg, IDL_LISTBOX),<br />
                LB_ADDSTRING, 0, (LONG) achKey);<br />
        }<br />
    }<br />
    SetCursor(LoadCursor (NULL, IDC_ARROW));</p>
<p>    // Enumerate the key values.<br />
    SetCursor(LoadCursor(NULL, IDC_WAIT));</p>
<p>    if (cValues)<br />
    {<br />
        for (j = 0, retValue = ERROR_SUCCESS;<br />
                j < cValues; j++)<br />
        {<br />
            cchValue = MAX_VALUE_NAME;<br />
            achValue[0] = '\0';<br />
            retValue = RegEnumValue(hKey, j, achValue,<br />
                &#038;cchValue,<br />
                NULL,<br />
                NULL,    // &#038;dwType,<br />
                NULL,    // &#038;bData,<br />
                NULL);   // &#038;bcData</p>
<p>            if (retValue == (DWORD) ERROR_SUCCESS )<br />
            {<br />
                achBuff[0] = '\0';</p>
<p>                // Add each value to a list box.<br />
                if (!lstrlen(achValue))<br />
                    lstrcpy(achValue, "<no NAME>&#8220;);<br />
                wsprintf(achBuff, &#8220;%d) %s &#8220;, j, achValue);<br />
                SendMessage(GetDlgItem(hDlg,IDL_LISTBOX2),<br />
                    LB_ADDSTRING, 0, (LONG) achBuff);<br />
            }<br />
        }</p>
<p>    SetCursor(LoadCursor(NULL, IDC_ARROW));<br />
}</p>
<p class="announce"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;">声明:</span> 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 <br /> 本站文章均采用 <a rel="nofollow" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="署名-非商业性使用-相同方式共享">知识共享署名-相同方式共享3.0</a> 协议进行授权，除非注明，本站文章均为原创，转载请注明转自  <a href="http://www.xiaozhou.net">Timothy&#039;s Space</a> 并应以链接形式标明本文地址!</p>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/vcdevelopment/enumerate-the-registry-key-name-and-key-value-2004-10-21.htm/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>枚举系统进程核心代码</title>
		<link>http://www.xiaozhou.net/vcdevelopment/enumerate-the-system-processes-the-core-code-2004-10-10.htm</link>
		<comments>http://www.xiaozhou.net/vcdevelopment/enumerate-the-system-processes-the-core-code-2004-10-10.htm#comments</comments>
		<pubDate>Sun, 10 Oct 2004 14:41:05 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[VC开发]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[Process]]></category>
		<category><![CDATA[system]]></category>
		<category><![CDATA[枚举]]></category>
		<category><![CDATA[核心代码]]></category>
		<category><![CDATA[系统]]></category>
		<category><![CDATA[进程]]></category>

		<guid isPermaLink="false">http://localhost/wordpress/?p=27</guid>
		<description><![CDATA[包含头文件： #include &#8220;tlhelp32.h&#8221; 示例： void CTerminateProcessDlg::OnGetProcess() { m_ListBox.ResetContent(); CString m_output; HANDLE hProcessSnap=NULL; PROCESSENTRY32 pe32={0}; hProcessSnap=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); if(hProcessSnap==(HANDLE)-1) { ::MessageBox(NULL,&#8221;查询进程失败！:(&#8220;,&#8221;错误提示&#8221;,MB_OK); } pe32.dwSize=sizeof(PROCESSENTRY32); if(Process32First(hProcessSnap,&#038;pe32)) { do { m_output.Format(&#8220;%-20s ID:%-5d&#8221;,pe32.szExeFile,pe32.th32ProcessID); m_ListBox.AddString(m_output); } while(Process32Next(hProcessSnap,&#038;pe32)); } else { ::MessageBox(NULL,&#8221;出现意外错误！&#8221;,&#8221;错误提示&#8221;,MB_OK); } CloseHandle(hProcessSnap); } 声明: 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 本站文章均采用 知识共享署名-相同方式共享3.0 协议进行授权，除非注明，本站文章均为原创，转载请注明转自 Timothy&#039;s Space 并应以链接形式标明本文地址!]]></description>
			<content:encoded><![CDATA[<p>包含头文件：<br />
#include &#8220;tlhelp32.h&#8221;<br />
示例：</p>
<p>void CTerminateProcessDlg::OnGetProcess()<br />
{<br />
	m_ListBox.ResetContent();<br />
	CString m_output;<br />
	HANDLE hProcessSnap=NULL;<br />
	PROCESSENTRY32 pe32={0};<br />
	hProcessSnap=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);<br />
	if(hProcessSnap==(HANDLE)-1)<br />
	{<br />
		::MessageBox(NULL,&#8221;查询进程失败！:(&#8220;,&#8221;错误提示&#8221;,MB_OK);</p>
<p>	}<br />
	pe32.dwSize=sizeof(PROCESSENTRY32);<br />
	if(Process32First(hProcessSnap,&#038;pe32))<br />
	{<br />
		do<br />
		{<br />
			m_output.Format(&#8220;%-20s     ID:%-5d&#8221;,pe32.szExeFile,pe32.th32ProcessID);<br />
			m_ListBox.AddString(m_output);<br />
		}<br />
		while(Process32Next(hProcessSnap,&#038;pe32));<br />
	}<br />
	else<br />
	{<br />
		::MessageBox(NULL,&#8221;出现意外错误！&#8221;,&#8221;错误提示&#8221;,MB_OK);<br />
	}<br />
	CloseHandle(hProcessSnap);</p>
<p>}</p>
<p class="announce"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;">声明:</span> 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 <br /> 本站文章均采用 <a rel="nofollow" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="署名-非商业性使用-相同方式共享">知识共享署名-相同方式共享3.0</a> 协议进行授权，除非注明，本站文章均为原创，转载请注明转自  <a href="http://www.xiaozhou.net">Timothy&#039;s Space</a> 并应以链接形式标明本文地址!</p>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/vcdevelopment/enumerate-the-system-processes-the-core-code-2004-10-10.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

