Monthly Archive for February, 2008

转帖:Dynamically loading a class from a dll

Original Article on codegear.com
Create the class dll:

1. Create a virtual base class that contains all of the methods you would need to call from the class. This will be the interface your dll class will support.
2. Make the dll class derive from that interface.
3. Include the interface definition in the executable that will use the dll class.
4. Export a function from the dll that will create a new instance of the dll class and return it’s address (I will call this function CreateClassInstance()).

To use the class in your executable:

1. Call LoadLibrary() on the dll that contains the class.
2. Call GetProcAddress() to gain access to the CreateClassInstance() function.
3. Call CreateClassObject() and store the returned address in an interface pointer.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
 
This example consists of two projects and six source files:
	header files:
	"FooInterface.h" -- definition for IFoo, the base class/interface
	"FooClass.h" -- definition for FooClass, deriving from IFoo
	"DllExports.h" -- dll's exported functions
 
	dll project:
	"DllMain.cpp" -- main cpp file for the dll project
	"FooClass.cpp" -- contains implementation for FooClass
 
	exe project:
	"ExeMain.cpp" -- main cpp file for exe project	
 
*/
 
 
//-------- FooInterface.h --------//
#ifndef FOOINTERFACE_H
#define FOOINTERFACE_H
 
class IFoo
{
public:
	int GetNumber() = 0;
	void SetNumber( int & ) =0;
};
 
#endif	// FOOINTERFACE_H

Continue reading ‘转帖:Dynamically loading a class from a dll’

我永远也忘不了那种寒冷?

连续n天抱怨天气,真是没什么创意。。。不过真的很冷。今天不多说了,只附上下面的图片,亲手制作。希望看过的朋友会心一笑,没看过?还不赶紧去看!——强烈推荐《热带雨林的爆笑生活》
guu_winter.jpg

2008年,大鱼吃小鱼。

最近IT界炒的风风火火的就算MS对Yahoo!的收购案了。
MS这条大鱼想要吃了Yahoo!这条小鱼,希望再长大一些。Yahoo!做为一条小鱼,又游不快,无望之下,决定吃掉一条和自己差不多大的鱼,AOL。最终的结果就是Yahoo!被AOL噎死,MS被吃了AOL的Yahoo!噎死。

其实吃来吃去,总有一天会被逼着分裂,还不如优化资产结构,没准长得更快更健康。

顺便提一下减肥。。。。。
我连续n天减肥,饿得两眼直冒绿光,可这体重就不见下。引用老罗的名言——我靠性的事件!人家老罗30天减了50斤,再看看自己,突然觉得减肥这玩意儿,也要靠天赋的。

天寒地冻+史上最无聊作业

今天温度是-30°C。。。给大家解释一下-30的概念。冰箱冷藏大概是-10,食品速冻是-18,工业速冻大概是-22~-24。
今天和mm去学校看书,路上那个爽啊。衣服都冻硬了,脸上的表情也凝固了。进屋以后觉得自己和速冻活鱼没啥区别,捏起来硬邦邦的,化冻化了半天才开始讲话。

回家的时候更别提了。就当提前去北极科考吧。

另外不能不抱怨一下史上最无聊作业。。。。。
计算机安全课,这次的作业是破解密码,16-bit的AES加密文件。我的电脑算了1个小时,而且文件还不带crc,解出来200多个大小差不多的文件,一个一个看。最后发现密码是0xDEAD。真是恶趣味的老师。居然搞这种无聊的密码。老子下次不学安全了,去搞心理学,估计更快猜到。。。。。

突然觉得老祖宗大力宣传的“春捂秋冻”还是很有科学道理的。
天寒地冻,下周也不暖和,大家注意保暖啊。感冒了就不和算了。嘎嘎。

史上最无聊Visual Studio 2005插件

Code Project的原文在这里(这可是俺原创啊)
http://www.codeproject.com/KB/macros/vsnowediting.aspx
源代码和文件都可以在上面这页找到。
插件的作用很简单~~装上以后你在VS里面编辑文件的时候,就可以在MSN上显示Now coding in Visual Studio : yourfile.cpp….。具体效果请看下面的截图 。

截图如下
msn now edit screenshot

我相信一定会有人比我更无聊~~~~期待一下vim的插件。哈哈哈哈。

甲子年第一场雪

我刚刚从门外回来,还以为自己到了南极去科考,满地找企鹅。。。。。。。

雪倒不大,风大得夸张。把地上的冰渣吹起来,居然能黏在我的牛仔裤上。Orz一下。。。。。

不过俗话说得好,瑞雪兆丰年。祝愿大家今年万事如意,身体健康!

LiveSync 2.2.3 Beta 发布!

使用方法很简单。
把文件解压到wp-content/plugins/,然后在plug-in控制面板激活即可。

Live Sync 2.2.3 Beta!
Simply extract the file into wp-content/plugins/

Download msn sync 2.2.3 here.

顺便拜一下年!