private void* TryGetConEmuHwnd()
{
if(!IsHandleCreated) // Without this check, getting the Handle would cause the control to be loaded, and AutoStartInfo be executed right in the .ctor, because the first call into this func goes in the .ctor
return null;
void* hwndConEmu = null;
WinApi.EnumWindowsProc callback = (hwnd, param) =>
{
*((void**)param) = hwnd;
return 0;
};
WinApi.EnumChildWindows((void*)Handle, (void*)Marshal.GetFunctionPointerForDelegate(callback), (IntPtr)(&hwndConEmu));
GC.KeepAlive(callback);
return hwndConEmu;
}