VC6.0 problems with threads created in the

Source: Internet
Author: User

VC in the Win32 console program, and then contains the MFC program, with CreateThread () to its corresponding function of the problem of parameters

 test.cpp : Defines the entry point for the console  application.//#include   "stdafx.h" #include   "test.h" #ifdef  _debug#define new debug_new# undef this_filestatic char this_file[] = __file__; #endif/////////////////////////////  The one and only application  objectcwinapp theapp;using namespace std;static int count=5;static handle  H1=NULL;STATIC HANDLE H2;DWORD DWFUN;INT FUNC1 (int *a); Void func2 (); int _ Tmain (int argc, tchar* argv[], tchar* envp[]) { int nretcode = 0;  h1=createthread (lpsecurity_attributes) null,   //  default security attribute pointer       0,     //  Thread stack size       (lpthread_start_routine) func1,   /Functions to be executed by the/  thread       (LPVOID)  &count,  //  parameters to be passed by the thread corresponding function       0,     //  the state at which the thread was created, 0 means immediate execution, and if create_suspended is pending after creation, ResumeThread () is required to execute      &dwfun);   //  thread identifier pointer  sleep (  closehandle (FUNC1);  exitthread (0);   return nretcode;} Note that the arguments in the function must use the pointer type, because LPVOID is a pointer type and is used in a function with the pointer reference  int func1 (INT *A) { printf ("This is  a running thread!\n%d\n ", 2**a);  return 0;}

VC6.0 problems with threads created in the

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.