本文整理汇总了C++中CAutoGeneralHandle::CloseHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ CAutoGeneralHandle::CloseHandle方法的具体用法?C++ CAutoGeneralHandle::CloseHandle怎么用?C++ CAutoGeneralHandle::CloseHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAutoGeneralHandle
的用法示例。
在下文中一共展示了CAutoGeneralHandle::CloseHandle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WinMain
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*cmdShow*/)
{
SetDllDirectory(L"");
CAutoGeneralHandle hReloadProtection = ::CreateMutex(NULL, FALSE, GetCacheMutexName());
if ((!hReloadProtection) || (GetLastError() == ERROR_ALREADY_EXISTS))
{
// An instance of TGitCache is already running
ATLTRACE("TGitCache ignoring restart\n");
return 0;
}
CGitStatusCache::Create();
CGitStatusCache::Instance().Init();
SecureZeroMemory(szCurrentCrawledPath, sizeof(szCurrentCrawledPath));
DWORD dwThreadId;
MSG msg;
TCHAR szWindowClass[] = {TGIT_CACHE_WINDOW_NAME};
// create a hidden window to receive window messages.
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = 0;
wcex.hCursor = 0;
wcex.hbrBackground = 0;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = 0;
RegisterClassEx(&wcex);
hWnd = CreateWindow(TGIT_CACHE_WINDOW_NAME, TGIT_CACHE_WINDOW_NAME, WS_CAPTION, 0, 0, 800, 300, NULL, 0, hInstance, 0);
hTrayWnd = hWnd;
if (hWnd == NULL)
{
return 0;
}
if (CRegStdDWORD(_T("Software\\TortoiseGit\\CacheTrayIcon"), FALSE)==TRUE)
{
SecureZeroMemory(&niData,sizeof(NOTIFYICONDATA));
DWORD dwMajor = 0;
DWORD dwMinor = 0;
GetShellVersion(&dwMajor, &dwMinor);
DWORD dwVersion = PACKVERSION(dwMajor, dwMinor);
if (dwVersion >= PACKVERSION(6,0))
niData.cbSize = sizeof(NOTIFYICONDATA);
else if (dwVersion >= PACKVERSION(5,0))
niData.cbSize = NOTIFYICONDATA_V2_SIZE;
else
niData.cbSize = NOTIFYICONDATA_V1_SIZE;
niData.uID = TRAY_ID; // own tray icon ID
niData.hWnd = hWnd;
niData.uFlags = NIF_ICON|NIF_MESSAGE;
// load the icon
niData.hIcon =
(HICON)LoadImage(hInstance,
MAKEINTRESOURCE(IDI_TGITCACHE),
IMAGE_ICON,
GetSystemMetrics(SM_CXSMICON),
GetSystemMetrics(SM_CYSMICON),
LR_DEFAULTCOLOR);
// set the message to send
// note: the message value should be in the
// range of WM_APP through 0xBFFF
niData.uCallbackMessage = TRAY_CALLBACK;
Shell_NotifyIcon(NIM_ADD,&niData);
// free icon handle
if(niData.hIcon && DestroyIcon(niData.hIcon))
niData.hIcon = NULL;
}
// Create a thread which waits for incoming pipe connections
CAutoGeneralHandle hPipeThread = CreateThread(
NULL, // no security attribute
0, // default stack size
PipeThread,
(LPVOID) &bRun, // thread parameter
0, // not suspended
&dwThreadId); // returns thread ID
if (!hPipeThread)
{
//OutputDebugStringA("TSVNCache: Could not create pipe thread\n");
//DebugOutputLastError();
return 0;
}
else hPipeThread.CloseHandle();
// Create a thread which waits for incoming pipe connections
CAutoGeneralHandle hCommandWaitThread = CreateThread(
NULL, // no security attribute
//.........这里部分代码省略.........