Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ctypes import *
- CreateFileW = windll.kernel32.CreateFileW
- SetFileInformationByHandle = windll.kernel32.SetFileInformationByHandle
- GetFinalPathNameByHandleW = windll.kernel32.GetFinalPathNameByHandleW
- GetLastError = windll.kernel32.GetLastError
- BUFSIZE=1024
- Path = create_unicode_buffer(BUFSIZE)
- hFile = CreateFileW(c_wchar_p('tempfile'), 0xC0010000, 7, 0, 1, 0x80, 0)
- VOLUME_NAME_DOS = 0
- FILE_NAME_NORMALIZED = 0
- fResult = GetFinalPathNameByHandleW(hFile, Path, BUFSIZE, FILE_NAME_NORMALIZED|VOLUME_NAME_DOS)
- print('fResult=' + str(fResult) + '\nPath=' + Path.value)
- FileDispositionInfo = 4
- class FILE_DISPOSITION_INFO(Structure):
- _fields_ = [("DeleteFile", c_bool)]
- fdi = FILE_DISPOSITION_INFO()
- fdi.DeleteFile = True
- fResult = SetFileInformationByHandle(hFile, FileDispositionInfo, byref(fdi), sizeof(FILE_DISPOSITION_INFO))
- fResult = GetFinalPathNameByHandleW(hFile, Path, BUFSIZE, FILE_NAME_NORMALIZED|VOLUME_NAME_DOS)
- err = GetLastError()
- print(fResult, err)
Advertisement
Add Comment
Please, Sign In to add comment