@@ -167,25 +167,36 @@ strerror(e::Integer) = bytestring(ccall(:strerror, Ptr{UInt8}, (Int32,), e))
167
167
strerror () = strerror (errno ())
168
168
169
169
@windows_only begin
170
- GetLastError () = ccall (:GetLastError ,stdcall,UInt32,())
171
- function FormatMessage (e= GetLastError ())
172
- const FORMAT_MESSAGE_ALLOCATE_BUFFER = UInt32 (0x100 )
173
- const FORMAT_MESSAGE_FROM_SYSTEM = UInt32 (0x1000 )
174
- const FORMAT_MESSAGE_IGNORE_INSERTS = UInt32 (0x200 )
175
- const FORMAT_MESSAGE_MAX_WIDTH_MASK = UInt32 (0xFF )
176
- lpMsgBuf = Array (Ptr{UInt16})
177
- lpMsgBuf[1 ] = 0
178
- len = ccall (:FormatMessageW ,stdcall,UInt32,(Cint, Ptr{Void}, Cint, Cint, Ptr{Ptr{UInt16}}, Cint, Ptr{Void}),
179
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
180
- C_NULL , e, 0 , lpMsgBuf, 0 , C_NULL )
181
- p = lpMsgBuf[1 ]
182
- len == 0 && return utf8 (" " )
183
- len = len + 1
184
- buf = Array (UInt16, len)
185
- unsafe_copy! (pointer (buf), p, len)
186
- ccall (:LocalFree ,stdcall,Ptr{Void},(Ptr{Void},),p)
187
- return utf8 (UTF16String (buf))
188
- end
170
+ @doc """
171
+ GetLastError()
172
+
173
+ Call the Win32 `GetLastError` function [only available on Windows].
174
+ """ ->
175
+ GetLastError () = ccall (:GetLastError ,stdcall,UInt32,())
176
+
177
+ @doc """
178
+ FormatMessage(n=GetLastError())
179
+
180
+ Convert a Win32 system call error code to a descriptive string [only available on Windows].
181
+ """ ->
182
+ function FormatMessage (e= GetLastError ())
183
+ const FORMAT_MESSAGE_ALLOCATE_BUFFER = UInt32 (0x100 )
184
+ const FORMAT_MESSAGE_FROM_SYSTEM = UInt32 (0x1000 )
185
+ const FORMAT_MESSAGE_IGNORE_INSERTS = UInt32 (0x200 )
186
+ const FORMAT_MESSAGE_MAX_WIDTH_MASK = UInt32 (0xFF )
187
+ lpMsgBuf = Array (Ptr{UInt16})
188
+ lpMsgBuf[1 ] = 0
189
+ len = ccall (:FormatMessageW ,stdcall,UInt32,(Cint, Ptr{Void}, Cint, Cint, Ptr{Ptr{UInt16}}, Cint, Ptr{Void}),
190
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_MAX_WIDTH_MASK,
191
+ C_NULL , e, 0 , lpMsgBuf, 0 , C_NULL )
192
+ p = lpMsgBuf[1 ]
193
+ len == 0 && return utf8 (" " )
194
+ len = len + 1
195
+ buf = Array (UInt16, len)
196
+ unsafe_copy! (pointer (buf), p, len)
197
+ ccall (:LocalFree ,stdcall,Ptr{Void},(Ptr{Void},),p)
198
+ return utf8 (UTF16String (buf))
199
+ end
189
200
end
190
201
191
202
# # Memory related ##
0 commit comments