2008年12月30日

There are two ways of rising in the world, either by your own industry or by the folly of others
成功之路有两条:靠自己的努力或靠他人的愚蠢。

Don't part with your illusions.When they are gone you may still exist, but you have ceased to live.
不要放弃你的幻想。当幻想没有了以后,你还可以生存,但是你生犹死。
posted @ 2008-12-30 21:48 犹志 阅读(203) | 评论 (0)编辑 收藏
Choose a life of action, not one of ostentation.
要选择行动的一生,儿不是炫耀的一生。

If you have a great talents, industy will improve them; if you have but moderate abilities, industy will supply their deficiency.
如有你很有天赋,勤勉会使其更加完善;如果你能力一般,勤勉会补足其缺陷。

It is easier to fight for principles than to live up to them
为原则而斗争比实践该原则要容易。
posted @ 2008-12-30 21:44 犹志 阅读(387) | 评论 (0)编辑 收藏
The important  thing in life is to have a great aim, and the determination to attain it.
人生的重要在于确立一个伟大的目标,并有决心使其实现。

Ideal is the beacon. Without ideal,there is no secure direction;without direction, there is no life
理想是指路明灯。没有理想,就没有坚定的方向;没有方向,就没有生活。
posted @ 2008-12-30 21:38 犹志 阅读(318) | 评论 (0)编辑 收藏
A man can succeed at almost anything for which he has unlimited enthusiam.
只要有无限的热情,一个人几乎可以在任何事情上取得成功。

If you would hit the mark, you must aim a little above it. Every arrow that flies feels the attraction of earth.
要想射中靶心,必须瞄准比靶略微高些,因为脱靶之箭都受到地心引力的影响。

If you doubt yourself, then indeed you stand on shaky ground.
如果你怀疑自己,那么你的立足点却是不稳固了。
posted @ 2008-12-30 21:31 犹志 阅读(180) | 评论 (0)编辑 收藏
If a jewel falls into the mire, it remains as precious as befour; and though dust should ascend to heaven, its former worthlessness will not be altered.
宝石及时落在泥潭里,仍是一样可贵;尘土纵然扬到天上,还是没有价值。

There is no royal road to science, and only those who do not dread the fatiguing climb of its steep path have a chance of gaining its luminous summit.
在科学上没有平坦大道,只有不畏劳苦沿着崎岖之路攀登的人,才有希望大道光辉的顶点。
posted @ 2008-12-30 21:24 犹志 阅读(156) | 评论 (0)编辑 收藏
在一些安全相关领域,为了防止资料外泄也许会禁止U盘的使用,或者只允许从U盘如入,而禁止向U盘写数据。这是怎么实现的呢?如果要从根本上禁止USB设备的使用,估计要用到USB hub的一些信息,对系统底层变成,禁止USB设备的使用,但对于一般人来说似乎没有必要这么做。就目前来看有两种简单的方式来实现禁止U盘写操作,具体方式如下:
(1)更改注册表
      打开注册表 “HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control”,然后创建一个名为“StorageDevicePolicies”的新key ,之后在“StorageDevicePolicies”下创建一个名为“WriteProtect”的DWORD value。当WriteProtect值为1时,用户将不能向USB设备写数据;WriteProtect为0时,则可以向USB设备写入数据。更改一下注册表项就能实现对U盘的访问策略,是不是很简单?
但这种方法也有弊端,就是只能使用在XP SP2以上(包括SP2)或者VSTA系统上,对于其他操作系统而言或许不能正常工作。
(2)使用gpedit更改系统策略
这种方式配置起来稍微繁琐一点儿,具体配置就不一一详述,可参阅相关文档。

以上两种做法孰好孰坏,还请各位使用者自己掂量。个人更倾向于第一种,呵呵,简单明了,对于做惯了开发的人来说比较实用。
posted @ 2008-12-30 14:40 犹志 阅读(920) | 评论 (0)编辑 收藏

