Sign in
MSDN Blogs
Microsoft Blog Images
More ...
The Old New Thing
Translate this page
Powered by
Microsoft® Translator
Common Tasks
RSS for posts
RSS for comments
Atom
OK
Search
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
Linker
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:
Who sends the initial WM_UPDATEUISTATE message?
Raymond Chen - MSFT
Last time , we looked at the confusingly-named WM_ UPDATEUISTATE and WM_ CHANGEUISTATE messages. But how does the whole indicator thingie get off the ground? The default state for a window is to show all indicators. But as a special trick, the dialog manager will send a WM_...
on
17 May 2013
Blog Post:
Untangling the confusingly-named WM_UPDATEUISTATE and WM_CHANGEUISTATE messages
Raymond Chen - MSFT
I always get confused by the WM_ UPDATEUISTATE and WM_ CHANGEUISTATE messages, and I have to go figure them out each time I need to mess with them. So this time, I'm going to write it down so I don't forget. Because the act of writing it down helps me to remember. It's like...
on
16 May 2013
Blog Post:
What does GDI use biXPelsPerMeter and SetBitmapDimensionEx for?
Raymond Chen - MSFT
What does GDI use BITMAPINFOHEADER. biXPelsPerMeter and SetBitmapDimensionEx for? Nothing. The BITMAPINFOHEADER. biXPelsPerMeter and BITMAPINFOHEADER. biYPelsPerMeter are completely ignored by GDI when loading...
on
15 May 2013
Blog Post:
How can I display a live screenshot of a piece of another application?
Raymond Chen - MSFT
Today's Little Program takes a rectangular portion of another application and continuously replicates it in its own client area. You might want to do this if you want to monitor a portion of an application like a custom progress bar, and the application doesn't use the Windows 7 taskbar progress indicator...
on
13 May 2013
Blog Post:
If you want to use a name for your file mapping, don't just use the name of the file itself
Raymond Chen - MSFT
The original question from the customer was why they couldn't get named file mappings to work at all, but it turns out that the reason is that they were using the full path to the file as the name, even though backslashes have special meaning in file mapping names . Okay, that problem can be solved...
on
10 May 2013
Blog Post:
Why am I getting LNK2019 unresolved external for my inline function?
Raymond Chen - MSFT
More than once, I'm seen somebody confused by how inline functions work. I have implemented a few inline functions in one of my cpp files, and I want to use it from other cpp files, so I declare them as extern . But sometimes I will get linker error 2019 (unresolved external) for the inline functions...
on
9 May 2013
Blog Post:
Mathematical formulas are designed to be pretty, not to be suitable for computation
Raymond Chen - MSFT
When you ask a mathematician to come up with a formula to solve a problem, you will get something that looks pretty, but that doesn't mean that it lends itself well to computation. For example, consider the binomial coefficient, traditionally written n C k or C ( n , k ) , and in more modern notation...
on
8 May 2013
Blog Post:
Reading mouse input from a console program, and programmatically turning off Quick Edit mode
Raymond Chen - MSFT
Today's Little program shows how to read mouse input from a console program. You might use this if you are writing a console-mode text editor with mouse support, or maybe you want to want to add mouse support to your roguelike game . But I'm not going to implement the game itself. Instead, I'm...
on
6 May 2013
Blog Post:
Creating a simple pidl: For the times you care enough to send the very fake
Raymond Chen - MSFT
I'll assume that we all know what pidls are and how the shell namespace uses them. That's the prerequisite for today. A simple pidl is an item ID list that refers to a file or directory that may not actually exist. It's a way of playing "what if": "If there were a file or directory at this location...
on
3 May 2013
Blog Post:
How do I get the current value of the RSP register from a C/C++ function? (No answer, but a solution.)
Raymond Chen - MSFT
A customer using Visual Studio wanted to know how to obtain the current value of the x64 RSP register from a C/C++ function. They noted that on the x86, you can drop to inline assembly, and on the ia64, you can use the __getReg intrinsic to retrieve the value of any register. There is no corresponding...
on
1 May 2013
Blog Post:
Getting the display name for a shell property
Raymond Chen - MSFT
Today's Little Program takes the symbolic name for a shell property and returns a string suitable for display to the end-user, translated into the user's specified display language. #include <windows.h> #include <ole2.h> #include <propsys.h> #include <propkey.h> #include <atlbase...
on
29 Apr 2013
Blog Post:
Another way to create a process with attributes, maybe worse maybe better
Raymond Chen - MSFT
Adam Rosenfield noted that " those sure are a lot of hoops you have to jump through to solve this unusual problem " of specifying which handles are inherited by a new process. Well, first of all, what's so wrong with that? You have to jump through a lot of hoops when you are in an unusual situation...
on
26 Apr 2013
Blog Post:
If you're going to use an interlocked operation to generate a unique value, you need to use it before it's gone
Raymond Chen - MSFT
Is the InterlockedIncrement function broken? One person seemed to think so. We're finding that the InterlockedIncrement is producing duplicate values. Are there are any know bugs in InterlockedIncrement ? Because of course when something doesn't work, it's because you are...
on
25 Apr 2013
Blog Post:
Dark corners of C/C++: The typedef keyword doesn't need to be the first word on the line
Raymond Chen - MSFT
Here are some strange but legal declarations in C/C++: int typedef a; short unsigned typedef b; By convention, the typedef keyword comes at the beginning of the line, but this is not actually required by the language. The above declarations are equivalent to typedef int a; typedef short unsigned...
on
24 Apr 2013
Blog Post:
Getting the current selection from an Explorer window
Raymond Chen - MSFT
Today's Little Program prints the current selection in all open Explorer windows. (This is an alternative to the C++ version that involves a ridiculous amount of typing.) var shellWindows = new ActiveXObject("Shell.Application").Windows(); for (var i = 0; i < shellWindows.Count; i++) { var...
on
22 Apr 2013
Blog Post:
Why does CoCreateInstance work even though my thread never called CoInitialize? The curse of the implicit MTA
Raymond Chen - MSFT
While developing tests, a developer observed erratic behavior with respect to CoCreateInstance : In my test, I call CoCreateInstance and it fails with CO_ E_ NOTINITIALIZED . Fair enough, because my test forgot to call CoInitialize . But then I went and checked...
on
19 Apr 2013
Blog Post:
Using opportunistic locks to get out of the way if somebody wants the file
Raymond Chen - MSFT
Opportunistic locks allow you to be notified when somebody else tries to access a file you have open. This is usually done if you want to use a file provided nobody else wants it. For example, you might be a search indexer that wants to extract information from a file, but if somebody opens the file...
on
15 Apr 2013
Blog Post:
Is it legal to call have a cross-process parent/child or owner/owned window relationship?
Raymond Chen - MSFT
A customer liaison asked whether it was legal to use SetParent to create a parent/child relationship between windows which belong to different processes. "If I remember correctly, the documentation for SetParent used to contain a stern warning that it is not supported, but that remark does...
on
12 Apr 2013
Blog Post:
The managed way to retrieve text under the cursor (mouse pointer)
Raymond Chen - MSFT
Today's Little Program is a managed version of the text-extraction program from several years ago . It turns out that it's pretty easy in managed code because the accessibility folks sat down and wrote a whole framework for you, known as UI Automation . (Some people are under the mistaken impression...
on
8 Apr 2013
Blog Post:
How do I wait until all processes in a job have exited?
Raymond Chen - MSFT
A customer was having trouble with job objects, specifically, the customer found that a WaitForSingleObject on a job object was not completing even though all the processes in the job had exited. This is probably the most frustrating part of job objects: A job object does not become...
on
5 Apr 2013
Blog Post:
Don't forget, the fourth parameter to ReadFile and WriteFile is sometimes mandatory
Raymond Chen - MSFT
The ReadFile and WriteFile functions have a parameter called lpNumberOfByteRead , which is documented as __out_opt LPDWORD lpNumberOfBytesRead, // or __out_opt LPDWORD lpNumberOfBytesWritten, "Cool," you think. "That parameter is optional, and I can safely...
on
4 Apr 2013
Blog Post:
How can I move an HTREEITEM to a new parent?
Raymond Chen - MSFT
Suppose you have a TreeView control, and you created an item in it, and you want to move the HTREEITEM to a new parent. How do you do that? You can't, at least not all in one motion. You will have to delete the HTREEITEM and then re-create it in its new location. If you want to move an HTREEITEM...
on
3 Apr 2013
Blog Post:
How do I convert a method name to a method index for the purpose of INTERFACEINFO?
Raymond Chen - MSFT
The IMessageFilter:: HandleIncomingCall method describes the incoming call by means of an INTERFACEINFO structure: typedef struct tagINTERFACEINFO { LPUNKNOWN pUnk; IID iid; WORD wMethod; } INTERFACEINFO, *LPINTERFACEINFO; The wMethod is a zero-based index of...
on
29 Mar 2013
Blog Post:
Using accessibility to monitoring windows as they come and go
Raymond Chen - MSFT
Today's Little Program monitors windows as they come and go. When people contemplate doing this, they come up with ideas like installing a WH_CBT hook or a WH_SHELL hook, but one of the major problems with those types of hooks is that they are injected hooks. Injection is bad for a number of reasons...
on
25 Mar 2013
Blog Post:
When will GetMessage return -1?
Raymond Chen - MSFT
A source of great consternation is the mysterious -1 return value from GetMessage : If there is an error, the return value is −1. For example, the function fails if hWnd is an invalid window handle or lpMsg is an invalid pointer. That paragraph has caused all sorts of havoc, because...
on
22 Mar 2013
Page 1 of 45 (1,114 items)
1
2
3
4
5
»