|
|
Browse by Tags
All Tags » Code
Showing page 1 of 20 (194 total posts)
-
Last time, we learned about
the dangers of uninitialized floating
point variables
but left with a puzzle:
Why wasn't this caught during internal testing?
I dropped a hint when I described how SNaNs work:
You have to ask the processor to raise an exception when it
encounters a signaling NaN,
and the program disabled that exception.
Why was an ...
-
A colleague of mine related to me this story about uninitialized
floating point variables.
He had a function that went something like this,
simplified for expository purposes.
The infoType parameter specified which piece of
information you're requesting,
and depending on what you're asking for,
one or the other of the output parameters may not ...
-
A customer needed to generate an 8-byte unique value,
and their initial idea was to generate a GUID
and throw away the second half, keeping the first eight bytes.
They wanted to know if this was a good idea.
No, it's not a good idea.
The GUID generation algorithm
relies on the fact that it has all 16 bytes to use to ...
-
It's great when you have a tool to make programming easier,
but you still must understand what it does or you're
just replacing one set of problems with another set of more subtle
problems.
For example, we discussed earlier the importance of knowing
when your destructor runs.
Here's another example, courtesy of my colleague Chris Ashton.
This ...
-
Commenter Chris Becke asks
how the common controls convert ANSI parameters to Unicode,
since the common controls are Unicode internally.
Everything goes through CP_ACP,
pretty much by definition.
The ANSI code page is CP_ACP.
That's what ACP stands for, after all.
Now, there are some function families that do not use ANSI.
The console ...
-
There are many situations where you pass a structure to a function,
and the function fills in the structure with information you request.
In some cases, the function always fills in the entire structure
(example: GlobalMemoryStatus).
In other cases, you tell the function
which bits of information you care about,
to save the function the effort of ...
-
This is really just a corollary to
Why are DLLs unloaded in the ''wrong'' order.
Exactly the same logic that explains why DLLs are unloaded in the ''wrong''
order also explains why they are uninitialized in the ''wrong'' order.
Once you understand the first issue, the second comes for free;
just change DLL_PROCESS_DETACH to DLL_THREAD_DETACH
in ...
-
A customer noticed that if you add three to a process ID
and pass it to the OpenProcess function, it still
succeeds.
Why is that?
Well, first of all, I need to say up front that the behavior you're
seeing is an artifact of the implementation and is not part of the
contract.
You're passing intentionally invalid parameters,
what did you ...
-
In the suggestion box, Serge Wautier asked
why accelerators for hidden controls remain active.
He's apparently rather insistent because he
asked the question again a few months later.
Asking the same question multiple times reduces the likelihood
that I'll answer it.
Consider yourself lucky that I wrote this answer before I noticed
the ...
-
Shell extensions that create worker threads need to call the
SHGetInstanceExplorer function
so that Explorer will not exit while the worker thread is still running.
When your worker thread finishes, you release the IUnknown
that you obtained to tell the host program,
''Okay, I'm done now, thanks for waiting.''
You can read this contract from ...
1 ...
|
|
|