Archive for the 'Uncategorized' Category

转帖: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.

顺便拜一下年!

Protected: 真TMD扭曲

This post is password protected. To view it please enter your password below:


XML RPC Lite RC1 Publish

You can download XML-RPC lite 0.9 RC1 version from the following link.
XML-RPC Lite 0.9 RC1


TOC
1. What is this
2. Who is this for
3. Who made this
4. Licenses (No BS, make sure you read this)
5. Function calls
6. BUGS!

1. What is this for

This is a simple (going towards minimun) XML RPC library. The official name is "PHP XML RPC Lite". This is a single file, fully inlineable library providing both encoding and decoding function for XML RPC client side calls.
This library is special that it doesn't have error checking, only have minimum functionality that 100% comply with XML-RPC spec. Nothing more.
The code is not fully optimized yet, since it's still in beta, but it will be optimized for sure to recude code size or increase performance.

2. Who is this for

You might ask if there is already a PHP XML RPC library, the answer is yes.
This is for those who want to write XML RPC clients in PHP and found PHP XML RPC to be too big or too complex. This file can be copied and pasted into your code or include as a external library.
The license even allows you to remove any section you want when redistrubuting it (see license section for more details) so it'll have a minimum profile. Current size is 16k and reducing.

3. Who made this

Well, to tell you the truth, my name is William. A third year computer engineering student in University of Toronto. I wrote this piece of code to help the development of a wordpress plug-in. If you are impressed by this piece of code or my love towords coding, you might want to consider hiring me for your next project. Contact infomation is listed below:

E-mail: 2bethere [at] gmail (dot) Com

4. Licenses
a) Provided as-is. I shall not be held responsible for any damage caused by this piece of code. However, bug reports are welcome
b) You are allowed to add any changes to the code and you don’t have to release the modified source code.
c) You are allowed to remove any section of the code when it is part of your own release. You are encourage to let the author know you are using this library so you can get better support. However, you are not allowed to redistribute the library alone with anything removed from it.

5. Function calls
A complete sample has been provided in the library. It’s at the very end of the code.
There are three date helper functions
isDate()
Determines if the given variable is a ISO date format string since php doesn’t have “date” type
ig_iso8601_time(utc?)
Generate a iso8601 string based on current time
wptime2iso8601
this will parse a wordpress format time string (YYYY-MM-DD HH:MM:SS) into a iso8601 time string

6. BUG(s)

Bug report can be send to me at 2bethere (at) gmail (.) com
Subject must be [XRLITEBUG], otherwise it’ll be ignored.

Good luck with this, hope to hear from you soon.

Almost done with AMD(外两条消息)

AMD T-shirt

经历了一年的洗礼,无论是被收购,裁员,还是新产品的发布,最后两天了。昨天AMD终于比较厚道滴感谢了一下这些辛勤劳作的学生们,每人发了一件T-shirt。纪念一下吧。回头我会对这一年多的经历写一篇完整的更新,敬请期待。
Continue reading ‘Almost done with AMD(外两条消息)’