Chinaunix首页 | 论坛 | 博客
  • 博客访问: 351709
  • 博文数量: 157
  • 博客积分: 3001
  • 博客等级: 中校
  • 技术积分: 1330
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-06 13:47
文章分类

全部博文(157)

文章存档

2011年(1)

2010年(28)

2009年(124)

2008年(4)

我的朋友

分类: WINDOWS

2009-09-03 09:52:23

1. VS2003为啥能够attach一个进程就可以bebug,代码如何和dll联系起来的?
答:在编译代码之后,就会生成pdb文件,这个文件中记录了dll和代码之间的映射。
 
2. 在makefile.dcl中能够看到DllName           = ${ClientAppOLAddInDLL}${DllExt}
其中${ClientAppOLAddInDLL}是定义在别处的,查找方法:
VS2003  ctrl+Shift+F
弹出对话框在Look in 中点击带三个小点的浏览文件的对话框。选中要查找的目录。能够找到
ClientAppOLAddInDLL            = sieboladdin
好强大啊。

3.全局errno方式:就是在出现错误的时候,将错误代码记录到一个全局变量errno中。比如waitpid()函数在被信号中断的情况下,将errno设置为EINTR(一
宏定义常量)。这种方式解决了返回值方式遇到的返回值冲突问题,而且效率方面也是非常令人愉悦的。但是它要求用户在调用函数后检查errno的值,这种
保证是脆弱的,程序仍然有可能在不处理那些errno的情况下”安然”地运行,导致未定义的结果。另一个问题出在多线程方面,errno不是线程安全的,多个
线程操作同一个errno会造成混乱。

4. 先在硬盘上用写的方式打开一个.txt文件,关闭文件后将该文件从硬盘上删除,这个操作该怎样用程序来实现?
  _unlink,   _wunlink  
  Delete   a   file.  
   
  int   _unlink(   const   char   *filename   );  
   
  int   _wunlink(   const   wchar_t   *filename   );  
   
  Routine   Required   Header   Compatibility    
  _unlink     and     Win   95,   Win   NT    
  _wunlink     or     Win   NT    
   
   
  For   additional   compatibility   information,   see   Compatibility   in   the   Introduction.  
   
  Libraries  
   
  LIBC.LIB   Single   thread   static   library,   retail   version    
  LIBCMT.LIB   Multithread   static   library,   retail   version    
  MSVCRT.LIB   Import   library   for   MSVCRT.DLL,   retail   version    
   
   
  Return   Value  
   
  Each   of   these   functions   returns   0   if   successful.   Otherwise,   the   function   returns   –1   and   sets   errno   to   EACCES,   which   means   the   path   specifies   a   read-only   file,   or   to   ENOENT,   which   means   the   file   or   path   is   not   found   or   the   path   specified   a   directory.  
   
  Parameter  
   
  filename  
   
  Name   of   file   to   remove  
   
  Remarks  
   
  The   _unlink   function   deletes   the   file   specified   by   filename.   _wunlink   is   a   wide-character   version   of   _unlink;   the   filename   argument   to   _wunlink   is   a   wide-character   string.   These   functions   behave   identically   otherwise.  
   
  Generic-Text   Routine   Mappings  
   
  TCHAR.H   Routine     _UNICODE   &   _MBCS   Not   Defined   _MBCS   Defined   _UNICODE   Defined    
  _tunlink   _unlink   _unlink   _wunlink    
   
   
  Example    
   
  /*   UNLINK.C:   This   program   uses   _unlink   to   delete   UNLINK.OBJ.   */  
   
  #include    
   
  void   main(   void   )  
  {  
        if(   _unlink(   "unlink.obj"   )   ==   -1   )  
              perror(   "Could   not   delete   'UNLINK.OBJ'"   );  
        else  
              printf(   "Deleted   'UNLINK.OBJ'\n"   );  
  }  
   
   
  Output  
   
  Deleted   'UNLINK.OBJ'  
   
   
  File   Handling   Routines  
   
  See   Also       _close,   remove  
   
   
  remove,   _wremove  
  Delete   a   file.  
   
  int   remove(   const   char   *path   );  
   
  int   _wremove(   const   wchar_t   *path   );  
   
  Routine   Required   Header   Compatibility    
  remove     or     ANSI,   Win   95,   Win   NT    
  _wremove     or     Win   NT    
   
   
  For   additional   compatibility   information,   see   Compatibility   in   the   Introduction.  
   
  Libraries  
   
  LIBC.LIB   Single   thread   static   library,   retail   version    
  LIBCMT.LIB   Multithread   static   library,   retail   version    
  MSVCRT.LIB   Import   library   for   MSVCRT.DLL,   retail   version    
   
   
  Return   Value  
   
  Each   of   these   functions   returns   0   if   the   file   is   successfully   deleted.   Otherwise,   it   returns   –1   and   sets   errno   either   to   EACCES   to   indicate   that   the   path   specifies   a   read-only   file,   or   to   ENOENT   to   indicate   that   the   filename   or   path   was   not   found   or   that   the   path   specifies   a   directory.   This   function   fails   and   returns   -1   if   the   file   is   open.  
   
  Parameter  
   
  path  
   
  Path   of   file   to   be   removed  
   
  Remarks  
   
  The   remove   function   deletes   the   file   specified   by   path.   _wremove   is   a   wide-character   version   of   _remove;   the   path   argument   to   _wremove   is   a   wide-character   string.   _wremove   and   _remove   behave   identically   otherwise.   All   handles   to   a   file   must   be   closed   before   it   can   be   deleted.  
   
  Generic-Text   Routine   Mappings  
   
  TCHAR.H   Routine     _UNICODE   &   _MBCS   Not   Defined   _MBCS   Defined   _UNICODE   Defined    
  _tremove   remove   remove   _wremove    
   
   
  Example  
   
  /*   REMOVE.C:   This   program   uses   remove   to   delete   REMOVE.OBJ.   */  
   
  #include    
   
  void   main(   void   )  
  {  
        if(   remove(   "remove.obj"   )   ==   -1   )  
              perror(   "Could   not   delete   'REMOVE.OBJ'"   );  
        else  
              printf(   "Deleted   'REMOVE.OBJ'\n"   );  
  }  
   
   
  Output  
   
  Deleted   'REMOVE.OBJ'  
   
   
  File   Handling   Routines  
   
  See   Also       _unlink  
阅读(714) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~