CreateThread() Help!

CreateThread() in windows Kernel32.dll to create multithread Application.
How can i pass multiple parameters and how can i give an return value instead for just VOID?

Any help appreciated!

Thanks!
Any data pointer can be casted to 'void *', so you can pass a pointer to anything, such as a struct or a class, and cast it back to its original type on the other side. Likewise, if you have some complex result to return to the main thread, you can pass it back through the object.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct Params{
    SomeWhackyTypeA a;
    SomeWhackyTypeB b;
};

void foo(void *p){
    Params *params = (Params *)p;
    params->b = params->a.bar();
}

//...

Params params;
f(&params);
std::cout << params->b;

EDIT: Just so it's clear, LPVOID is an alias for void *.
Last edited on
Topic archived. No new replies allowed.