When using winapi, there are often callback functions that only execute simple functions. I don't want to write them into a function separately, so that a function is marked as (global) static is independently suspended outside all classes, which is difficult to maintain. So I want to use Lambda to simplify it.
However, one thing that these callback functions have in common is that they all have a property called callback (also known as _ stdcall ). How can we make winapi call Lambda correctly?
The following is the code. Call enumwindows to display all window names and hwnd on the screen
# Include "iostream" # include "windows. H "using namespace STD; int main () {enumwindows ([] (hwnd, lparam) callback {char Buf [1000]; getwindowtext (hwnd, Buf, 1000 ); cout <Buf <"hwnd ="
Pitfall: how to convert a no capture Lambda function into a function pointer