规范化的C++编程方法备忘录 c++ for windows(2)

DllMain(说明:这不是一个API,但用对它很重要)
  详见http://msdn.microsoft.com/en-us/library/ms682583.aspx,(你在自己的MSDN光盘上也可找到。后同,略)需要强调的是Remarks中的
"The entry-point function should perform only simple initialization or termination tasks. It must not call the LoadLibrary or LoadLibraryEx function (or a function that calls these functions), ..."
"Calling functions that require DLLs other than Kernel32.dll may result in problems that are difficult to diagnose. For example, calling User, Shell, and COM functions can cause access violation errors, because some functions load other system components. Conversely, calling functions such as these during termination can cause access violation errors because the corresponding component may already have been unloaded or uninitialized."
当然,如果你还想干点儿别的,全看遍...

以下没特殊说明的,都假设你传入的参数都符合各API说明文档的要求。
InterlockedXXX APIs
即使失败时也不会返回失败。失败的原因是待同步检查的数据没有对齐到指针型整数的边界。

CloseHandle
是否成功仅依赖于句柄对应的驱动程序的行为。还有句柄必须有效的前提。

SetWindowLongPtr/GetWindowLongPtr
微软保证从窗口线程调用这两个API操纵已存在的合法内部字段时函数不会失败。对其他任何情况则不提供这种保证。

 

 

你可能感兴趣的:(编程,C++,windows,shell,api,文档)