| |

VerySource

 Forgot password?
 Register
Search
View: 592|Reply: 1

About BeginThreadex () function

[Copy link]

3

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-14 16:00:01
| Show all posts |Read mode
Question (1) In a program of a member function of a class, I have the following statement:

h [0] = (HANDLE) :: _ beginthreadex (NULL, 0, bank_allocation, NULL, 0,&uld);

Where bank_allocation is the name of another member function in the class, which is declared as follows:

UINT __stdcall Cresource :: bank_allocation (LPVOID lpParam);

The compilation error (the error location is where beginThreadex () is used above), the prompt is as follows:
G:\resource\resource.cpp (100): error C2664: '_beginthreadex': cannot convert parameter 3 from 'unsigned int (void *)' to 'unsigned int (__stdcall *) (void *)'
        None of the functions with this name in scope match the target type
The reason for the error is the wrong parameter type. I can't figure it out. I have declared the type of the bank_allocation () function as UINT __stdcall.
(2) How to use beginThreadex to pass parameters to the new thread? For example, to pass an integer variable
thank you very much
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-6-11 22:00:01
| Show all posts
&uld is lpParam, passing in the pointer of uld structure. In bank_allocation(LPVOID lpParam); it will be fine after conversion
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list