Sign In
MSDN Blogs
Microsoft Blog Images
More ...
The Old New Thing
not actually
to establish a blogging point where individuals can enrich their learns on facilitating and leveraging .NET-related activities most effectively
Translate this page
Powered by
Microsoft® Translator
Common Tasks
RSS for posts
RSS for comments
Atom
OK
Search
Advanced search options...
Search In:
Everything
Blogs
Forums
People
Groups
Places
Pages
Date range:
All Time
Last Year
Last 6 Months
Last 3 Months
Last Month
Last Week
Last Two Days
News
Holy cow,
I wrote a book
!
Basics
Ground Rules
Suggestion Box
Contact Me
Disclaimers and such
Blogroll
The Daily WTF
Michael Kaplan
NT Debugging
Categories
Code
History
Non-Computer
Other (Computer)
Tips/Support
All tags
Browse by Tags
MSDN Blogs
>
The Old New Thing
>
All Tags
>
code
Browse by Tags
email
History
Microspeak
Modality
No good deed goes unpunished
Other
Things I've written that have amused other people
Time
Tips/Support
What a drag
Blog Post:
Fancy use of exception handling in FormatMessage leads to repeated "discovery" of security flaw
Raymond Chen - MSFT
Every so often, somebody "discovers" an alleged security vulnerability in the FormatMessage function. You can try it yourself: #include <windows.h> #include <stdio.h> char buf[2048]; char extralong[128*1024]; int __cdecl main(int argc, char **argv) { memset(extralong, 'x', 128...
on
10 Feb 2012
Blog Post:
What is the effect of memory-mapped file access on GetLastError()?
Raymond Chen - MSFT
A customer was using memory-mapped files and was looking for information as to whether access to the memory-mapped data modifies the value returned by GetLastError . A member of the kernel team replied, "No, memory-mapped I/O does not ever change the value returned by GetLastError...
on
9 Feb 2012
Blog Post:
The path-searching algorithm is not a backtracking algorithm
Raymond Chen - MSFT
Suppose your PATH environment variable looks like this: C:\dir1;\\server\share;C:\dir2 Suppose that you call LoadLibrary("foo.dll") intending to load the library at C:\dir2\foo.dll . If the network server is down, the LoadLibrary call will fail. Why doesn't it just skip the bad directory in...
on
8 Feb 2012
Blog Post:
The compatibility constraints of error codes, episode 2
Raymond Chen - MSFT
A customer reported an incompatibility in Windows 7: If A: is a floppy drive and they call LoadLibrary("A:\\foo.dll") and there is no disk in the drive, the LoadLibrary call fails with the error ERROR_ NOT_ READY . Previous versions of Windows failed with the error ERROR_ MOD_ NOT_ FOUND...
on
3 Feb 2012
Blog Post:
Does mapping the same shared memory two times in a process lead to double the address space usage?
Raymond Chen - MSFT
A customer designed a system which uses shared memory. Specifically, for each database file, they create a corresponding shared memory block of, say, 200 MB . Multiple clients which connect to the same database file use the same shared memory block. Naturally, if two processes each access the same database...
on
27 Jan 2012
Blog Post:
How do I disable the fault-tolerant heap?
Raymond Chen - MSFT
A while back, I linked to a talk by Silviu Calinoiu on the fault-tolerant heap . But what if you don't want the fault-tolerant heap? For example, during program development, you probably want to disable the fault-tolerant heap for your program: If the program is crashing, then it should crash so...
on
25 Jan 2012
Blog Post:
Can OANOCACHE be used for non-debug purposes?
Raymond Chen - MSFT
Friday asks whether OANOCACHE can be used for non-debug purposes, say to improve stability and/or speed . You can try, but it's not recommended. For one thing, it probably damages stability, because there are many applications out there which unwittingly rely on the BSTR cache to protect them from...
on
23 Jan 2012
Blog Post:
How do FILE_FLAG_SEQUENTIAL_SCAN and FILE_FLAG_RANDOM_ACCESS affect how the operating system treats my file?
Raymond Chen - MSFT
There are two flags you can pass to the CreateFile function to provide hints regarding your program's file access pattern. What happens if you pass either of them, or neither? Note that the following description is not contractual. It's just an explanation of the current heuristics (where...
on
20 Jan 2012
Blog Post:
Don't try to allocate memory until there is only x% free
Raymond Chen - MSFT
I have an ongoing conflict with my in-laws. Their concept of the correct amount of food to have in the refrigerator is "more than will comfortably fit." Whenever they come to visit (which is quite often), they make sure to bring enough food so that my refrigerator bursts at the seams, with vegetables...
on
18 Jan 2012
Blog Post:
How do I print non-error messages during compilation?
Raymond Chen - MSFT
Commenter Worf remarked, " My one wish is that #warning would be supported ." I always find it interesting when people say "I wish that Microsoft would stop following standards," since the #warning directive is nonstandard. The Microsoft C/C++ compiler implements the feature in a method...
on
13 Jan 2012
Blog Post:
Why did HeapFree fail with ERROR_POSSIBLE_DEADLOCK?
Raymond Chen - MSFT
A customer reported that they were receiving some assertion failures because the HeapFree function was failing with what they believed to be a valid heap block, and the GetLastError function reported that the reason for failure was ERROR_ POSSIBLE_ DEADLOCK . What's going on? One...
on
6 Jan 2012
Blog Post:
When DLL_PROCESS_DETACH tells you that the process is exiting, your best bet is just to return without doing anything
Raymond Chen - MSFT
When the DllMain function receives a reason code of DLL_ PROCESS_ DETACH , the increasingly-inaccurately-named lpReserved parameter to is used to indicate whether the process is exiting. And if the process is exiting, then you should just return without doing anything. No, really. ...
on
5 Jan 2012
Blog Post:
Creating context menus on menus
Raymond Chen - MSFT
Last week we looked at menu drag/drop. Another little-used menu feature added in Windows 2000 is the ability to show context menus on menus. The message is WM_ MENURBUTTONUP and the flag is TPM_ RECURSE . Let's demonstrate with a simple program. Start with the scratch program , and...
on
4 Jan 2012
Blog Post:
Using the MNS_DRAGDROP style: Menu rearrangement
Raymond Chen - MSFT
In order to do drag-drop rearrangement of menus, you need four things, most of which we already know how to do. Dragging an item out of a menu. Check . Dropping an item into a menu. Check . Connecting the drag with the drop. Rearranging menu items in response to the operation. Let's...
on
30 Dec 2011
Blog Post:
Using the MNS_DRAGDROP style: Dropping in
Raymond Chen - MSFT
Last time, we looked at using the MNS_ DRAGDROP style for dragging items out of a menu . Today, we'll look at dropping them in. Take the program from last time and make the following additions. First, let's add a second item to the menu. // resource header file #define IDM_MAIN 1 #define...
on
29 Dec 2011
Blog Post:
Using the MNS_DRAGDROP style: Dragging out
Raymond Chen - MSFT
Windows 2000 introduced the MNS_ DRAGDROP menu style, which permits drag/drop operations in a menu. Nobody uses this style, probably because it's totally undiscoverable by the end-user. But I'll write a sample program anyway. Mind you, I knew nothing about the MNS_ DRAGDROP menu style...
on
28 Dec 2011
Blog Post:
Introducing the for-if anti-pattern
Raymond Chen - MSFT
Over the years, I've seen a bunch of coding anti-patterns. I figured maybe I'll share a few. Today, I'll introduce what I'm calling the for-if anti-pattern, also known as " We'll sell you the whole seat, but you'll only need the edge ." This is a special case of the for-case anti-pattern, where all...
on
27 Dec 2011
Blog Post:
How do I get the full path for the target of a shortcut file?
Raymond Chen - MSFT
A customer was having trouble obtaining information from a shortcut file. "Here is a sample program that tries to print the target of a shortcut file, but it only gets the file name without a directory. How do I get the full path?" IShellLink *psl; ... code that loads the IShellLink omitted .....
on
23 Dec 2011
Blog Post:
How do I determine programmatically whether a particular language is LTR or RTL?
Raymond Chen - MSFT
Given an LCID , how does one determine whether the language lays out left-to-right or right-to-left? One suggestion was simply to hard-code the list of known right-to-left languages, and if the language isn't on the list, then assume that it is left-to-right. This technique is clearly fragile, because...
on
22 Dec 2011
Blog Post:
Paint messages will come in as fast as you let them
Raymond Chen - MSFT
There is a class of messages which are generated on demand rather than explicitly posted into a message queue. If you call GetMessage or PeekMessage and the queue is empty, then the window manager will look to see if one of these generated-on-demand messages is due, messages like WM_ TIMER...
on
19 Dec 2011
Blog Post:
Programmatically controlling which handles are inherited by new processes in Win32
Raymond Chen - MSFT
In unix, file descriptors are inherited by child processes by default. This wasn't so much an active decision as it was a consequence of the fork/exec model. To exclude a file descriptor from being inherited by children, you set the FD_ CLOEXEC flag on the file descriptor. Win32 sort of works...
on
16 Dec 2011
Blog Post:
What is the API for accessing content on SkyDrive?
Raymond Chen - MSFT
The last time I mentioned programmatic access to SkyDrive was last June , where I noted that the interface was given the confusing name Messenger Connect. At least now they renamed it to Live Connect , which is slightly less confusing. The SkyDrive folks have been pretty busy lately. A few days...
on
12 Dec 2011
Blog Post:
How can I tell whether a window is modal?
Raymond Chen - MSFT
A customer wanted a way to determine whether a particular window is modal. They listed a few methods they had tried but found that it didn't work and asked for assistance. As Eric Lippert is fond of saying, " First, write your spec ." Until you know what you want, you won't know how to get it. ...
on
12 Dec 2011
Blog Post:
Sure, I'm supposed to pass WT_EXECUTELONGFUNCTION if my function takes a long time, but how long is long?
Raymond Chen - MSFT
A customer contacted me to tell a story and ask a question. The customer discovered that in their code base, all calls to QueueUserWorkItem passed the WT_ EXECUTELONGFUNCTION flag, regardless of whether the function actually took a long time or not. Their program creates a large...
on
9 Dec 2011
Blog Post:
What does it mean when my program exits with the message "This application has requested the Runtime to terminate it in an unusual way"?
Raymond Chen - MSFT
You're running your program, and then it suddenly exits with the message This application has requested the Runtime to terminate it in an unusual way . What happened? That message is printed by the C runtime function abort , the same function that also causes your program to terminate with...
on
8 Dec 2011
Page 1 of 39 (953 items)
1
2
3
4
5
»