【Windows学习】解决python无法访问win64系统drivers目录重定向文件问题
#!/usr/bin/env python # encoding: utf-8 import ctypes import os class disable_file_system_redirection: """ 关闭64位系统的driver目录重定向 """ try: _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection except Exception as e: print(str(e)) def __enter__(self): self.old_value = ctypes.c_long() self.success = self._disable(ctypes.byref(self.old_value)) def __exit__(self, type, value, traceback): if self.success: self._revert(self.old_value) with disable_file_system_redirection(): if os.path.exists(r‘C:\Windows\System32\drivers\test.sys‘): print "yes"
相关推荐
朱培知浅ZLH 2020-11-16
Junzizhiai 2020-10-10
zhangbingb 2020-09-21
ROES 2020-08-17
ningningmingming 2020-07-28
Jiajinjin 2020-07-27
懒人的小窝 2020-07-04
wykpaopao 2020-06-28
lishaokang 2020-06-12
谢育政 2020-05-27
wanggongzhen 2020-05-26
ITlover00 2020-05-07
zhongcanw 2020-05-08
DAV数据库 2020-05-07
服务器端攻城师 2020-05-04
ningningmingming 2020-05-01
yuleng测试赛 2020-04-11
tvk 2020-04-06
Jieen 2020-03-23