• Disable File System Redirector For Windows x64 (Python recipe)(转)


    This disables the Windows File System Redirector.
    When a 32 bit program runs on a 64 bit operating system the paths to C:/Windows/System32 automatically get redirected to the 32 bit version (C:/Windows/SysWow64), if you really do need to access the contents of System32, you need to disable the file system redirector first.

    import ctypes
    
    class disable_file_system_redirection:
        _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
        _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
        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)
    
    
    #Example usage
    import os
    
    path = 'C:\Windows\System32\msg.exe'
    
    print os.path.exists(path)
    with disable_file_system_redirection():
        print os.path.exists(path)
    print os.path.exists(path)
  • 相关阅读:
    Mysql密码操作
    最长公共子串(2017蓝桥杯省赛)
    一和零(leetcode)
    leetcode 235周赛
    袋子里最少数目的球(leetcode)
    第七周课后作业
    第四周jsp作业
    3.10
    3.4课堂练习
    DS博客作业05-查找批改
  • 原文地址:https://www.cnblogs.com/qq78292959/p/3435255.html
Copyright © 2020-2023  润新知