打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
OpenFile 和 CreateFile 的区别
偶然被人问到OpenFile和CreateFile路径的问题,查了MSDN,然后做了一下Debug,记录一下心得
首先OpenFile是一个16-bit windows 的函数,现在再写新的程序应该用CreateFile来代替。
有一些老的code可能还是用的OpenFile来打开文件,如果现在升级到CreateFile,就需要注意路径的问题了。
OpenFile 可以只给一个文件名称,然后会有相应的路径搜索顺序:
  1. The directory where an application is loaded.

  2. The current directory.

  3. The Windows system directory.

  4. The 16-bit Windows system directory.

    There is not a function that retrieves the path of this directory, but it is searched.

  5. The Windows directory.

  6. The directories that are listed in the PATH environment variable.

在kernel32!openFile里面会调用到kernel32!SearchPath 函数来查找,这个行为是和loadlibrary一致的。
比如在c:\windows\system32下面有一个sicl32.dll的文件
如果用OpenFile("sicl32.dll"....)是可以打开成功的,因为里面会搜索到c:\windows\system32目录
但是用CreateFile("sicl32.dll"...)会失败,必须以“c:\\windows\\system32\sicl32.dll”为参数才能成功。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
WPF中播放Flash动画
错误模块路径:c:\Windows\system32\ntdll.dll
在 VC6 中使用 GdiPlus-安装
为什么句柄返回值不一致?
巧妙从进程中判断出病毒和木马 eNet硅谷动力
App Angles | wp7dev blog by Mick N
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服