Ultraedit,相信大部分开发人员都比较熟悉吧?各位在实用的过程中有没有注意到ultraedit较强的关联性呢?比如说,ultraedit已经打开了a.txt文件,此时在另外一个程序中对a.txt做了更改,ultraedit就能马上提示a.txt已被其他应用程序改变,提示用户是否需要重新载入。相信使用过ultraedit的人对这个印象比较深。这个功能是怎么实现的呢?在这里笔者略述一二。
要实现这样的功能,其实很简单,无怪乎调用系统函数,查看文件状态,比较文件更改时间等等,但总不至于用一线程一直读取文件状态吧?其实可以使用文件系统的事件通知机制来实现。
(1)对于dotnet应用来说,可以通过使用fileSystemWatcher组件来实现,只需要设置Path,Filter等属性,实现Changed,Created,deleted,renamed等事件即可。注意,Path指要监控的文件目录,Filter指文件类型,在这里可以使用通配符,比如*.*等等
(2)对于非dotnet应用,可以使用系统的文件操作,通过FindFirstChangeNotification,FindNextChangeNotificationFindCloseChangeNotification,以及相应的Wait Functions(包括 SignalObjectAndWait, WaitForSingleObject, and WaitForSingleObjectEx 以及 WaitForMultipleObjects, WaitForMultipleObjectsEx, MsgWaitForMultipleObjects, and MsgWaitForMultipleObjectsEx )来实现和fileSystemWatcher同样的功能,具体使用方法请参阅MSDN
在一些涉及到文件处理的程序中如果也能加上这种关联功能,则给用户的印象就比较深,而且更容易为用户所接受

posted @ 2008-12-30 14:37 犹志 阅读(316) | 评论 (0)编辑 收藏

2008年4月18日

最近在看以前的一些代码,发现程序中有一些函数返回指针,而且所返回的指针是stack指针,觉得很是奇怪,stack指针都是系统自己维护,出了作用域以后自动释放的,难道函数所返回的stack指针还能继续使用?以前的代码就是那样,而且运行也一直很正常,这是什么原因?觉得很是怪异。
为测试stack指针是否由系统管理,从函数中返回后是否继续可用,写了一些代码:
// TestPointer.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include 
<windows.h>
#include 
<stdlib.h>

typedef 
struct Person
{
    
int iAge;
    
int iWeight;
}
Person;

//Printf都做了什么?
//感觉调用printf时系统对stack进行了清理
char * GetString(void);
Person 
* GetPerson();

int main(int argc, char* argv[])
{
    printf(
"Hello World!\n");

    
char * pStr = GetString();

    
//感觉调用printf时系统对stack进行了清理
    printf("%s", pStr); //将这一句去掉后运行试试?

    Person 
* m_pPersion = GetPerson();
    
    printf(
"doooooo\n"); //将这一句去掉运行试试?
    printf("Age = %d, Weight = %d\n", m_pPersion->iAge, m_pPersion->iWeight);

    
return 0;
}


char * GetString(void)
{
    
//简单的可以理解为: 
    
//heap:是由malloc之类函数分配的空间所在地。地址是由低向高增长的。 
    
//stack:是自动分配变量,以及函数调用的时候所使用的一些空间。地址是由高向低减少的。
    
//栈(stack)内存的情况
    char szMessage[100];
    strcpy(szMessage, 
"this is just a test!\n");
    printf(
"%s", szMessage);
    
return szMessage;

    
//堆(heap)内存的情况
    /*char * pRet = (char *)malloc( 100 * sizeof(char));
    strcpy(pRet, "This is just a test!\n");
    return pRet;
*/
    
}


Person 
* GetPerson()
{
    
//stack
    Person m_Person;
    m_Person.iAge 
= 24;
    m_Person.iWeight 
= 55;

    
return &m_Person;

    
//更换成heap形式的又是怎样?
}


上述程序运行环境为:WindowsXP sp2 
+ Visual C++ Enterprise Edition 6.0 + Vs6Sp6
源代码
posted @ 2008-04-18 20:32 犹志 阅读(1704) | 评论 (5)编辑 收藏
仅列出标题  

导航

<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

统计

常用链接

留言簿(1)

随笔分类

随笔档案

文章档案

搜索

最新评论

阅读排行榜

评论排行榜