Skip to content

Commit df74a99

Browse files
committed
expose syscall errno
1 parent 0689f87 commit df74a99

File tree

6 files changed

+803
-800
lines changed

6 files changed

+803
-800
lines changed

.idea/workspace.xml

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

comctl32.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -284,47 +284,47 @@ func init() {
284284
loadIconWithScaleDown = libcomctl32.NewProc("LoadIconWithScaleDown")
285285
}
286286

287-
func ImageList_Add(himl HIMAGELIST, hbmImage, hbmMask HBITMAP) int32 {
288-
ret, _, _ := syscall.Syscall(imageList_Add.Addr(), 3,
287+
func ImageList_Add(himl HIMAGELIST, hbmImage, hbmMask HBITMAP) (int32, syscall.Errno) {
288+
ret, _, err := syscall.Syscall(imageList_Add.Addr(), 3,
289289
uintptr(himl),
290290
uintptr(hbmImage),
291291
uintptr(hbmMask))
292292

293-
return int32(ret)
293+
return int32(ret), err
294294
}
295295

296-
func ImageList_AddMasked(himl HIMAGELIST, hbmImage HBITMAP, crMask COLORREF) int32 {
297-
ret, _, _ := syscall.Syscall(imageList_AddMasked.Addr(), 3,
296+
func ImageList_AddMasked(himl HIMAGELIST, hbmImage HBITMAP, crMask COLORREF) (int32, syscall.Errno) {
297+
ret, _, err := syscall.Syscall(imageList_AddMasked.Addr(), 3,
298298
uintptr(himl),
299299
uintptr(hbmImage),
300300
uintptr(crMask))
301301

302-
return int32(ret)
302+
return int32(ret), err
303303
}
304304

305-
func ImageList_Create(cx, cy int32, flags uint32, cInitial, cGrow int32) HIMAGELIST {
306-
ret, _, _ := syscall.Syscall6(imageList_Create.Addr(), 5,
305+
func ImageList_Create(cx, cy int32, flags uint32, cInitial, cGrow int32) (HIMAGELIST, syscall.Errno) {
306+
ret, _, err := syscall.Syscall6(imageList_Create.Addr(), 5,
307307
uintptr(cx),
308308
uintptr(cy),
309309
uintptr(flags),
310310
uintptr(cInitial),
311311
uintptr(cGrow),
312312
0)
313313

314-
return HIMAGELIST(ret)
314+
return HIMAGELIST(ret), err
315315
}
316316

317-
func ImageList_Destroy(hIml HIMAGELIST) bool {
318-
ret, _, _ := syscall.Syscall(imageList_Destroy.Addr(), 1,
317+
func ImageList_Destroy(hIml HIMAGELIST) (bool, syscall.Errno) {
318+
ret, _, err := syscall.Syscall(imageList_Destroy.Addr(), 1,
319319
uintptr(hIml),
320320
0,
321321
0)
322322

323-
return ret != 0
323+
return ret != 0, err
324324
}
325325

326-
func ImageList_DrawEx(himl HIMAGELIST, i int32, hdcDst HDC, x, y, dx, dy int32, rgbBk COLORREF, rgbFg COLORREF, fStyle uint32) bool {
327-
ret, _, _ := syscall.Syscall12(imageList_DrawEx.Addr(), 10,
326+
func ImageList_DrawEx(himl HIMAGELIST, i int32, hdcDst HDC, x, y, dx, dy int32, rgbBk COLORREF, rgbFg COLORREF, fStyle uint32) (bool, syscall.Errno) {
327+
ret, _, err := syscall.Syscall12(imageList_DrawEx.Addr(), 10,
328328
uintptr(himl),
329329
uintptr(i),
330330
uintptr(hdcDst),
@@ -338,53 +338,53 @@ func ImageList_DrawEx(himl HIMAGELIST, i int32, hdcDst HDC, x, y, dx, dy int32,
338338
0,
339339
0)
340340

341-
return ret != 0
341+
return ret != 0, err
342342
}
343343

344-
func ImageList_ReplaceIcon(himl HIMAGELIST, i int32, hicon HICON) int32 {
345-
ret, _, _ := syscall.Syscall(imageList_ReplaceIcon.Addr(), 3,
344+
func ImageList_ReplaceIcon(himl HIMAGELIST, i int32, hicon HICON) (int32, syscall.Errno) {
345+
ret, _, err := syscall.Syscall(imageList_ReplaceIcon.Addr(), 3,
346346
uintptr(himl),
347347
uintptr(i),
348348
uintptr(hicon))
349349

350-
return int32(ret)
350+
return int32(ret), err
351351
}
352352

353-
func InitCommonControlsEx(lpInitCtrls *INITCOMMONCONTROLSEX) bool {
354-
ret, _, _ := syscall.Syscall(initCommonControlsEx.Addr(), 1,
353+
func InitCommonControlsEx(lpInitCtrls *INITCOMMONCONTROLSEX) (bool, syscall.Errno) {
354+
ret, _, err := syscall.Syscall(initCommonControlsEx.Addr(), 1,
355355
uintptr(unsafe.Pointer(lpInitCtrls)),
356356
0,
357357
0)
358358

359-
return ret != 0
359+
return ret != 0, err
360360
}
361361

362-
func LoadIconMetric(hInstance HINSTANCE, lpIconName *uint16, lims int32, hicon *HICON) HRESULT {
362+
func LoadIconMetric(hInstance HINSTANCE, lpIconName *uint16, lims int32, hicon *HICON) (HRESULT, syscall.Errno) {
363363
if loadIconMetric.Find() != nil {
364-
return HRESULT(0)
364+
return HRESULT(0), syscall.ERROR_PROC_NOT_FOUND
365365
}
366-
ret, _, _ := syscall.Syscall6(loadIconMetric.Addr(), 4,
366+
ret, _, err := syscall.Syscall6(loadIconMetric.Addr(), 4,
367367
uintptr(hInstance),
368368
uintptr(unsafe.Pointer(lpIconName)),
369369
uintptr(lims),
370370
uintptr(unsafe.Pointer(hicon)),
371371
0,
372372
0)
373373

374-
return HRESULT(ret)
374+
return HRESULT(ret), err
375375
}
376376

377-
func LoadIconWithScaleDown(hInstance HINSTANCE, lpIconName *uint16, w int32, h int32, hicon *HICON) HRESULT {
377+
func LoadIconWithScaleDown(hInstance HINSTANCE, lpIconName *uint16, w int32, h int32, hicon *HICON) (HRESULT, syscall.Errno) {
378378
if loadIconWithScaleDown.Find() != nil {
379-
return HRESULT(0)
379+
return HRESULT(0), syscall.ERROR_PROC_NOT_FOUND
380380
}
381-
ret, _, _ := syscall.Syscall6(loadIconWithScaleDown.Addr(), 5,
381+
ret, _, err := syscall.Syscall6(loadIconWithScaleDown.Addr(), 5,
382382
uintptr(hInstance),
383383
uintptr(unsafe.Pointer(lpIconName)),
384384
uintptr(w),
385385
uintptr(h),
386386
uintptr(unsafe.Pointer(hicon)),
387387
0)
388388

389-
return HRESULT(ret)
389+
return HRESULT(ret), err
390390
}

0 commit comments

Comments
 (0)