AllenDang / w32

A wrapper of windows apis for the Go Programming Language.
Other
761 stars 245 forks source link

Callback example #97

Open SForresterGG opened 1 year ago

SForresterGG commented 1 year ago

I am trying to use your EnumDisplayMonitors function, but I can't figure out how to pass a function pointer that works. Do you have examples of how to use this?

I've tried lots of things along the lines of

func monitorEnumProc(hMonitor w32.HMONITOR, hdc w32.HDC, lpRect *w32.RECT, lparam w32.LPARAM) bool { fmt.Println("hMonitor") return true }

func GetMonitors() {

funcPtr := monitorEnumProc
fptr := unsafe.Pointer(&funcPtr)
EnumDisplayMonitors(0, nil, uintptr(fptr), 0)

}

but it invariably crashes somewhere along the way, displaying something like Process 33436 has exited with status 3221226525

Any assistance greatly appreciated! -Steven