title: Define thread in C++
body: <p>How do I start a thread using <code>_beginthreadex()</code>, making it execute <code>void myFunction(wchar_t *param);</code>?   I try to use this:</p>
  
  <pre><code>_beginthread(NULL, 0, myFunction, L"someParam", 0, &amp;ThreadID);
  </code></pre>
  
  <p>but there is compilation error:</p>
  
  <blockquote>
    <p>error C2664: '<em>beginthreadex' : cannot convert parameter 3 from 'void (</em>_cdecl *)(wchar_t *)' to 'unsigned int (__stdcall *)(void *)'. </p>
  </blockquote>
  
  <p>How I can resolve this error?   I seem able to do <code>_beginthread((void(*)(void*))myFunction, 0 , (void *)L"someParam");</code>. But for <code>_beginthreadex()</code> these casts don't seem to work. What do 
  I need to do?
  This code doesn't output anything. What's wrong?</p>
  
  <pre><code>unsigned int __stdcall myFunction( void *someParam )
  {
      printf("Hello world!");
      return 0;
  }
  
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      _beginthreadex(NULL, 0, myFunction, L"param", 0, NULL);
      return 0;
  }
  </code></pre>