Fix winapi
This commit is contained in:
parent
0e4ce3762a
commit
2d738fa08b
|
@ -39,7 +39,7 @@ def format_system_message(errno):
|
||||||
result_buffer = ctypes.wintypes.LPWSTR()
|
result_buffer = ctypes.wintypes.LPWSTR()
|
||||||
buffer_size = 0
|
buffer_size = 0
|
||||||
arguments = None
|
arguments = None
|
||||||
bytes = ctypes.windll.kernel32.FormatMessageW(
|
format_bytes = ctypes.windll.kernel32.FormatMessageW(
|
||||||
flags,
|
flags,
|
||||||
source,
|
source,
|
||||||
message_id,
|
message_id,
|
||||||
|
@ -51,13 +51,13 @@ def format_system_message(errno):
|
||||||
# note the following will cause an infinite loop if GetLastError
|
# note the following will cause an infinite loop if GetLastError
|
||||||
# repeatedly returns an error that cannot be formatted, although
|
# repeatedly returns an error that cannot be formatted, although
|
||||||
# this should not happen.
|
# this should not happen.
|
||||||
handle_nonzero_success(bytes)
|
handle_nonzero_success(format_bytes)
|
||||||
message = result_buffer.value
|
message = result_buffer.value
|
||||||
ctypes.windll.kernel32.LocalFree(result_buffer)
|
ctypes.windll.kernel32.LocalFree(result_buffer)
|
||||||
return message
|
return message
|
||||||
|
|
||||||
|
|
||||||
class WindowsError(__builtin__.WindowsError):
|
class WindowsError(builtins.WindowsError):
|
||||||
"more info about errors at http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx"
|
"more info about errors at http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx"
|
||||||
|
|
||||||
def __init__(self, value=None):
|
def __init__(self, value=None):
|
||||||
|
@ -122,7 +122,7 @@ class MemoryMap(object):
|
||||||
FILE_MAP_WRITE = 0x2
|
FILE_MAP_WRITE = 0x2
|
||||||
filemap = ctypes.windll.kernel32.CreateFileMappingW(
|
filemap = ctypes.windll.kernel32.CreateFileMappingW(
|
||||||
INVALID_HANDLE_VALUE, p_SA, PAGE_READWRITE, 0, self.length,
|
INVALID_HANDLE_VALUE, p_SA, PAGE_READWRITE, 0, self.length,
|
||||||
unicode(self.name))
|
u(self.name))
|
||||||
handle_nonzero_success(filemap)
|
handle_nonzero_success(filemap)
|
||||||
if filemap == INVALID_HANDLE_VALUE:
|
if filemap == INVALID_HANDLE_VALUE:
|
||||||
raise Exception("Failed to create file mapping")
|
raise Exception("Failed to create file mapping")
|
||||||
|
|
Loading…
Reference in New Issue