| 发表于:2008-02-24 18:47:37 楼主 |
我想给dll实现一个回调,也就是说dll里面有一个定时器在定期执行一个操作,这个操作里有一步是回调当前程序的函数。比如说: 定义这个回调函数的指针类型 typedef bool (*encodefunc) (char *pfilename, char *upwd, char *spwd); 实现这个类型的函数 static bool processfile(char *filename, char *upwd, char *spwd) 这里的调用dll的api: encodefunc ef = &processfile; startmonitorfile(&ef); 现在的问题是,如果我传给dll并马上调用,就不会有问题。但是如果把这个值针在dll保存起来,等到定时器到时间时,再调用,那么就会得到access violation at address 00000000. read of address 00000000 这样的异常。感觉像是ef 这个的变量被清空了,如何才能长时间保存这个变量呢?我使用static的方式也无效。 |
|
|
|
|