Click here to Skip to main content
15,907,001 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionProblem: ISAPI Extension Add custom header Pin
theoneneo244-Jan-11 22:47
theoneneo244-Jan-11 22:47 
QuestionProblem with WaitForSingleObject Pin
Amol Jaikar4-Jan-11 21:09
Amol Jaikar4-Jan-11 21:09 
AnswerRe: Problem with WaitForSingleObject Pin
Rajesh R Subramanian4-Jan-11 21:20
professionalRajesh R Subramanian4-Jan-11 21:20 
AnswerRe: Problem with WaitForSingleObject Pin
Richard MacCutchan4-Jan-11 21:27
mveRichard MacCutchan4-Jan-11 21:27 
AnswerRe: Problem with WaitForSingleObject PinPopular
bleedingfingers4-Jan-11 21:29
bleedingfingers4-Jan-11 21:29 
GeneralRe: Problem with WaitForSingleObject Pin
CPallini4-Jan-11 21:31
mveCPallini4-Jan-11 21:31 
GeneralRe: Problem with WaitForSingleObject Pin
Code-o-mat5-Jan-11 4:33
Code-o-mat5-Jan-11 4:33 
AnswerRe: Problem with WaitForSingleObject Pin
Aescleal5-Jan-11 7:25
Aescleal5-Jan-11 7:25 
it compiles 'cause Microsoft made a horrible decision with kernel handles in NT - they made them all void pointers so any type of pointer is compatible with them. You can pass any old rubbish pointer into most kernel functions where it expects a kernel handle and the compiler can't tell the difference.

Ironically this is unlike GDI handles which they'd already made specific structure pointers in Windows 3.1 - 3 years previously. Such is life... [1]

If you're prone to messing this sort of thing up a lot (as I am) then you can make things a bit more type safe in C++ by defining an overload of WaitForSingleObject:

DWORD WaitForSingleObject( CWinThread *thread_ptr, DWORD msec_to_wait )
{
return WaitForSingleObject( *thread_ptr, msec_to_wait );
}

which will catch this sort of error. It's a right pain in the bum to have to that though and you have to make sure that you include your API wrappers otherwise you're back to square one (and there's the old catch-22 - if you know enough to use the typesafe wrappers you know enough to not need to use them).

Cheers,

Ash

[1] I suppose the difference was that in Windows 3.1 if you got a handle wrong you had to reboot as you'd trashed the system, in NT you'd just mess up a process.
JokeRe: Problem with WaitForSingleObject Pin
Code-o-mat5-Jan-11 7:59
Code-o-mat5-Jan-11 7:59 
AnswerRe: Problem with WaitForSingleObject Pin
CPallini4-Jan-11 21:30
mveCPallini4-Jan-11 21:30 
AnswerRe: Problem with WaitForSingleObject Pin
Arman S.4-Jan-11 21:32
Arman S.4-Jan-11 21:32 
AnswerRe: Problem with WaitForSingleObject Pin
Frank Seidler4-Jan-11 21:34
Frank Seidler4-Jan-11 21:34 
QuestionDialogBox Control disappear Pin
MsmVc4-Jan-11 18:37
MsmVc4-Jan-11 18:37 
QuestionRe: DialogBox Control disappear Pin
Cool_Dev4-Jan-11 19:39
Cool_Dev4-Jan-11 19:39 
AnswerRe: DialogBox Control disappear Pin
MsmVc4-Jan-11 19:47
MsmVc4-Jan-11 19:47 
GeneralRe: DialogBox Control disappear Pin
Cool_Dev4-Jan-11 19:50
Cool_Dev4-Jan-11 19:50 
GeneralRe: DialogBox Control disappear Pin
MsmVc4-Jan-11 19:53
MsmVc4-Jan-11 19:53 
RantRe: DialogBox Control disappear Pin
Cool_Dev4-Jan-11 19:59
Cool_Dev4-Jan-11 19:59 
GeneralRe: DialogBox Control disappear Pin
MsmVc4-Jan-11 20:06
MsmVc4-Jan-11 20:06 
GeneralRe: DialogBox Control disappear Pin
Cool_Dev4-Jan-11 20:15
Cool_Dev4-Jan-11 20:15 
GeneralRe: DialogBox Control disappear Pin
MsmVc4-Jan-11 20:26
MsmVc4-Jan-11 20:26 
GeneralRe: DialogBox Control disappear Pin
Cool_Dev4-Jan-11 21:00
Cool_Dev4-Jan-11 21:00 
GeneralRe: DialogBox Control disappear Pin
MsmVc4-Jan-11 21:09
MsmVc4-Jan-11 21:09 
GeneralRe: DialogBox Control disappear Pin
Cool_Dev4-Jan-11 21:11
Cool_Dev4-Jan-11 21:11 
GeneralRe: DialogBox Control disappear Pin
MsmVc4-Jan-11 21:18
MsmVc4-Jan-11 21:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.