Date: 2023jan19
OS: WindowsFramework: MFC
Language: C/C++Q. MFC: AfxGetThread() returning NULL (solved)
A. This will occur when you're trying to do OLE
in a thread that wasn't started with AfxBeginThread()
So change
HANDLE h = (HANDLE) _beginthread(MyThreadMain, 0, arg);