Click here to Skip to main content
15,886,806 members
Please Sign up or sign in to vote.
1.50/5 (2 votes)
See more:
CreateThread() Routine Function Parameter as input i want to pass parameter which has return type and not void. How do i do that ?

Question 2. I also want to pass arguments. How do i do that ?

best intentions always. Thanks in advanced.

What I have tried:

I Tried to search startPage.com but i did not found any satisfaction result.
Thanks
Posted
Updated 26-May-16 7:12am
Comments
jeron1 25-May-16 12:47pm    
Have you seen the exmaple here? https://msdn.microsoft.com/en-us/library/windows/desktop/ms682516(v=vs.85).aspx

First: you google the Microsoft reference documentation.

To start some function with parameter you can use a wrapper function like that:

C++
void coolTheadFunc( void* data){
 //prepare the param
  DataStruct*params = (DataStruct*) data;
  myFunctionWithParams( ...);
}


After clicking a while you would had found this example as jeron did.
 
Share this answer
 
KarstenK answered question 2.

Your first question is a bit vague.

The return type of a ThreadProc is DWORD. It is not void.

ThreadProc callback function (Windows)[^]

If you are referring to the ThreadProc parameter, it is a pointer to void. As long as your function's parameter is a pointer, you can type cast the function to a ThreadProc.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900