Showing tag results for Code

Jul 22, 2005
Post comments count0
Post likes count0

The importance of passing the WT_EXECUTELONGFUNCTION flag to QueueUserWorkItem

Raymond Chen

One of the flags to the QueueUserWorkItem function is WT_EXECUTELONGFUNCTION. The documentation for that flag reads The callback function can perform a long wait. This flag helps the system to decide if it should create a new thread. As noted in the documentation, the thread pool uses this flag to decide whether it should create a new thread...

Code
Jul 21, 2005
Post comments count0
Post likes count0

FindFirstFile is not a SQL query

Raymond Chen

The function is not a SQL query. It's a very simple directory enumerator. There is a slightly fancier version called , but even that function doesn't add much at present beyond filtering for directories or devices. You don't get to pass it sort criteria like or "return the files/directories sorted smallest file first", or "return the files/dir...

Code
Jul 13, 2005
Post comments count0
Post likes count0

Converting from traditional to simplified Chinese, part 3: Highlighting differences

Raymond Chen

One of the things that is interesting to me as a student of the Chinese languages is to recognize where the traditional and simplified Chinese scripts differ. Since this is my program, I'm going to hard-code the color for simplified Chinese script: maroon. To accomplish the highlighting, we take advantage of listview's custom-draw feature. Cus...

Code
Jul 12, 2005
Post comments count0
Post likes count0

Converting from traditional to simplified Chinese, part 2: Using the dictionary

Raymond Chen

Now that we have our traditional-to-simplified pseudo-dictionary, we can use it to generate simplified Chinese words in our Chinese/English dictionary. class StringPool { public: StringPool(); ~StringPool(); LPWSTR AllocString(const WCHAR* pszBegin, const WCHAR* pszEnd); LPWSTR DupString(const WCHAR* pszBegin) { return AllocString(pszBegi...

Code
Jul 11, 2005
Post comments count0
Post likes count0

Converting from traditional to simplified Chinese, part 1: Loading the dictionary

Raymond Chen

One step we had glossed over in our haste to get something interesting on the screen in our Chinese/English dictionary program was the conversion from traditional to simplified Chinese characters. The format of the hcutf8.txt file is a series of lines, each of which is a UTF-8 encoded string consisting of a simplified Chinese character followed ...

Code
Jul 6, 2005
Post comments count0
Post likes count1

What’s the point of DeferWindowPos?

Raymond Chen

The purpose of the DeferWindowPos function is to move multiple child windows at one go. This reduces somewhat the amount of repainting that goes on when windows move around. Take that DC brush sample from a few months ago and make the following changes: HWND g_hwndChildren[2]; BOOL OnCreate(HWND hwnd, LPCREATESTRUCT lpcs) { const static CO...

Code
Jul 5, 2005
Post comments count0
Post likes count0

Using script to query information from Internet Explorer windows

Raymond Chen

Some time ago, we used C++ to query information from the ShellWindows object and found it straightforward but cumbersome. This is rather clumsy from C++ because the ShellWindows object was designed for use by a scripting language like JScript or Visual Basic. Let's use one of the languages the ShellWindows object was designed for to enumera...

Code
Jul 1, 2005
Post comments count0
Post likes count0

I hope you weren’t using those undocumented critical section fields

Raymond Chen

I hope you weren't using those undocumented critical section fields, because in Windows Server 2003 Service Pack 1, they've changed. Mike Dodd tells an interesting story of a vendor who used reserved fields and then complained when the system started using them!

Code
Jul 1, 2005
Post comments count0
Post likes count2

What’s the difference between My Documents and Application Data?

Raymond Chen

The most important difference between My Documents and Application Data is that My Documents is where users store their files, whereas Application Data is where programs store their files. In other words, if you put something in CSIDL_MYDOCUMENTS (My Documents), you should expect the user to be renaming it, moving it, deleting it, emailing it to ...

Code
Jun 30, 2005
Post comments count0
Post likes count0

Beware of roaming user profiles

Raymond Chen

One of the less-known features of Windows is the roaming user profile. I know that this is not well-known because I often see suggestions that fail to take the roaming user profile scenario into account. Indeed, if your program behaves badly enough, you can cause data loss. (More on this later.) What is a roaming user profile? Well, your user pr...

Code