zoukankan      html  css  js  c++  java
  • 【Windows学习】解决python无法访问win64系统drivers目录重定向文件问题

     1 #!/usr/bin/env python
     2 # encoding: utf-8
     3 import ctypes
     4 import os
     5 class disable_file_system_redirection:
     6     """
     7     关闭64位系统的driver目录重定向
     8     """
     9     try:
    10         _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
    11         _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
    12     except Exception as e:
    13         print(str(e))
    14 
    15     def __enter__(self):
    16         self.old_value = ctypes.c_long()
    17         self.success = self._disable(ctypes.byref(self.old_value))
    18 
    19     def __exit__(self, type, value, traceback):
    20         if self.success:
    21             self._revert(self.old_value)
    22 
    23 with disable_file_system_redirection():
    24     if os.path.exists(r'C:WindowsSystem32drivers	est.sys'):
    25     print "yes"
    作者:gtea 博客地址:https://www.cnblogs.com/gtea
  • 相关阅读:
    typeof返回的结果必定是字符串
    coe文件格式
    求余算法的FPGA实现
    dBm
    信噪比
    增益
    总谐波失真THD
    基波与谐波
    Tco时候在干嘛?
    AXI4-Slave自定义IP设计
  • 原文地址:https://www.cnblogs.com/gtea/p/13088525.html
Copyright © 2011-2022 走看看