MSDNによると
lpWindowName [入力、オプション]
Type: LPCTSTR
The window name (the window's title). If this parameter is NULL, all window names match.
したがって、WindowName を「Mozilla Firefox」にすることはできません。これは、Firefox ウィンドウのタイトルが「Mozilla Firefox」ではなく、「Mozilla Firefox スタート ページ - Mozilla Firefox」または Web ページの名前に依存する可能性があるためです。ここに例の写真があります

したがって、コードは次のようになります (以下のコードは、上の画像のように正確なウィンドウのタイトル名「Mozilla Firefox スタート ページ - Mozilla Firefox」がある場合にのみ機能します。Windows 8.1 でテストしたところ、機能しました)。
void CaptureWindow()
{
RECT rc;
HWND hwnd = ::FindWindow(0, _T("Mozilla Firefox Start Page - Mozilla Firefox"));//::FindWindow(0,_T("ScreenCapture (Running) - Microsoft Visual Studio"));//::FindWindow(0, _T("Calculator"));//= FindWindow("Notepad", NULL); //You get the ideal?
if (hwnd == NULL)
{
return;
}
GetClientRect(hwnd, &rc);
//create
HDC hdcScreen = GetDC(NULL);
HDC hdc = CreateCompatibleDC(hdcScreen);
HBITMAP hbmp = CreateCompatibleBitmap(hdcScreen,
rc.right - rc.left, rc.bottom - rc.top);
SelectObject(hdc, hbmp);
//Print to memory hdc
PrintWindow(hwnd, hdc, PW_CLIENTONLY);
//copy to clipboard
OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(CF_BITMAP, hbmp);
CloseClipboard();
//release
DeleteDC(hdc);
DeleteObject(hbmp);
ReleaseDC(NULL, hdcScreen);
//Play(TEXT("photoclick.wav"));//This is just a function to play a sound, you can write it yourself, but it doesn't matter in this example so I comment it out.
}