Windows core programming

Source: Internet
Author: User
During this time, I read "Windows core programming", which is really nice. It is really a classic book.
After reading this book, I finally figured out what I didn't quite understand. I felt that I had a deep understanding of windows. Here I want to record the errors I have been writing Code .

1. Critical Section
I have never figured out the true meaning of the critical section. In the past, I used to write this statement to protect resources in the process:
Void threadfunction (pvoid pvparam)
{
// Create a critical section object
Resources to be protected
// Release the critical section object
}
The original critical section object must use global variables (that is, all threads are visible), and all threads here are gentlemen: that is, all threads use the critial section object to access resources, if a thread does not use this critial section object to access resources, the consequences will be very serious ,:)
Looking at the original code, it seems that every time a resource is accessed, a critical section object is created, which obviously cannot protect the resource.

2. Related window APIs
I always thought that setfocus (), getactivewindow (), setactivewindow () and other APIs are global. Now I understand that they are only for the current thread. If the window created by the current thread is not activated, getactivewindow () returns NULL. Now we finally understand the difference between getforegroundwindow () and getactivewindow (). Originally, we wrote an event in a button to get the handle returned by the two functions, and the handle returned in the result is equal, so I mistakenly understood these two APIs. Hoho ~~~, Learning Technology cannot be sloppy.
Now I understand how to use the attachtreadinput () API ,:)

3. Others
I have never paid attention to the "Auxiliary Function" of waitforsingleobject, and I always follow the example on msdn, but I don't understand why. Now we have figured out that waitforsingleobject will set the corresponding object to the "not notified" status.

Bytes -----------------------------------------------------------------------------------------------------------------------------
Among these many technical books, these two books are the most worth collecting:

Programming essence-microsft programming quality error-free CProgramResolution
Windows core programming

When I have the money, I must buy the e-file version of Windows core programming and add it to my favorites. If I have time, it is also a pleasure. ^_^

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.