|
hello,
is it possible to create many different threads with one thread function by passing function pointer as lparam and calling it in thread?
i am trying to do something but... not successful
what i am doing wrong?
thank you for help in advance
DWORD CALLBACK mhThread(LPVOID lpParam)
{
(*lpParam)();
return 0;
}
void fff()
{
MessageBox(0,"ehlo","helo",0);
}
Screenshots::Screenshots()
{
hookHD = CreateThread(0, 0, mhThread, (*fff), 0, 0);
}
|
|
|
|
|
I think if you are going to use windows in your threads then each thread is going to have
to process window messages.
I'm not sure if I'm scared or curious to try the code you posted!
|
|
|
|
|
typedef void (*fffptr)(void);<br />
DWORD CALLBACK mhThread(LPVOID lpParam)<br />
{<br />
try{<br />
fffptr* function = static_cast<fffptr*>(lpParam);<br />
*function();<br />
}<br />
catch (std::bad_cast&)<br />
{<br />
}<br />
}
just something like that ( code might me invallid didnt test it or what... )
|
|
|
|
|
What Environment are you working in. CreateThread is essentially an SDK function. It can only be called as part of an environment you create first. The only sensible reason to call this function would be if you want to do something very smart that surpasses the capabilities of MFC, but it would require setting up accordingly. If you do not understand this requirement, the chances are that you do not need the options on offer there, and straight MFC would be your best option.
If you are working in MFC, you should rarely use 'CreateThread at all, if you do it could realy upset things, unless if you fully understand how it interracts with MFC. Instead you use:
AfxBeginThread(pFun,lpParam);
This starts a thread with pFun(lpParam);
It also has all the 'uglies' hidden inside the MFC Library.
Believe Me it is a lot easier to handle!
LateNightsInNewry
|
|
|
|
|
actually (*lpParam) is just a void pointer.. you have to define some Function Pointer to it to call it the required function!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
Here I found very simple way of doing this:
void fff()
{
MessageBox(0,"ehlo","helo",0);
}
DWORD CALLBACK mhThread(LPVOID lpParam)
{
((void(*)(void)) lpParam)();
return 0;
}
CreateThread(0, 0, mhThread, fff, 0, 0);
but... can somebody explain what does this mean: ((void(*)(void)) lpParam)(); ? it looks confusing...
and thank you again for replies
|
|
|
|
|
Simply a cast to a function pointer, the function returning no value and accepting no args. Maybe this clearify a bit the code:
typedef void (*LPFUNC)(void);
void mhThread(void * lpParam)
{
LPFUNC lpFunc = (LPFUNC) lpParam;
(*lpFunc)();
}
|
|
|
|
|
Someone in their article instructed users to "remove all post processing call to upx...". What does that mean and how do I do that?
Thanks,
BP
|
|
|
|
|
that could mean the Post-Build Step in Project Settings.
|
|
|
|
|
Thanks Chris, I'll check it out.
|
|
|
|
|
Hey all,
I have a strange question to ask. I have an app that performs some functions when a user is logged in or logged out. The functions are performed in separate threads and a dummy window is created so it can be used as the parent for windows that are popped up during this functionality.
Here is my problem: after I updated one of my machines to IE7, this functionality will only work if I am logged in and I run it manually. In debugging, the call to SetWindowPos never returned, even though the values were good. Other times, I try to circumvent the code and it fails elsewhere. I am using CreateWindow to create the dummy window and it contains a good window handle.
Any ideas what might be causing this problem? Any thoughts on what I can look at? I am completely stumped, my application doesn't even use anything from IE7 but after the install (and eventual uninstall) it still has a hangup.
|
|
|
|
|
What is IE7?
LateNightsInNewry
|
|
|
|
|
LateNightsInNewry wrote: What is IE7?
Why, it's the next step up from IE6, of course!
|
|
|
|
|
So, Let's Cut the Crapp, what's IE0, other than the step up from IE-1
LateNightsInNewry
|
|
|
|
|
LateNightsInNewry wrote: So, Let's Cut the Crapp
OK Internet Explorer Version 7
|
|
|
|
|
Wow
|
|
|
|
|
|
I was wondered why you written IE7
|
|
|
|
|
Because....
LateNightsInNewry wrote: What is IE7?
|
|
|
|
|
can anybody help me in implementing blowfish algorithm for encryption/decryption between client and server in unix enviornment.
i dont have a clue how to do it..
-- modified at 15:08 Thursday 16th November, 2006
|
|
|
|
|
poklmnbjihgyurybdgsyrwpkdfjisgcdhwkuqihwvdgfacekg;hprkla;lfjgupweorutypqpwliorujmnxb.
There's a clue, but sorry it's encrypted.
Chris Meech
I am Canadian. [heard in a local bar]
I agree with you that my argument is useless. [Red Stateler]
Hey, I am part of a special bread, we are called smart people [Captain See Sharp]
The zen of the soapbox is hard to attain...[Jörgen Sigvardsson]
I wish I could remember what it was like to only have a short term memory.[David Kentley]
|
|
|
|
|
Wow - you got off lightly.
Please don't post programming questions in the lounge ( as it said in big red letters as you typed this ), I've moved this to the most likely place for you to get an answer ( on this Windows programming site ).
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
use Google to find the Crypto++ library.
|
|
|
|
|
|
Dear OMC79
I think your best chance is to subscribe to the course, attend the lectures, read the books, and try again next year.
LateNightsInNewry
|
|
|
|