2009年3月20日星期五

cmd2cb.exe v0.92 is published

In my post <pipe console program output to clipboard>, I made a tiny tool -- cmd2cb for my own convenience. After several days improvement, cmd2cb v0.92 is avaiable now.

Basic feature:
Pipe the output of a console program to clipboard.


New features:
1. Unicode support, cmd2cb can be used in CJK locale. ( Most important one)
2. Add a parameter -h or -help for help page.
3. When failed copy contents to clipboard, it will redirect the output to console.

Download:
box.net: cmd2cb.zip
namipan.net: cmd2cb.zip (for Chinese)

Screen snapshots:







cmd2cb 0.92版发布了!!

基本功能:
通过管道符把控制台程序的输出重定向到剪贴板,以方便其他程序使用。


增加的功能有:
1. 支持Unicode,因此能支持中文,日文,韩文以及其他ANSI 的CodePage
2. 增加命令行参数-h, -help,显示帮助
3. 在把内容输出到剪贴板失败时,仍旧输出到控制台

截图:
看上面英文版介绍

下载:
box.net: cmd2cb.zip
纳米盘: cmd2cb.zip

100篇blog纪念

我很惭愧,很不好意思,很小声的宣布:“本人终于写了100篇blog啦!”。


我从07年1月30日在blogger开博以来2年间,疏于耕耘,到现在两年多,算下来平均5篇每月都不到,相比引领我入门的morphine,实在让我汗颜。他一个季度的blog数就差不多和我两年的产量一样多了。

不过由于我的blog定位偏向技术,因此也不可能产量很高。有些课题需要花一定时间去研究,整理,才能写成文章。不过我以后会渐渐拓宽自己的思路,写一些别的东西。

说说之后的打算吧。

第一件事就是关于blog空间的。

由于马勒隔壁的鸡恶妇打不溜,我的blog已经无法直接访问了。但是域名mogling.com是在国外托管的,不会有问题。我现在只能暂时用FTP发布到我的域名服务商godaddy.com的免费服务器上,这样又可以通过http://blog.mogling.com访问了。这样做的缺点就是页面上头有广告。输出的FEED也会有影响,而且还只能用超窄的经典模板(屁,这么烂的也算经典?)。

我正在犹豫,是否像morphine一样去弄个没有广告的免费空间,用WP算了。但是现在工作比较忙,对这些网络上的东西也不像以前那样热衷,而且以前做ffsky.com的时候吃尽了颠沛流离的苦,所以对这种方式还是有点吃不准。

第二件事算是预告。
接下来可能会写一个系列的文章,关于STL库的设计和运用的。具体时间还没有定,不过在6月份之前应该会搞定这件事情。这系列文章我一定会精心打造:)


2009年3月16日星期一

Lnk2001: unresolved external symbol _com_util::ConvertBSTRToString

Today my colleague encountered a strange Lnk2001 error while using VS2003.net to build a project.

Here is the error snippet:

error LNK2019: unresolved external symbol "unsigned short * __stdcall _com_util::ConvertStringToBSTR(char const *)" (?ConvertStringToBSTR@_com_util@@YGPA_WPBD@Z) referenced in function "public: __thiscall _bstr_t::Data_t::Data_t(char const *)" (??0Data_t@_bstr_t@@QAE@PBD@Z)

error LNK2019: unresolved external symbol "char * __stdcall _com_util::ConvertBSTRToString(unsigned short *)" (?ConvertBSTRToString@_com_util@@YGPADPA_W@Z) referenced in function "public: char const * __thiscall _bstr_t::Data_t::GetString(void)const " (?GetString@Data_t@_bstr_t@@QBEPBDXZ)

I checked if the correct lib (comsuppw.lib) is included. But he already did.

The same code can pass build in VC2005. But in VC2003, it can’t. That’s interesting.

One possibility is the environment of VC2003 differs from VC2005. By making a rough search, I found they are almost same. After I googled this bug, a post inspires me. I forget to check the method’s return type and argument type.

Let take a look at the same errors in VC2005:
Error    5     error LNK2001: unresolved external symbol "char * __stdcall _com_util::ConvertBSTRToString(wchar_t *)" (?ConvertBSTRToString@_com_util@@YGPADPA_W@Z) XLRCreatorDll.obj
Error    6     error LNK2001: unresolved external symbol "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)" (?ConvertStringToBSTR@_com_util@@YGPA_WPBD@Z) XLRCreatorDll.obj


Compare the error msg in VC2005 and VC2003, we can see the return type and argument type is different:

char * __stdcall _com_util::ConvertBSTRToString(unsigned short *)    ----VC2003

char * __stdcall _com_util::ConvertBSTRToString(wchar_t *) ----VC2005


What does this mean?

Yes, the wchar_t in VC2003 project is treated as unsigned short instead of wchar_t itself. We know in some old OS implementation, wchar_t is only typedef of unsigned short. But in new release, wchat_t is definitely a native data type to support Unicode.

Then we know, in VC2003, the compiler still treats wchar_t as unsigned short rather than a native data type. But the prototype in comsuppw.lib, it requires wchar_t.

Thus comes the very simple solution: add /Zc:wchar_t to command line of compiler.

After adding this option, the annoying Lnk2001 disappears.

2009年3月7日星期六

养目荠菜粥

荠菜,又名护生草、鸡心菜、净肠草,在路边或野地里随处可见。

荠菜不仅是营养丰富的美味食品,而且还能治疗多种疾病,民间不仅有“阳春三月三,荠菜当灵丹”的谚语,还流传着“春食荠菜赛仙丹”的说法。可见荠菜不仅是佳肴一碟,更是灵药一方。在中药里,荠菜的药用价值非常广泛,被誉为“菜中甘草”。祖国医学认为:荠菜味甘、性凉,归肝、脾、肾经,有和脾、利水、止血、明目等效用。

我这里推荐一道简单易学又清淡好吃的荠菜粥:


做法:荠菜(量自己控制),梗米50克,武火烧开,文火煮熟。

吃法:空腹食用,连续一个星期效果比较好。

推荐对象:每天对着显示器工作,感到自己眼睛不舒服的上班族。荠菜粥对目赤目暗,视网膜出血等症有比较好的治疗效果。其实我眼睛不舒服已经几个月了,最近连续吃荠菜粥,荠菜饭,炒荠菜,大量荠菜投下去,终于有点效果了。

另外喜欢精致的朋友可以用珍珠米。煮粥的米要预先腌:约半碗米淘洗干净后,要用2汤匙的油、1个半茶匙的盐和少许水(2茶匙)拌匀,腌至少半小时。这样煮出来的粥非常软,入口即化。煮的时候放一个轻的小调羹在锅底与粥同煮,水沸腾过程中,小调羹也被带动,可以防止粥煮粘底。

2009年3月1日星期日

Share a very interesting physics game

the game "Crayon Physics" reveals the fun of physics to you and bring you back to your childhood drawing with crayons.



you may get it from http://www.crayonphysics.com/