I pass a address of USB_INSTACE_DATA
variable to function CreateThread()
like this. Is it safe to use, or I must use dynamic memory allocation for USB_INSTACE_DATA
data?
DWORD WINAPI MyThreadFunction(LPVOID lpParam);
void GetUSBInfo(PDEV_BROADCAST_DEVICEINTERFACE pDevInf, WPARAM wParam) {
USB_INSTACE_DATA data{ pDevInf, wParam };
DWORD dwThreadId;
auto hThreadArray = CreateThread(
NULL, // default security attributes
0, // use default stack size
MyThreadFunction, // thread function name
&data, // argument to thread function
0, // use default creation flags
&dwThreadId); // returns the thread identifier
}