We should forget about small efficiencies — Donald Knuth
26 Sep
Cool picture of all the new Vista Icons.
Besides, here is a tutorial from MSDN on how Microsoft makes their Windows XP icons.
Popularity: 56% [?]
26 Sep
Elevate through ShellExecute, from Vista Compatibility Team Blog.
We often get the question how to elevate a process through ShellExecute. From the docs it is not immediately clear. The trick is passing in “runas” in the lpVerb.
Here is a snippet to run notepad elevated.
#include “stdafx.h”
#include “windows.h”
#include “shellapi.h”
int _tmain(int argc, _TCHAR* argv[])
{
SHELLEXECUTEINFO shExecInfo;
shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
shExecInfo.fMask = NULL;
shExecInfo.hwnd = NULL;
shExecInfo.lpVerb = L”runas“;
shExecInfo.lpFile = L”notepad.exe”;
shExecInfo.lpParameters = NULL;
shExecInfo.lpDirectory = NULL;
shExecInfo.nShow = SW_MAXIMIZE;
shExecInfo.hInstApp = NULL;
ShellExecuteEx(&shExecInfo);
return 0;
}
Here is some screenshot:

Popularity: 51% [?]
7 Sep
Peer to Peer (p2p) in Windows Vista - People Near Me API from ebooth’s blog.
The overview of the p2p APIs available in Windows Vista is:
Popularity: 43% [?]
21 Aug
Buffering in HTTP.SYS, from Windows Core Networking Team’s blog.
故事內容是這樣的. IIS 5.0 之前是用 WinSock 來 implement, 這樣預設會打開 buffering 機制, 到了 Windows 2003 的 IIS 6.0 開始, 則改由 HTTP.SYS 來負責. 這樣反而會遇到 performance 下降的問題.
主要的理由我猜是 Nagle’s Algorithm. 現在的 socket 實作預設都會打開 TCP 的 Nagle’s Algorithm. 這個演算法簡單的說, 就是利用 delay ack 來減少網路上所傳輸 packet 量, 進而增加 TCP 的 performance. 不幸的是, Nagle’s Algorithm 對於小 packet 的幫助比較明顯, 大 packet 反而會有 latency 拉長的反效果. 換句話說, 對於一次傳輸大量資料的網路程式, 應該要 disable Nagle’s Algorithm 會有比較好的 performance.
目前在 Windows 2003 SP1 之後有一個 workaround 的辦法, 就是利用 HTTP_SEND_RESPONSE_FLAG_BUFFER_DATA 這個 flag. 雖然說還有另一個 flag 是 HTTP_SEND_RESPONSE_FLAG_ENABLE_NAGLING, 表示預設應該是 disable Nagle’s Algorithm, 不過我還是很好奇, 為甚麼預設明明 disable Nagle’s Algorithm, performance 沒上去的原因, 和一般網路程式 enable Nagle’s Algorithm 一樣呢?
Popularity: 43% [?]
16 Aug
How To Create a Self-Restartable Application, from CodeProject.
This article describes the way to add restarting support to your Win32 applications. Key pointer is as followings:
Old Instance Create a Mutex and create a new process with command retrieved by GetModuleFileName().
g_RA_hMutexOtherRestarting = ::CreateMutex( NULL, TRUE, RA_MUTEX_OTHER_RESTARTING);
TCHAR szAppPath[MAX_PATH] = {0};
::GetModuleFileName(NULL, szAppPath, MAX_PATH);
CreateProcess(NULL, szAppPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
New Instance wait for this mutex for release which means old instance has been dead.
// Releasing mutex signal that process finished DWORD dwWaitResult = WaitForSingleObject(g_RA_hMutexOtherRestarting, 0); if (dwWaitResult == WAIT_TIMEOUT) ::ReleaseMutex(g_RA_hMutexOtherRestarting); ::CloseHandle(g_RA_hMutexOtherRestarting);
Popularity: 33% [?]
5 Jul
CString Management, from CodeProject.
CStrings are a useful data type. They greatly simplify a lot of operations in MFC, making it much more convenient to do string manipulation. However, there are some special techniques to using CStrings, particularly hard for people coming from a pure-C background to learn. This essay discusses some of these techniques.
Much of what you need to do is pretty straightforward. This is not a complete tutorial on CStrings, but captures the most common basic questions
From this article, we can learn how to effectively use CStrings.
Popularity: 33% [?]
12 Jun
WTL Helper, from CodeProject.
Add-in for MS VC++.NET 2003 that helps to insert message handlers for WTL.
Popularity: 37% [?]