/* * Return TRUE if comctl32.dll is version 4.71 or greater * otherwise return FALSE. */ LONG GetCommonControlVersion() { HMODULE hModule = GetModuleHandle("comctl32"); if (hModule) { FARPROC lpfnICCE = GetProcAddress(hModule, "InitCommonControlsEx"); if (NULL != lpfnICCE) { FARPROC lpfnDLLI = GetProcAddress(hModule, "DllInstall"); if (NULL != lpfnDLLI) { /* comctl 4.71 or greater */ // see if we can find out exactly DLLGETVERSIONPROC pDllGetVersion; pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hModule, "DllGetVersion"); /* Because some DLLs might not implement this function, you must test for it explicitly. Depending on the particular DLL, the lack of a DllGetVersion function can be a useful indicator of the version. */ if(pDllGetVersion) { DLLVERSIONINFO dvi; HRESULT hr; ZeroMemory(&dvi, sizeof(dvi)); dvi.cbSize = sizeof(dvi); hr = (*pDllGetVersion)(&dvi); if (SUCCEEDED(hr)) { return PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion); } } return PACKVERSION(4,71); } return PACKVERSION(4,7); } return PACKVERSION(4,0); } /* DLL not found */ return PACKVERSION(0,0); }
DWORD CMainWindow::GetDllVersion(LPCTSTR lpszDllName) { HINSTANCE hinstDll; DWORD dwVersion = 0; hinstDll = LoadLibrary(lpszDllName); if (hinstDll) { DLLGETVERSIONPROC pDllGetVersion; pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion"); if (pDllGetVersion) { DLLVERSIONINFO dvi; HRESULT hr; SecureZeroMemory(&dvi, sizeof(dvi)); dvi.cbSize = sizeof(dvi); hr = (*pDllGetVersion)(&dvi); if (SUCCEEDED(hr)) { dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion); } } FreeLibrary(hinstDll); } return dwVersion; }
/* This function can be used to retrieve version information from * Window's Shell and common control libraries (Comctl32.dll, * Shell32.dll, and Shlwapi.dll) The code was copied from the MSDN * article "Shell and Common Controls Versions" */ DWORD GetDllVersion(LPCTSTR lpszDllName) { HINSTANCE hinstDll; DWORD dwVersion = 0; /* For security purposes, LoadLibrary should be provided with a fully-qualified path to the DLL. The lpszDllName variable should be tested to ensure that it is a fully qualified path before it is used. */ hinstDll = LoadLibrary(lpszDllName); if (hinstDll) { DLLGETVERSIONPROC pDllGetVersion; pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion"); /* Because some DLLs might not implement this function, you must test for it explicitly. Depending on the particular DLL, the lack of a DllGetVersion function can be a useful indicator of the version. */ if (pDllGetVersion) { DLLVERSIONINFO dvi; HRESULT hr; ZeroMemory(&dvi, sizeof(dvi)); dvi.cbSize = sizeof(dvi); hr = (*pDllGetVersion)(&dvi); if (SUCCEEDED(hr)) dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion); } FreeLibrary(hinstDll); } return dwVersion; }
bool MusikTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip ) { bool bRes = false; #ifndef __WXMSW__ bRes = wxTaskBarIcon::SetIcon(icon,tooltip); #else if(m_dwShellDllVersion < PACKVERSION(5,00)) bRes = wxTaskBarIcon::SetIcon(icon,tooltip); else { // we can use NOTIFYICONDATA V2,where the szTip has 128 chars instead of 64 bRes = wxTaskBarIcon::SetIcon(icon,wxEmptyString);//just set the icon. if(!tooltip.empty()) {// now set the tooltip text with the help of NOTIFYICONDATA V2 struct. NOTIFYICONDATA nid; memset(&nid,0,sizeof(nid)); nid.cbSize = NOTIFYICONDATAW_V2_SIZE; nid.hWnd = (HWND)m_win->GetHWND(); nid.uID = 99; nid.uFlags = NIF_TIP; wxStrncpy(nid.szTip, tooltip.c_str(), WXSIZEOF(nid.szTip)); Shell_NotifyIcon(NIM_MODIFY, &nid); } } #endif return bRes; }
DWORD GetDllVersion(LPCTSTR lpszDllName) { DWORD version= 0; if (HINSTANCE dll= ::LoadLibrary(lpszDllName)) { DLLGETVERSIONPROC DllGetVersionFn= reinterpret_cast<DLLGETVERSIONPROC>(::GetProcAddress(dll, "DllGetVersion")); // Because some DLLs might not implement this function, you // must test for it explicitly. Depending on the particular // DLL, the lack of a DllGetVersion function can be a useful // indicator of the version. if (DllGetVersionFn) { DLLVERSIONINFO dvi; ZeroMemory(&dvi, sizeof dvi); dvi.cbSize = sizeof dvi; if (SUCCEEDED(DllGetVersionFn(&dvi))) version = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion); } ::FreeLibrary(dll); } return version; }
// get dll version DWORD getDllVersion(const _TCHAR *i_dllname) { DWORD dwVersion = 0; if (HINSTANCE hinstDll = LoadLibrary(i_dllname)) { DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion"); /* Because some DLLs may not implement this function, you * must test for it explicitly. Depending on the particular * DLL, the lack of a DllGetVersion function may * be a useful indicator of the version. */ if (pDllGetVersion) { DLLVERSIONINFO dvi; ZeroMemory(&dvi, sizeof(dvi)); dvi.cbSize = sizeof(dvi); HRESULT hr = (*pDllGetVersion)(&dvi); if (SUCCEEDED(hr)) dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion); } FreeLibrary(hinstDll); } return dwVersion; }
DWORD CWindowsVersion::GetDllVersion(LPCTSTR lpszDllName) { HINSTANCE hInstDll = LoadLibrary(lpszDllName); if(!hInstDll) return 0; DWORD dwVersion = 0; DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hInstDll, "DllGetVersion"); // Because some DLLs might not implement this function, you // must test for it explicitly. Depending on the particular // DLL, the lack of a DllGetVersion function can be a useful // indicator of the version. if(pDllGetVersion) { DLLVERSIONINFO dvi; HRESULT hr; ZeroMemory(&dvi, sizeof(dvi)); dvi.cbSize = sizeof(dvi); hr = (*pDllGetVersion)(&dvi); if(SUCCEEDED(hr)) { dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion); } } FreeLibrary(hInstDll); return dwVersion; }
void CLoginDlg::OnLButtonDown(UINT nFlags, CPoint point) { if(GetDllVersion(_T("comctl32.dll")) >= PACKVERSION(5,8)) { ShowLoginTooltip(FALSE); } COFSNcDlg2::OnLButtonDown(nFlags,point); }
bool HideActiveDesktop() { // returns true if the Active Desktop was enabled and has been hidden if (GetDllVersion(TEXT("shell32.dll")) >= PACKVERSION(4,71)) if (SHDesktopHTML()) return SUCCEEDED(EnableActiveDesktop(false)); return false; }
/* Create() */ BOOL CTrayIcon::Create(HWND hWnd,HICON hIcon,UINT nMsg,UINT nMenuId,UINT nBlankIconId/* = (UINT)-1L*/,LPCSTR lpcszTooltip/* = NULL*/) { Destroy(); if(!m_bIsValid) { // inizializza la struttura per l'icona nella tray area memset(&m_NotifyIconData,'\0',sizeof(m_NotifyIconData)); m_NotifyIconData.cbSize = sizeof(NOTIFYICONDATA); m_NotifyIconData.hWnd = m_hWndParent = hWnd; m_NotifyIconData.uID = m_nMenuId = nMenuId; m_NotifyIconData.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP; m_NotifyIconData.uCallbackMessage = nMsg; m_NotifyIconData.hIcon = m_hIcon = hIcon; // se win >= 2k inizializza anche per il balloon nativo if(m_winVer.GetCommonControlsVer() >= PACKVERSION(5,0)) { m_NotifyIconData.uFlags |= NIF_INFO; m_NotifyIconData.szInfoTitle[0] = '\0'; m_NotifyIconData.szInfo[0] = '\0'; m_NotifyIconData.uTimeout = BALLOON_DEFAULT_TIMEOUT * 1000L; m_NotifyIconData.dwInfoFlags = NIIF_NONE; } // imposta il testo del tooltip if(lpcszTooltip) { strcpyn(m_szToolTipText,lpcszTooltip,sizeof(m_szToolTipText)); strcpyn(m_NotifyIconData.szTip,m_szToolTipText,sizeof(m_NotifyIconData.szTip)); } else { memset(m_szToolTipText,'\0',sizeof(m_szToolTipText)); memset(m_NotifyIconData.szTip,'\0',sizeof(m_NotifyIconData.szTip)); } // crea l'icona nella tray area m_bIsValid = ::Shell_NotifyIcon(NIM_ADD,&m_NotifyIconData); // se viene specificato l'identificatore, imposta per il balloon esteso if((m_nBlankIconId = nBlankIconId)!=(UINT)-1L) { // inizializza per ricavare in seguito la posizione dell'icona m_TrayPosition.InitializeTracking(hWnd,nMenuId,nBlankIconId); // crea il balloon (esteso) m_TrayTooltip.Create(hWnd); m_TrayTooltip.SetSize(CPPToolTip::PPTTSZ_MARGIN_CX,4); m_TrayTooltip.SetSize(CPPToolTip::PPTTSZ_MARGIN_CY,4); } } return(m_bIsValid); }
DWORD GetWinVersion() { static DWORD c_dwWinVers=0; // check win version only once (will not change during application) if(!c_dwWinVers) { OSVERSIONINFO osvi; ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); // Initialize the OSVERSIONINFO structure. osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osvi); c_dwWinVers=PACKVERSION(osvi.dwMajorVersion,osvi.dwMinorVersion); } return c_dwWinVers; }
static void checkCommonControls() { #define PACKVERSION(major,minor) MAKELONG(minor,major) HINSTANCE hinstDll; DWORD dwVersion = 0; hinstDll = LoadLibrary(_T("comctl32.dll")); if(hinstDll) { DLLGETVERSIONPROC pDllGetVersion; pDllGetVersion = (DLLGETVERSIONPROC) GetProcAddress(hinstDll, "DllGetVersion"); if(pDllGetVersion) { DLLVERSIONINFO dvi; HRESULT hr; memzero(&dvi, sizeof(dvi)); dvi.cbSize = sizeof(dvi); hr = (*pDllGetVersion)(&dvi); if(SUCCEEDED(hr)) { dwVersion = PACKVERSION(dvi.dwMajorVersion, dvi.dwMinorVersion); } } FreeLibrary(hinstDll); } if(dwVersion < PACKVERSION(5,80)) { MessageBox(NULL, _T("Your version of windows common controls is too old for AirDC++ to run correctly, and you will most probably experience problems with the user interface. You should download version 5.80 or higher from the DC++ homepage or from Microsoft directly."), _T("User Interface Warning"), MB_OK); } }
void Initialize() { char buffer[_MAX_PATH]; if (GetTempPath(sizeof(buffer), buffer) == 0) { g_sTempPath = "c:\\"; } else { g_sTempPath = buffer; } g_bIsAdmin = ::IsAdmin(); g_bIsWindowsNT = ::IsWindowsNT(); g_bIE5 = (GetDllVersion("shdocvw.dll") >= PACKVERSION(5,0)); // Guess which mode ! g_sInternetMethod = (g_bIE5 ? "ie5" : "direct"); // The TeXLive registry key g_sRegKey = ConcatPath( TEXLIVE_REGENTRY, TEXLIVE_VERSION); // VarTexmf will be stored in temp dir g_sVarTexmf = ConcatPath(g_sTempPath, "TeX\\texmf"); // Get the cdrom texmf tree CString sDummyName; DWORD dwDummySize; #ifdef TEST g_sTexmfMain = "e:\\TeXLive\\setupw32"; #else GetExecutableDirectory(g_sTexmfMain, sDummyName, dwDummySize); #endif // Assume we are in \bin\win32 subdirectory, so: GetParentDirectory(g_sTexmfMain); GetParentDirectory(g_sTexmfMain); g_sDriveRootPath = g_sTexmfMain; g_sBinDir = ConcatPath(g_sTexmfMain, "bin\\win32"); g_sSetupw32 = ConcatPath(g_sTexmfMain, "setupw32"); g_sSupport = ConcatPath(g_sTexmfMain, "support"); g_sTexmfMain = ConcatPath(g_sTexmfMain, "texmf"); if (! DirectoryExists(g_sTexmfMain) ) { AfxMessageBox(IDS_NO_TEXLIVE_TEXMF, MB_OK | MB_ICONSTOP); exit(1); } if (! DirectoryExists(g_sBinDir) ) { AfxMessageBox(IDS_NO_TEXLIVE_BINARIES, MB_OK | MB_ICONSTOP); exit(1); } GetEditorLocation(g_sEditor); }
/* CTrayIcon() */ CTrayIcon::CTrayIcon() { m_bIsValid = FALSE; memset(&m_NotifyIconData,'\0',sizeof(m_NotifyIconData)); m_hWndParent = (HWND)NULL; m_hIcon = (HICON)NULL; m_hBalloonIcon = (HICON)NULL; m_bSharedIcon = TRUE; m_nMenuId = (UINT)-1; m_nBlankIconId = (UINT)-1L; memset(m_szToolTipText,'\0',sizeof(m_szToolTipText)); m_nTimeout = m_nTimerId = 0L; m_nBalloonType = (m_winVer.GetCommonControlsVer() >= PACKVERSION(5,0)) ? BALLOON_USE_NATIVE : BALLOON_USE_EXTENDED; m_nCloseIconID = 0; memset(m_szCssStyles,'\0',sizeof(m_szCssStyles)); }
BOOL BrowseFolder (CWnd *pParentWnd, CStdStringW &strText, UINT nHelpId, LPCTSTR szTitle /*= NULL*/, LPCTSTR szNote /*= NULL*/, CInputRestriction *pRestriction /*= NULL*/, long nType /*= 0*/, CStdStringW &szInitialPath /*= NULL*/) { if (GetDllVersion(_T("shell32.dll")) >= PACKVERSION(4, 71) || (!(nType & COD_EDITBOX) && !(nType & COD_FILEANDFOLDERS))) { CCChooseObjectDialog dlg (nHelpId); dlg.m_szNote = szNote; dlg.m_szTitle = szTitle; dlg.m_Edit.SetRestriction (pRestriction); dlg.SetObjectPath (szInitialPath); if (dlg.Browse (pParentWnd, nType)) { dlg.GetObjectPath (strText); return TRUE; } } else { CBrowseDirectoryNT4 dlg (nHelpId, pParentWnd, pRestriction, __LPCTSTR(szInitialPath)); // dlg.m_ofn.lpstrFilter = " \0.\0\0"; dlg.m_szNote = szNote, dlg.m_ofn.lpstrTitle = (LPSTR)szTitle; dlg.m_bInitialEmpty = (nType & COD_INITIALEMPTY) != 0; if (IOSGetFileAttributes (__LPCTSTR(szInitialPath)) != INVALID_FILE_ATTRIBUTES) dlg.m_ofn.lpstrInitialDir = __LPCTSTR(szInitialPath); if (dlg.DoModal () == IDOK) { strText = dlg.m_StrFolderName; return TRUE; } } return FALSE; }
bool CDllLoader::GetVersion( DWORD* pdwVersion ) { DLLGETVERSIONPROC pfDllGetVersion = ( DLLGETVERSIONPROC )GetProcAddress( "DllGetVersion" ); if ( pfDllGetVersion != 0 ) { DLLVERSIONINFO dvi; dvi.cbSize = sizeof( dvi ); HRESULT hr = pfDllGetVersion( &dvi ); if ( SUCCEEDED( hr ) ) { *pdwVersion = PACKVERSION( dvi.dwMajorVersion, dvi.dwMinorVersion ); return true; } } return false; }
bool MusikTaskBarIcon::ShowBalloonInfo(const wxString &sTitle,const wxString & sText) { bool bRes = true; if(m_dwShellDllVersion >= PACKVERSION(5,00)) { NOTIFYICONDATA nid; memset(&nid,0,sizeof(nid)); nid.cbSize = NOTIFYICONDATAW_V2_SIZE; nid.hWnd = (HWND)m_win->GetHWND(); nid.uID = 99; nid.uFlags = NIF_INFO; wxStrncpy(nid.szInfo, sText.c_str(), WXSIZEOF(nid.szInfo)); wxStrncpy(nid.szInfoTitle, sTitle.c_str(), WXSIZEOF(nid.szInfoTitle)); nid.dwInfoFlags = NIIF_NOSOUND|NIIF_INFO; nid.uTimeout = 5000; Shell_NotifyIcon(NIM_MODIFY, &nid); } else return false; return bRes; }
int WINAPI _tWinMain (HINSTANCE hThisInstance, UNUSED HINSTANCE hPrevInstance, UNUSED LPTSTR lpszArgument, UNUSED int nCmdShow) { MSG messages; /* Here messages to the application are saved */ WNDCLASSEX wincl; /* Data structure for the windowclass */ DWORD shell32_version; /* Initialize handlers for manangement interface notifications */ mgmt_rtmsg_handler handler[] = { { ready, OnReady }, { hold, OnHold }, { log, OnLogLine }, { state, OnStateChange }, { password, OnPassword }, { proxy, OnProxy }, { stop, OnStop }, { 0, NULL } }; InitManagement(handler); /* initialize options to default state */ InitOptions(&o); #ifdef DEBUG /* Open debug file for output */ if (!(o.debug_fp = fopen(DEBUG_FILE, "w"))) { /* can't open debug file */ ShowLocalizedMsg(IDS_ERR_OPEN_DEBUG_FILE, DEBUG_FILE); exit(1); } PrintDebug(_T("Starting OpenVPN GUI v%S"), PACKAGE_VERSION); #endif o.hInstance = hThisInstance; if(!GetModuleHandle(_T("RICHED20.DLL"))) { LoadLibrary(_T("RICHED20.DLL")); } else { /* can't load riched20.dll */ ShowLocalizedMsg(IDS_ERR_LOAD_RICHED20); exit(1); } /* Check version of shell32.dll */ shell32_version=GetDllVersion(_T("shell32.dll")); if (shell32_version < PACKVERSION(5,0)) { /* shell32.dll version to low */ ShowLocalizedMsg(IDS_ERR_SHELL_DLL_VERSION, shell32_version); exit(1); } #ifdef DEBUG PrintDebug(_T("Shell32.dll version: 0x%lx"), shell32_version); #endif /* Parse command-line options */ ProcessCommandLine(&o, GetCommandLine()); /* Check if a previous instance is already running. */ if ((FindWindow (szClassName, NULL)) != NULL) { /* GUI already running */ ShowLocalizedMsg(IDS_ERR_GUI_ALREADY_RUNNING); exit(1); } if (!GetRegistryKeys()) { exit(1); } if (!CheckVersion()) { exit(1); } if (!EnsureDirExists(o.log_dir)) { ShowLocalizedMsg(IDS_ERR_CREATE_PATH, _T("log_dir"), o.log_dir); exit(1); } BuildFileList(); if (!VerifyAutoConnections()) { exit(1); } GetProxyRegistrySettings(); #ifndef DISABLE_CHANGE_PASSWORD /* Initialize OpenSSL */ OpenSSL_add_all_algorithms(); ERR_load_crypto_strings(); #endif /* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadLocalizedIcon(ID_ICO_APP); wincl.hIconSm = LoadLocalizedIcon(ID_ICO_APP); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default color as the background of the window */ wincl.hbrBackground = (HBRUSH) COLOR_3DSHADOW; //COLOR_BACKGROUND; /* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) return 1; /* The class is registered, let's create the program*/ CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ szTitleText, /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ (int)CW_USEDEFAULT, /* Windows decides the position */ (int)CW_USEDEFAULT, /* where the window ends up on the screen */ 230, /* The programs width */ 200, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Run the message loop. It will run until GetMessage() returns 0 */ while (GetMessage (&messages, NULL, 0, 0)) { TranslateMessage(&messages); DispatchMessage(&messages); } /* The program return-value is 0 - The value that PostQuitMessage() gave */ return messages.wParam; }
bool isComctl(unsigned int maj , unsigned int min) { static unsigned int ver = 0; if (!ver) ver = getDllVersion(TEXT("comctl32.dll")); return ver >= (unsigned int)PACKVERSION(maj,min); }
void ShowActiveDesktop() { if (GetDllVersion(TEXT("shell32.dll")) >= PACKVERSION(4,71)) EnableActiveDesktop(true); }
INT_PTR CALLBACK DialogProc( HWND hWnd, // handle to dialog box UINT msg, // message WPARAM wParam, // first message parameter LPARAM lParam) // second message parameter { switch (msg) { case WM_INITDIALOG: { DWORD common_control_lib_version= GetDllVersion(_T("comctl32.dll")); g_update_common_ctrls = common_control_lib_version < PACKVERSION(5,80); // anything below 5.80 is worth upgrading //{ // ::MessageBox(hWnd, _T("ExifPro requires Common Controls library (ComCtl32.dll) version 4.71 or higher.\n\n") // _T("This library can be found on the Microsoft download site either as a stand-alone \n") // _T("component or part of the Internet Explorer 4.0 or later install package."), // g_INSTALLER, MB_OK | MB_ICONERROR); // ::EndDialog(hWnd, IDCANCEL); // return false; //} } if (g_update_common_ctrls) { // hide it--comctl updater needs to restart ::ShowWindow(::GetDlgItem(hWnd, IDC_RUN), SW_HIDE); } { HICON icon= ::LoadIcon(g_instance_handle, MAKEINTRESOURCE(IDR_MAINFRAME)); ::SendMessage(hWnd, WM_SETICON, ICON_SMALL, LPARAM(icon)); ::SendMessage(hWnd, WM_SETICON, ICON_BIG, LPARAM(icon)); } { HDC dc= ::GetWindowDC(hWnd); int log_pixels_y= ::GetDeviceCaps(dc, LOGPIXELSY); ::ReleaseDC(hWnd, dc); // create title font { HFONT font= static_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT)); LOGFONT lf; ::GetObject(font, sizeof lf, &lf); lf.lfWeight = FW_BOLD; lf.lfHeight = -MulDiv(18, log_pixels_y, 96); lf.lfWidth = 0; lf.lfQuality = ANTIALIASED_QUALITY; _tcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Tahoma")); g_fntTitle = ::CreateFontIndirect(&lf); } // create license info font { HFONT font= static_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT)); LOGFONT lf; ::GetObject(font, sizeof lf, &lf); lf.lfWeight = FW_NORMAL; lf.lfHeight = -MulDiv(9, log_pixels_y, 96); lf.lfWidth = 0; //lf.lfQuality = ANTIALIASED_QUALITY; _tcscpy_s(lf.lfFaceName, LF_FACESIZE, _T("Small Fonts")); g_fntLicense = ::CreateFontIndirect(&lf); } } g_camera_image = ::ImageList_LoadImage(g_instance_handle, MAKEINTRESOURCE(IDB_CAMERA), 48, 0, CLR_NONE, IMAGE_BITMAP, LR_CREATEDIBSECTION); { TCHAR path[2 * MAX_PATH]= _T("c:\\Program Files"); ITEMIDLIST* idl= 0; if (g_IsWindows64) { if (HINSTANCE dll= ::LoadLibrary(_T("shell32.dll"))) { typedef HRESULT (STDAPICALLTYPE *FN_SHGetKnownFolderIDList)(REFKNOWNFOLDERID, DWORD, HANDLE, PIDLIST_ABSOLUTE*); FN_SHGetKnownFolderIDList SHGetKnownFolderIDListFn= reinterpret_cast<FN_SHGetKnownFolderIDList>(::GetProcAddress(dll, "SHGetKnownFolderIDList")); if (SHGetKnownFolderIDListFn) { if (SHGetKnownFolderIDListFn(FOLDERID_ProgramFilesX64, 0, HANDLE(0), &idl) == S_OK) { ::SHGetPathFromIDList(idl, path); IMallocPtr malloc; if (::SHGetMalloc(&malloc) == 0) malloc->Free(idl); } } ::FreeLibrary(dll); } if (idl == 0) { TCHAR buffer[MAX_PATH]; DWORD d= ::GetEnvironmentVariable(_T("ProgramW6432"), buffer, MAX_PATH); if (d > 0) _tcscpy_s(path, MAX_PATH, buffer); } } else if (::SHGetSpecialFolderLocation(hWnd, CSIDL_PROGRAM_FILES, &idl) == 0) { ::SHGetPathFromIDList(idl, path); IMallocPtr malloc; if (::SHGetMalloc(&malloc) == 0) malloc->Free(idl); } _tcscat_s(path, MAX_PATH * 2, _T("\\ExifPro ") EP_VER); ::SetDlgItemText(hWnd, IDC_FOLDER, path); if (pfnAutoCompleteFn) (*pfnAutoCompleteFn)(::GetDlgItem(hWnd, IDC_FOLDER), SHACF_FILESYSTEM); } ::CheckDlgButton(hWnd, IDC_RUN, 1); ::CheckDlgButton(hWnd, IDC_ADD_ICON, 1); ::CheckDlgButton(hWnd, IDC_PROGRAMS, 1); if (HWND edit= ::GetDlgItem(hWnd, IDC_FOLDER)) ::SendMessage(edit, EM_LIMITTEXT, MAX_PATH - 16, 0); ::SendMessage(hWnd, WM_NEXTDLGCTL, WPARAM(::GetDlgItem(hWnd, IDOK)), 1L); return false; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: { TCHAR path[MAX_PATH]= { 0 }; if (::GetDlgItemText(hWnd, IDC_FOLDER, path, MAX_PATH) > 0) { HCURSOR cursor= ::SetCursor(::LoadCursor(0, IDC_WAIT)); if (InstallExifPro(path, !!::IsDlgButtonChecked(hWnd, IDC_ADD_ICON), !!::IsDlgButtonChecked(hWnd, IDC_PROGRAMS))) { if (!g_update_common_ctrls) // if comctl updated it waits for a restart { // launch ExifPro? if (::IsDlgButtonChecked(hWnd, IDC_RUN)) { TCHAR exif[MAX_PATH * 2]= { 0 }; AppendFileName(path, g_EXIF_APP, exif); ::ShellExecute(0, _T("open"), exif, 0, 0, SW_SHOWNORMAL); } else { ::MessageBox(hWnd, _T("ExifPro was installed successfully."), g_INSTALLER, MB_ICONINFORMATION | MB_OK); } } ::EndDialog(hWnd, wParam); } } } return true; case IDCANCEL: ::EndDialog(hWnd, wParam); return TRUE; case IDC_BROWSE_DIR: BrowseDir(hWnd); break; case ID_LICENSE: ShowLicense(); break; } return TRUE; case WM_ERASEBKGND: if (HDC dc= HDC(wParam)) { RECT rect; ::GetClientRect(hWnd, &rect); RECT rectTop= rect; rectTop.bottom = 50; rect.top = rectTop.bottom; ::SetBkMode(dc, OPAQUE); ::SetBkColor(dc, RGB(255,255,255)); ::ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rectTop, 0, 0, 0); ::ImageList_Draw(g_camera_image, 0, dc, 14, 7, ILD_NORMAL); HGDIOBJ hOld= ::SelectObject(dc, g_fntTitle); ::SetTextColor(dc, RGB(0,0,0)); const TCHAR* title= _T("ExifPro ") EP_VER _T(" Installer"); ::ExtTextOut(dc, 74, 13, 0, 0, title, _tcslen(title), 0); ::SelectObject(dc, hOld); ::SetBkColor(dc, ::GetSysColor(COLOR_3DSHADOW)); RECT rectLine= rectTop; rectLine.top = rectLine.bottom - 1; ::ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rectLine, 0, 0, 0); ::SetBkColor(dc, ::GetSysColor(COLOR_3DFACE)); ::ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rect, 0, 0, 0); hOld = ::SelectObject(dc, g_fntLicense); ::SetTextColor(dc, RGB(0,0,0)); const TCHAR* info= _T("By installing this product, you are agreeing to be bound by the terms of the license."); ::ExtTextOut(dc, rect.left + 16, rect.bottom - 16, 0, 0, info, _tcslen(info), 0); ::SelectObject(dc, hOld); } return true; } return 0; }
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 0, // default stack size CommandWaitThread, (LPVOID) &bRun, // thread parameter 0, // not suspended &dwThreadId); // returns thread ID if (!hCommandWaitThread) { //OutputDebugStringA("TSVNCache: Could not create command wait thread\n"); //DebugOutputLastError(); return 0; } // loop to handle window messages. BOOL bLoopRet; while (bRun) { bLoopRet = GetMessage(&msg, NULL, 0, 0); if ((bLoopRet != -1)&&(bLoopRet != 0)) { DispatchMessage(&msg); } } bRun = false; Shell_NotifyIcon(NIM_DELETE,&niData); CGitStatusCache::Destroy(); return 0; }
int WINAPI WinMain (HINSTANCE hThisInstance, UNUSED HINSTANCE hPrevInstance, LPSTR lpszArgument, UNUSED int nCmdShow) { HWND hwnd; /* This is the handle for our window */ MSG messages; /* Here messages to the application are saved */ WNDCLASSEX wincl; /* Data structure for the windowclass */ HWND hwndAbout; DWORD shell32_version; /* initialize options to default state */ init_options (&o); #ifdef DEBUG /* Open debug file for output */ if (!(o.debug_fp = fopen(DEBUG_FILE, "w"))) { /* can't open debug file */ ShowLocalizedMsg(GUI_NAME, ERR_OPEN_DEBUG_FILE, DEBUG_FILE); exit(1); } PrintDebug("Starting OpenVPN GUI v%s", GUI_VERSION); #endif o.hInstance = hThisInstance; if(!GetModuleHandle("RICHED20.DLL")) { LoadLibrary("RICHED20.DLL"); } else { /* can't load riched20.dll */ ShowLocalizedMsg(GUI_NAME, ERR_LOAD_RICHED20, ""); exit(1); } /* Check version of shell32.dll */ shell32_version=GetDllVersion("shell32.dll"); if (shell32_version < PACKVERSION(5,0)) { /* shell32.dll version to low */ ShowLocalizedMsg(GUI_NAME, ERR_SHELL_DLL_VERSION, shell32_version); exit(1); } #ifdef DEBUG PrintDebug("Shell32.dll version: 0x%lx", shell32_version); #endif /* Parse command-line options */ Createargcargv(&o, lpszArgument); /* Check if a previous instance is already running. */ if ((FindWindow (szClassName, NULL)) != NULL) { /* GUI already running */ ShowLocalizedMsg(GUI_NAME, ERR_GUI_ALREADY_RUNNING, ""); exit(1); } if (!GetRegistryKeys()) { exit(1); } #ifdef DEBUG PrintDebug("exe_path: %s", o.exe_path); PrintDebug("config_dir: %s", o.config_dir); PrintDebug("log_dir: %s", o.log_dir); PrintDebug("priority_string: %s", o.priority_string); PrintDebug("append_string: %s", o.append_string); PrintDebug("log_viewer: %s", o.log_viewer); PrintDebug("editor: %s", o.editor); PrintDebug("allow_edit: %s", o.allow_edit); PrintDebug("allow_service: %s", o.allow_service); PrintDebug("allow_password: %s", o.allow_password); PrintDebug("allow_proxy: %s", o.allow_proxy); PrintDebug("silent_connection: %s", o.silent_connection); PrintDebug("service_only: %s", o.service_only); PrintDebug("show_balloon: %s", o.show_balloon); PrintDebug("show_script_window: %s", o.show_script_window); PrintDebug("psw_attempts_string: %s", o.psw_attempts_string); PrintDebug("disconnect_on_suspend: %s", o.disconnect_on_suspend); PrintDebug("connectscript_timeout_string: %s", o.connectscript_timeout_string); PrintDebug("disconnectscript_timeout_string: %s", o.disconnectscript_timeout_string); PrintDebug("preconnectscript_timeout_string: %s", o.preconnectscript_timeout_string); #endif if (!CheckVersion()) { exit(1); } if (!BuildFileList()) { exit(1); } if (!VerifyAutoConnections()) { exit(1); } GetProxyRegistrySettings(); #ifndef DISABLE_CHANGE_PASSWORD /* Initialize OpenSSL */ OpenSSL_add_all_algorithms(); ERR_load_crypto_strings(); #endif /* The Window structure */ wincl.hInstance = hThisInstance; wincl.lpszClassName = szClassName; wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */ wincl.style = CS_DBLCLKS; /* Catch double-clicks */ wincl.cbSize = sizeof (WNDCLASSEX); /* Use default icon and mouse-pointer */ wincl.hIcon = LoadIcon (hThisInstance, MAKEINTRESOURCE(APP_ICON)); wincl.hIconSm = LoadIcon (hThisInstance, MAKEINTRESOURCE(APP_ICON)); wincl.hCursor = LoadCursor (NULL, IDC_ARROW); wincl.lpszMenuName = NULL; /* No menu */ wincl.cbClsExtra = 0; /* No extra bytes after the window class */ wincl.cbWndExtra = 0; /* structure or the window instance */ /* Use Windows's default color as the background of the window */ wincl.hbrBackground = (HBRUSH) COLOR_3DSHADOW; //COLOR_BACKGROUND; /* Register the window class, and if it fails quit the program */ if (!RegisterClassEx (&wincl)) return 1; /* The class is registered, let's create the program*/ hwnd = CreateWindowEx ( 0, /* Extended possibilites for variation */ szClassName, /* Classname */ szTitleText, /* Title Text */ WS_OVERLAPPEDWINDOW, /* default window */ (int)CW_USEDEFAULT, /* Windows decides the position */ (int)CW_USEDEFAULT, /* where the window ends up on the screen */ 230, /* The programs width */ 200, /* and height in pixels */ HWND_DESKTOP, /* The window is a child-window to desktop */ NULL, /* No menu */ hThisInstance, /* Program Instance handler */ NULL /* No Window Creation data */ ); /* Run the message loop. It will run until GetMessage() returns 0 */ while (GetMessage (&messages, NULL, 0, 0)) { TranslateMessage(&messages); DispatchMessage(&messages); } /* The program return-value is 0 - The value that PostQuitMessage() gave */ return messages.wParam; }
// // FUNCTION: gui_SetTrayIcon( PA_PluginParameters params ) // // PURPOSE: Put an icon in system tray // // COMMENTS: Flags and action determine what happens: Add, modify, delete, tool tip etc // Not available for pre-6.7 4D // IMPORTANT NOTE: This and sys_GetPrintJob use the same subclassed window procedure. // You cannot arbitrarily delete the function newProc // without breaking sys_GetPrintJob. // // DATE: dcc 08/04/01 // void gui_SetTrayIcon( PA_PluginParameters params ) { UINT iconHndl = 0; NOTIFYICONDATA nid; PNOTIFYICONDATA pnid; LONG_PTR returnValue = 0, iconID = 0, flags = 0, action = 0; char szTipParam[60], szBalloonInfo[255], szBalloonTitle[60]; char *pBalloonIconFlag; LONG_PTR arraySize = 0, procNbr = 0, storedProcNbr = 0, nbrParams = 0; LONG_PTR index; LONG_PTR errCode = 0; BOOL bFuncReturn = FALSE; BOOL shellOK = FALSE; //HWND hWnd; LONG_PTR count = -10; activeCalls.bTrayIcons = TRUE; pnid = &nid; count = count % 5; if ((sIsPriorTo67)) { // does not work with 6.5 plugin PA_ReturnLong( params, -1 ); return; } //hWnd = (HWND)PA_GetHWND(PA_GetWindowFocused()); // 3/2/04 Unnecessary nbrParams = getTrayIconParams(params, &action, &flags, &iconID, &procNbr, &iconHndl, szTipParam, szBalloonInfo, szBalloonTitle); index = findIconID( &startPtr, iconID, &storedProcNbr ); if (index == 0) { // not found if (isEmpty(startPtr)) { //processHandles.wpFourDOrigProc = (WNDPROC) SetWindowLong(windowHandles.fourDhWnd, GWL_WNDPROC, (LONG) newProc); // MJG 3/26/04 Replaced code above with function call. subclass4DWindowProcess(); } //add element to array bFuncReturn = insertIcon( &startPtr, iconID, procNbr); } else { if ((action == NIM_MODIFY) & (storedProcNbr != procNbr)) { // process nbr changed and modify request has been explicitly made bFuncReturn = updateIconIdProcNbr( &startPtr, iconID, procNbr ); } } //end if (index == 0) // must have version 5 of shell 32 for balloon feature // NOTIFYICONDATA structure is larger for balloon feature // also must be W2K for balloons if(GetDllVersion(TEXT("shell32.dll")) >= PACKVERSION(5,00)) { shellOK = TRUE; } if (shellOK) { if ((action >= 0) & (flags >= 0x010)) { nid.dwInfoFlags = 0; strcpy(nid.szInfo, szBalloonInfo); switch (szBalloonTitle[0]) // leading 1, 2, 0r 3 causes addition of icon { case '1' : pBalloonIconFlag = &szBalloonTitle[1]; if (*pBalloonIconFlag != '\0') { strcpy(nid.szInfoTitle, pBalloonIconFlag); nid.dwInfoFlags = NIIF_INFO; } break; case '2' : pBalloonIconFlag = &szBalloonTitle[1]; if (*pBalloonIconFlag != '\0') { strcpy(nid.szInfoTitle, pBalloonIconFlag); nid.dwInfoFlags = NIIF_WARNING; } break; case '3' : pBalloonIconFlag = &szBalloonTitle[1]; if (*pBalloonIconFlag != '\0') { strcpy(nid.szInfoTitle, pBalloonIconFlag); nid.dwInfoFlags = NIIF_ERROR; } break; default : strcpy(nid.szInfoTitle, szBalloonTitle); } nid.uTimeout = 10; if (flags & NIF_HIDE) { flags = flags & 0x001F; flags = flags | NIF_STATE; nid.dwState = NIS_HIDDEN; nid.dwStateMask = NIS_HIDDEN; } else { if (flags & NIF_SHOW) { flags = flags & 0x001F; flags = flags | NIF_STATE; nid.dwState = 0; nid.dwStateMask = NIS_HIDDEN; } } } } else { flags = (flags & 0xF); // must not send balloon flag when version not Win2K or above } nid.cbSize = sizeof(NOTIFYICONDATA); nid.hWnd = windowHandles.fourDhWnd; nid.uID = iconID; strcpy(nid.szTip, szTipParam); // can use this if balloon feature not available or not wanted nid.uVersion = 0; // REB 3/3/09 #16207 nid.uFlags = flags; // REB 2/18/10 #22656 switch (action) { case NIM_ADD : case NIM_MODIFY : case NIM_SETFOCUS : case NIM_SETVERSION : nid.uFlags = flags; nid.hIcon = (HICON)iconHndl; if (flags & NIF_MESSAGE) { nid.uCallbackMessage = WM_USER + 0x0021; // hex 21 is purely arbitrary } else { nid.uCallbackMessage = WM_NULL; } break; case NIM_DELETE : //if (index != 0) { // MJG 3/2/04 The element will still exist even if index is zero. returnValue = deleteIcon(&startPtr, iconID); //} } //bFuncReturn = Shell_NotifyIcon(NIM_SETVERSION, pnid); // REB 3/3/09 #16207 Force Win95 icon handling. bFuncReturn = Shell_NotifyIcon(action, pnid); //errCode = GetLastError(); //PA_ReturnLong( params, errCode ); PA_ReturnLong( params, (LONG_PTR)bFuncReturn ); }
// Choose video device dialog callback // INT_PTR CALLBACK WebCam::DialogProcChooseVideoDevice(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { WebCam* cam = reinterpret_cast<WebCam*>(GetWindowLongPtr(hwndDlg, GWLP_USERDATA)); switch(uMsg) { // Command message from dialog box // case WM_COMMAND: { switch (LOWORD(wParam)) { case IDOK: { bool bChanged = false; HWND hwndComboBox = GetDlgItem(hwndDlg, IDC_COMBO_VIDEO_DEVICE); unsigned int newDeviceType; if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_DEVICE_FILE)) { newDeviceType = deviceType_file; TCHAR filePathBuffer[MAX_PATH]; UINT filePathLength = GetDlgItemText(hwndDlg, IDC_FILE_DEVICE_PATH, filePathBuffer, MAX_PATH); wstring filePath; if (filePathLength) { filePath = filePathBuffer; } cam->SaveSetting(L"devicePath", filePath.c_str()); if ((cam->uDeviceType == deviceType_file) && (filePath != cam->sDevicePath)) { bChanged = true; } } else if (IsDlgButtonChecked(hwndDlg, IDC_RADIO_DEVICE_CAMERA)) { newDeviceType = deviceType_camera; LRESULT index = SendMessage( hwndComboBox, CB_GETCURSEL, 0, 0); if (index != CB_ERR) { LRESULT deviceIndex = SendMessage( hwndComboBox, CB_GETITEMDATA, (WPARAM)index, 0); VideoDevice *device = &(cam->videoDevices[deviceIndex]); cam->SaveSetting(L"devicePath", device->devicePath.c_str()); if ((cam->uDeviceType == deviceType_camera) && (device->devicePath != cam->sDevicePath)) { bChanged = true; } } } else { assert(false); } cam->SaveSetting(L"deviceType", newDeviceType); if (newDeviceType != cam->uDeviceType) { bChanged = true; } if (bChanged) { TCHAR message[256]; LoadString(GetModuleHandle(NULL), IDS_DEVICE_CHANGED, message, 255); TCHAR messageTitle[256]; LoadString(GetModuleHandle(NULL), IDS_DEVICE_CHANGED_TITLE, messageTitle, 255); MessageBox(hwndDlg, message, messageTitle, MB_OK | MB_ICONINFORMATION); } EndDialog(hwndDlg, (INT_PTR)1); break; } case IDCANCEL: EndDialog(hwndDlg, (INT_PTR)2); break; case IDC_RADIO_DEVICE_CAMERA: if (HIWORD(wParam) == BN_CLICKED) { EnableWindow(GetDlgItem(hwndDlg, IDC_COMBO_VIDEO_DEVICE), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_DEVICE_BROWSE), FALSE); } break; case IDC_RADIO_DEVICE_FILE: if (HIWORD(wParam) == BN_CLICKED) { EnableWindow(GetDlgItem(hwndDlg, IDC_COMBO_VIDEO_DEVICE), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_DEVICE_BROWSE), TRUE); } break; case IDC_FILE_DEVICE_BROWSE: if (HIWORD(wParam) == BN_CLICKED) { TCHAR szFilename[MAX_PATH]; GetDlgItemText(hwndDlg, IDC_FILE_DEVICE_PATH, szFilename, MAX_PATH); TCHAR szMyPictures[MAX_PATH]; BOOL bGotFolder; if (GetDllVersion(TEXT("shell32.dll")) >= PACKVERSION(5, 0)) { bGotFolder = SHGetSpecialFolderPath(hwndDlg, szMyPictures, CSIDL_MYPICTURES, FALSE); } else { bGotFolder = SHGetSpecialFolderPath(hwndDlg, szMyPictures, CSIDL_PERSONAL, FALSE); } OPENFILENAME ofn; ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwndDlg; ofn.lpstrFilter = TEXT("All Images\0*.bmp;*.dib;*.gif;*.jpg;*.jpe;*.jpeg;*.jif;*.png;*.tif;*.tiff;*.wmf;*.emf\0JPEG Images\0*.jpg;*.jpe;*.jpeg;*.jif\0GIF Images\0*.gif\0PNG Images\0*.png\0BMP Images\0*.bmp;*.dib\0TIFF Images\0*.tif;*.tiff\0Windows Meta File Images\0*.wmf;*.emf\0All Files\0*.*\0\0"); ofn.lpstrCustomFilter = NULL; ofn.nFilterIndex = 1; ofn.lpstrFile = szFilename; ofn.nMaxFile = MAX_PATH; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; if (bGotFolder) ofn.lpstrInitialDir = szMyPictures; else ofn.lpstrInitialDir = NULL; ofn.lpstrTitle = TEXT("Image File"); ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrDefExt = TEXT("jpg"); ofn.pvReserved = NULL; ofn.dwReserved = 0; BOOL bGotFilename = GetOpenFileName(&ofn); if (bGotFilename) { SetDlgItemText(hwndDlg, IDC_FILE_DEVICE_PATH, szFilename); } } break; } break; } // Initialize dialog // case WM_INITDIALOG: { WebCam* cam = reinterpret_cast<WebCam*>(lParam); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(cam)); cam->EnumerateVideoDevicesForComboBox(GetDlgItem(hwndDlg, IDC_COMBO_VIDEO_DEVICE)); if (cam->uDeviceType == deviceType_camera) { CheckDlgButton(hwndDlg, IDC_RADIO_DEVICE_CAMERA, BST_CHECKED); EnableWindow(GetDlgItem(hwndDlg, IDC_COMBO_VIDEO_DEVICE), TRUE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_DEVICE_BROWSE), FALSE); } else if (cam->uDeviceType == deviceType_file) { CheckDlgButton(hwndDlg, IDC_RADIO_DEVICE_FILE, BST_CHECKED); SetDlgItemText(hwndDlg, IDC_FILE_DEVICE_PATH, cam->sDevicePath.c_str()); EnableWindow(GetDlgItem(hwndDlg, IDC_COMBO_VIDEO_DEVICE), FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_FILE_DEVICE_BROWSE), TRUE); } else { assert(false); } break; } default: { return FALSE; } } return TRUE; }
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 TSVNCache is already running CTraceToOutputDebugString::Instance()(__FUNCTION__ ": TSVNCache ignoring restart\n"); return 0; } // set the current directory to the users temp dir TCHAR pathbuf[MAX_PATH] = { 0 }; GetTempPath(_countof(pathbuf), pathbuf); SetCurrentDirectory(pathbuf); apr_initialize(); svn_dso_initialize2(); svn_error_set_malfunction_handler(svn_error_handle_malfunction); g_SVNAdminDir.Init(); CSVNStatusCache::Create(); CSVNStatusCache::Instance().Init(); SecureZeroMemory(szCurrentCrawledPath, sizeof(szCurrentCrawledPath)); // create a hidden window to receive window messages. hWndHidden = CreateHiddenWindow(hInstance); hTrayWnd = hWndHidden; if (hWndHidden == NULL) { return 0; } if (CRegStdDWORD(L"Software\\TortoiseSVN\\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 = hWndHidden; niData.uFlags = NIF_ICON|NIF_MESSAGE; // load the icon niData.hIcon = (HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_TSVNCACHE), 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 unsigned int threadId = 0; CAutoGeneralHandle hPipeThread = (HANDLE)_beginthreadex(NULL, 0, PipeThread, &bRun, 0, &threadId); if (!hPipeThread) return 0; // Create a thread which waits for incoming pipe connections CAutoGeneralHandle hCommandWaitThread = (HANDLE)_beginthreadex(NULL, 0, CommandWaitThread, &bRun, 0, &threadId); if (hCommandWaitThread) { // loop to handle window messages. MSG msg; while (bRun) { const BOOL bLoopRet = GetMessage(&msg, NULL, 0, 0); if ((bLoopRet != -1)&&(bLoopRet != 0)) { DispatchMessage(&msg); } } } bRun = false; Shell_NotifyIcon(NIM_DELETE,&niData); CSVNStatusCache::Destroy(); g_SVNAdminDir.Close(); apr_terminate(); return 0; }
void CLoginDlg::OnClickButtonLogin() { UpdateData(); m_LoginStr.TrimLeft(); m_LoginStr.TrimRight(); CString LoginStr = m_LoginStr; int StartPortPos = -1; if((StartPortPos = LoginStr.Find(_T(":")))!=-1) { CString strPort = LoginStr.Mid(StartPortPos+1); LoginStr = LoginStr.Left(StartPortPos); int lPort = _ttol(strPort); } // Check: Login is E-Mail [9/2/2002] if(CheckEmailString(LoginStr)) { if(GetDllVersion(_T("comctl32.dll")) >= PACKVERSION(5,8)) { ShowLoginTooltip(FALSE); } WriteOptionInt(IDS_NETOPTIONS, IDS_USESSL, m_btnSSL.GetPressed()); if(!m_btnSavePassword.GetPressed()) { WriteOptionString(IDS_LOGIN, IDS_NICKNAME, _T("")); //WriteOptionString(IDS_LOGIN,IDS_PASSWORD,""); WriteOptionInt(IDS_LOGIN,IDS_REMEMBER,FALSE); } else { #ifndef RADIUS #define CRYPT_PROV_CONTAINER_NAME _T("Mediachase") #else #define CRYPT_PROV_CONTAINER_NAME _T("Radius-Soft") #endif #define CRYPT_KEYLENGTH 0x00280000L #define ENCRYPT_ALGORITHM CALG_RC4 #define ENCRYPT_BLOCK_SIZE 1 //CString strHashData; CCryptProv m_hCryptProv; CCryptDerivedKey m_hKey; HRESULT m_CryptInitErrorCode = m_hCryptProv.Initialize(PROV_RSA_FULL,CRYPT_PROV_CONTAINER_NAME,MS_DEF_PROV,NULL); if(m_CryptInitErrorCode==0x80090016) { m_CryptInitErrorCode = m_hCryptProv.Initialize(PROV_RSA_FULL,CRYPT_PROV_CONTAINER_NAME,MS_DEF_PROV,CRYPT_NEWKEYSET); } if(m_CryptInitErrorCode==S_OK) { // Create Key [9/12/2002] CCryptMD5Hash hMD5Hash; m_CryptInitErrorCode = hMD5Hash.Initialize(m_hCryptProv,CRYPT_PROV_CONTAINER_NAME); if(m_CryptInitErrorCode==S_OK) { m_CryptInitErrorCode = m_hKey.Initialize(m_hCryptProv,hMD5Hash,ENCRYPT_ALGORITHM,CRYPT_KEYLENGTH); if(m_CryptInitErrorCode==S_OK) { LPTSTR strHashData = NULL; if(LoginPassword2HexSTR(m_hKey,m_LoginStr,m_PasswordStr,&strHashData)==S_OK) { WriteOptionString(IDS_LOGIN,IDS_NICKNAME,strHashData); delete [] strHashData; strHashData = NULL; } } } } //WriteOptionString(IDS_LOGIN,IDS_NICKNAME,m_LoginStr); //Pack(m_PasswordStr,CString("vTsfO")); //WriteOptionString(IDS_LOGIN,IDS_PASSWORD,m_PasswordStr); //UnPack(m_PasswordStr,CString("vTsfO")); WriteOptionInt(IDS_LOGIN,IDS_REMEMBER,TRUE); } if(::IsWindow(GetParent()->GetSafeHwnd())) GetParent()->PostMessage(WM_INETLOGIN,0,0); } else { // Error; Onvalide Login [9/2/2002] // Show Ballon Tooltip [9/9/2004] if(GetDllVersion(_T("comctl32.dll")) >= PACKVERSION(5,8)) { ShowLoginTooltip(TRUE); } else { _SHOW_IBN_ERROR_DLG_OK(IDS_INVALID_LOGIN_OR_PASSWORD); } } // [9/2/2002] }
//---------------------------------------------------------------------------------------------------------- BOOL IsWinXP() { return GetWinVersion()>=PACKVERSION(5,1)?TRUE:FALSE; }