<?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>Justin's Tech Blog &#187; C/C++</title>
	<atom:link href="http://www.sofee.cn/blog/category/technical/cplusplus/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sofee.cn/blog</link>
	<description>世界其实很简单，复杂的是人；生活其实很轻松，沉重的是感情！</description>
	<lastBuildDate>Sun, 17 Jan 2010 17:17:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>解决IE中IFRAME无法保留SESSION的问题</title>
		<link>http://www.sofee.cn/blog/2008/11/25/190/</link>
		<comments>http://www.sofee.cn/blog/2008/11/25/190/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 07:43:41 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[CWebBrowser2]]></category>
		<category><![CDATA[跨域]]></category>
		<category><![CDATA[IFRAME]]></category>
		<category><![CDATA[MFC]]></category>
		<category><![CDATA[P3P]]></category>
		<category><![CDATA[SESSION]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/?p=190</guid>
		<description><![CDATA[最近用C++开发一个基于WebBrowser的Application，界面都是在一个IFRAME里展示，由于需要会员登录模块，结果却出现在IFRAME里无法保留SESSION的问题，上MICROSOFT官方找到了答案：
@header(&#8216;P3P: CP=&#8221;CAO PSA OUR&#8221;&#8216;);
一句代码搞定！
P3P是微软的隐私策略，通常情况下跨域IFRAME或者FRAMESET默认采用的隐私策略为“中”，该级别的策略拒绝保留SESSION。CAO PSA OUR则意味着你同意跨域保留SESSION。
详细资料可以查看官方文档:http://support.microsoft.com/kb/323752

  addthis_url    = 'http%3A%2F%2Fwww.sofee.cn%2Fblog%2F2008%2F11%2F25%2F190%2F';
  addthis_title  = '%E8%A7%A3%E5%86%B3IE%E4%B8%ADIFRAME%E6%97%A0%E6%B3%95%E4%BF%9D%E7%95%99SESSION%E7%9A%84%E9%97%AE%E9%A2%98';
  addthis_pub    = 'sofeecn';

]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2008/11/25/190/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sofee Domain Typo Generator released</title>
		<link>http://www.sofee.cn/blog/2008/01/07/142/</link>
		<comments>http://www.sofee.cn/blog/2008/01/07/142/#comments</comments>
		<pubDate>Mon, 07 Jan 2008 04:38:05 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Domain]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Generator]]></category>
		<category><![CDATA[Keywords]]></category>
		<category><![CDATA[Letter Swap]]></category>
		<category><![CDATA[mis-spellings]]></category>
		<category><![CDATA[mis-typings]]></category>
		<category><![CDATA[QWERTY]]></category>
		<category><![CDATA[Sticky Keys]]></category>
		<category><![CDATA[Traffic]]></category>
		<category><![CDATA[Typo]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/2008/01/07/142/</guid>
		<description><![CDATA[ 
var alimama_pid="mm_10006029_103557_106167"; 
var alimama_titlecolor="8ab459"; 
var alimama_descolor ="888888"; 
var alimama_bgcolor="FFFFFF"; 
var alimama_bordercolor="ffffff"; 
var alimama_linkcolor="8ab459"; 
var alimama_sizecode="12"; 
var alimama_width=468; 
var alimama_height=60; 
var alimama_type=2; 
 
 
 Sofee Domain Typo Generator will take a domain name you specify and generator a list of suggestions of likely human mis-spellings and mis-typings for that domain.
The typo methods we do [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2008/01/07/142/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>去掉CWebBorwser2控件的滚动条</title>
		<link>http://www.sofee.cn/blog/2007/12/23/136/</link>
		<comments>http://www.sofee.cn/blog/2007/12/23/136/#comments</comments>
		<pubDate>Sun, 23 Dec 2007 13:23:52 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[COleControlSite]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CWebBorwser2]]></category>
		<category><![CDATA[DOCHOSTUIFLAG_NO3DBORDER]]></category>
		<category><![CDATA[DOCHOSTUIFLAG_SCROLL_NO]]></category>
		<category><![CDATA[GetHostInfo]]></category>
		<category><![CDATA[MFC]]></category>
		<category><![CDATA[滚动条]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/2007/12/23/136/</guid>
		<description><![CDATA[重载XDocHostUIHandler::GetHostInfo方法即可
相关代码如下：

HRESULT FAR EXPORT CMyControlSite::XDocHostUIHandler::GetHostInfo&#40;DOCHOSTUIINFO* pInfo&#41;
&#123;
    METHOD_PROLOGUE&#40;CMyControlSite, DocHostUIHandler&#41;
    //pInfo-&#62;dwFlags = DOCHOSTUIFLAG_NO3DBORDER;
    pInfo-&#62;dwFlags = DOCHOSTUIFLAG_DIALOG;		// 禁止选择
    pInfo-&#62;dwFlags &#124;= DOCHOSTUIFLAG_SCROLL_NO;	// 去掉滚动条
    pInfo-&#62;dwDoubleClick = DOCHOSTUIDBLCLK_DEFAULT;
    return S_OK;
&#125;

该方法中，可延伸的内容也非常，比如设置默认的CSS，设置浏览器默认的属性等。
DOCHOSTUIFLAG_DIALOG = 0&#215;00000001,
DOCHOSTUIFLAG_DISABLE_HELP_MENU = 0&#215;00000002,
DOCHOSTUIFLAG_NO3DBORDER = 0&#215;00000004,
DOCHOSTUIFLAG_SCROLL_NO = 0&#215;00000008,
DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE = 0&#215;00000010,
DOCHOSTUIFLAG_OPENNEWWIN = 0&#215;00000020,
DOCHOSTUIFLAG_DISABLE_OFFSCREEN = 0&#215;00000040,
DOCHOSTUIFLAG_FLAT_SCROLLBAR [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2007/12/23/136/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disable URLDownloadToFile cache</title>
		<link>http://www.sofee.cn/blog/2007/12/23/135/</link>
		<comments>http://www.sofee.cn/blog/2007/12/23/135/#comments</comments>
		<pubDate>Sun, 23 Dec 2007 12:42:04 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[BINDF_GETNEWESTVERSION]]></category>
		<category><![CDATA[BINDF_NOWRITECACHE]]></category>
		<category><![CDATA[禁止缓存]]></category>
		<category><![CDATA[IBindStatusCallback]]></category>
		<category><![CDATA[URLDownloadToFile]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/2007/12/23/135/</guid>
		<description><![CDATA[VC++提供了URLDownloadToFile和URLDownloadToCacheFile两个方法用来实现文件的下载,省去了自己写SOCKET。
默认情况下，这两个方法都会从缓存里找，若存在缓存，则会直接从缓存取，而不再下载（IE就是这么实现的），这样大大增加了下载出错的几率。
下面提供两种方法来禁止缓存，而每次都从服务器端下载
方法一：
该方法最简单，在调用URLDownloadToFile之间调用DeleteUrlCacheEntry即可。
DeleteUrlCacheEntry()方法在Wininet.h头文件里定义。

DeleteUrlCacheEntry&#40;remote_file&#41;;
HRESULT hr = URLDownloadToFile&#40;NULL, local_file, remote_file, 0, 0&#41;;

方法二：
这种方法适合需实现自定义下载进度的，原理就是实现一个IBindStatusCallback接口的GetBindInfo方法，加入BINDF_GETNEWESTVERSION &#124; BINDF_NOWRITECACHE属性即可。相关代码如下：

STDMETHODIMP CBindStatusCallback::GetBindInfo&#40;DWORD *pgrfBINDF, BINDINFO *pbindInfo&#41;
&#123;
    if &#40;!pgrfBINDF &#124;&#124; !pbindInfo &#124;&#124; pgrfBINDF == NULL&#41; &#123;
        return E_POINTER;
    &#125;
&#160;
    // force redownload
    *pgrfBINDF &#124;= BINDF_GETNEWESTVERSION &#124; BINDF_NOWRITECACHE;
&#160;
   [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2007/12/23/135/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C++遍历中删除std::map元素</title>
		<link>http://www.sofee.cn/blog/2007/11/14/128/</link>
		<comments>http://www.sofee.cn/blog/2007/11/14/128/#comments</comments>
		<pubDate>Wed, 14 Nov 2007 01:45:26 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[CNNIC]]></category>
		<category><![CDATA[玉米]]></category>
		<category><![CDATA[erase]]></category>
		<category><![CDATA[std::list]]></category>
		<category><![CDATA[std::map]]></category>
		<category><![CDATA[STL]]></category>
		<category><![CDATA[域名]]></category>
		<category><![CDATA[抢注工具]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/2007/11/14/128/</guid>
		<description><![CDATA[最近在写一个CNNIC的玉米抢注工具，碰到一个std::map遍历中不能删除元素的问题，以下是GOOGLE的结果，记录一下：
在std::list中删除一个元素非常简单，直接使用erase方法即可，代码如下：

for&#40;iter = list.begin&#40;&#41;; iter != list.end&#40;&#41;;&#41; &#123;
	if &#40;shouldDelete&#40;*iter&#41;&#41;
		iter = list.erase&#40;iter&#41;;
	else
		++iter;
&#125;

或者更简单点

list.erase&#40;std::remove_if&#40;list.begin&#40;&#41;, list.end&#40;&#41;, shouldDelete&#41;, list_end&#40;&#41;&#41;;

然而根据STL std::map中的定义void erase(iterator pos)，此erase并不返回下一个元素的迭代器，因此不能采用std::list的方法

The truth is that &#8216;erase&#8217; in associative containers doesn&#8217;t invalidate any iterators except those that point to elements being erased (that&#8217;s also true for &#8217;sid::list&#8217;). For this reason, you don&#8217;t really need &#8216;map::erase&#8217; to return an iterator. Just do this


for&#40;iter [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2007/11/14/128/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[老文章 ]使用VC++开发PHP扩展注意事项</title>
		<link>http://www.sofee.cn/blog/2006/06/26/20/</link>
		<comments>http://www.sofee.cn/blog/2006/06/26/20/#comments</comments>
		<pubDate>Mon, 26 Jun 2006 15:42:19 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[ZEND API]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP扩展]]></category>
		<category><![CDATA[VC++]]></category>
		<category><![CDATA[ZEND-API]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/?p=20</guid>
		<description><![CDATA[一、默认情况下，C++是使用.cpp作为扩展名的，而PHP是用C写的，因此必须使用C++提供的C连接交换指定符号extern &#8220;C&#8221;来解决这个问题，以下两部分语句必须被包含：

extern &#34;C&#34; &#123;
#include &#34;php.h&#34;
#include &#34;php_ini.h&#34;
#include &#34;ext/standard/info.h&#34;
... // 其他C头文件
&#125;

和

extern &#34;C&#34; &#123;
#ifdef COMPILE_DL_MYEXT
ZEND_GET_MODULE&#40;myext&#41;
#endif
&#125;


二、STL模版定义是不能被包含在C连接交换指定符的，而PHP需用到math.h这个头文件，因此编译的时候会产生math.h(514) error c2894: templates cannot be declared to have &#8216;C&#8217; linkage的错误信息，要解决这个问题，需在� 的CPP文件头部也就是extern &#8220;C&#8221;连接符之前加 入以下代码：

#ifdef WIN32
#include &#60;math.h&#62;
#endif

三、同C中一样，必须先在头文件（如：php_myext.h）中申明所有函数原型，如果没有使用头文件，那么必须在CPP文件（如：ext.cpp）的zend function结构之间申明所有函数原型，也就是在如下代码之前：

function_entry myext_functions&#91;&#93; = &#123;
PHP_FE&#40;confirm_myext_compiled, NULL&#41; /* For testing, remove later. */
&#123;NULL, NULL, NULL&#125;
&#125;;


  addthis_url    = 'http%3A%2F%2Fwww.sofee.cn%2Fblog%2F2006%2F06%2F26%2F20%2F';
  addthis_title  = '%5B%E8%80%81%E6%96%87%E7%AB%A0+%5D%E4%BD%BF%E7%94%A8VC%2B%2B%E5%BC%80%E5%8F%91PHP%E6%89%A9%E5%B1%95%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9';
  addthis_pub  [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2006/06/26/20/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[老文章]从PHP源代码修改phpinfo中的LOGO及彩蛋</title>
		<link>http://www.sofee.cn/blog/2006/06/26/19/</link>
		<comments>http://www.sofee.cn/blog/2006/06/26/19/#comments</comments>
		<pubDate>Mon, 26 Jun 2006 15:25:28 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[ZEND API]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP扩展]]></category>
		<category><![CDATA[ZEND-API]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/?p=19</guid>
		<description><![CDATA[1. 大家先来看一段PHP代码（gif2h.php）：

&#60;?php
// 将GIF转换为C语言中的H文件
$filename = &#34;mylogo.gif&#34;;
$fp = f open&#40;$filename, &#34;rb&#34;&#41;;
$buffer = f read&#40;$fp, filesize&#40;$filename&#41;&#41;;
f close&#40;$fp&#41;;
$len = strlen&#40;$buffer&#41;;
$fp = f open&#40;&#34;mylogo.h&#34;, &#34;wb&#34;&#41;;
f write&#40;$fp, &#34;unsigned char php_logo[] = {&#34;&#41;;
for &#40;$i=0; $i&#60;=$len; $i++&#41; &#123;
	if&#40;$i % 10 == 0&#41; &#123;
		f write&#40;$fp, &#34;\n\t\t&#34;&#41;;
	&#125;
	if&#40;$i == $len&#41; &#123;
		$str = str_pad&#40;ord&#40;substr&#40;$buffer, $i, 1&#41;&#41;, 3, &#34; &#34;, STR_PAD_LEFT&#41;;
	&#125; else &#123;
		$str = str_pad&#40;ord&#40;substr&#40;$buffer, $i, 1&#41;&#41;, 3, [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2006/06/26/19/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Timer on Windows and Linux</title>
		<link>http://www.sofee.cn/blog/2006/06/16/11/</link>
		<comments>http://www.sofee.cn/blog/2006/06/16/11/#comments</comments>
		<pubDate>Fri, 16 Jun 2006 05:15:33 +0000</pubDate>
		<dc:creator>Justin</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Signal]]></category>
		<category><![CDATA[Timer]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.sofee.cn/blog/?p=11</guid>
		<description><![CDATA[1. Timer on Windows



#define WIN32_LEAN_AND_MEAN
#include &#60;windows.h&#62;
&#160;
UINT tid;
&#160;
VOID CALLBACK TimerHandler&#40;HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime&#41; &#123;
	printf&#40;&#34;Timer called @ [%ld]\n&#34;, dwTime&#41;;
&#125;
&#160;
static BOOL WINAPI SignalHandler&#40;DWORD event&#41; &#123;
	switch &#40;event&#41; &#123;
		case CTRL_C_EVENT:
		case CTRL_BREAK_EVENT:
			KillTimer&#40;&#40;HWND&#41;NULL, tid&#41;;
			// Notify not to call other handlers.
			return FALSE;
	&#125;
&#160;
    return TRUE;
&#125;
&#160;
int main&#40;int argc, char **argv&#41; &#123;
	MSG msg;
&#160;
	if &#40;!SetConsoleCtrlHandler&#40;SignalHandler, TRUE/*add*/&#41;&#41; &#123;
		printf&#40;&#34;SetConsoleCtrlHandler error - %d&#34;, [...]]]></description>
		<wfw:commentRss>http://www.sofee.cn/blog/2006/06/16/11/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
