示例#1
0
//------------------------------------------------------------------------
// основная программа
//------------------------------------------------------------------------
void main(void)
{
	WORD i;

	// зачистим экран монитора
	system("cls");

	printf(" ******************************************\n");
	printf(" Module E14-140                            \n");
	printf(" Console example for DLL dynamic loading 	\n");
	printf(" ******************************************\n");

	// динамическая загрузка библиотеки "Lusbapi.dll"
	pLoadDll = new TLoadDll("Lusbapi.dll");
	if(!pLoadDll) AbortProgram(" Can't alloc 'TLoadDll' object!!!\n");
	// проверим смогли ли мы загрузить библиотеку?
	if(!pLoadDll->GetDllHinstance()) AbortProgram(" 'Lusbapi.dll' Dynamic Loading --> Bad\n");
	else printf(" 'Lusbapi.dll' Dynamic Loading --> OK\n");

	// адрес функции получения версии библиотеки
	pGetDllVersion GetDllVersion = (pGetDllVersion)pLoadDll->CallGetDllVersion();
	if(!GetDllVersion) AbortProgram(" Address of GetDllVersion() --> Bad\n");
	else printf(" Address of GetDllVersion() --> OK\n");

	// проверим версию используемой библиотеки Lusbapi.dll
	if((DllVersion = GetDllVersion()) != CURRENT_VERSION_LUSBAPI)
	{
		char String[128];
		sprintf(String, " Lusbapi.dll Version Error!!!\n   Current: %1u.%1u. Required: %1u.%1u",
											DllVersion >> 0x10, DllVersion & 0xFFFF,
											CURRENT_VERSION_LUSBAPI >> 0x10, CURRENT_VERSION_LUSBAPI & 0xFFFF);

		AbortProgram(String);
	}
示例#2
0
static void
AddTaskbarIcon()
{
    ZeroMemory(&niData, sizeof(NOTIFYICONDATA));

    ULONGLONG dllVersion = GetDllVersion(_T("shell32.dll"));
    if (dllVersion >= MAKEDLLVERULL(5, 0, 0, 0))
	niData.cbSize = sizeof(NOTIFYICONDATA);
    else
	niData.cbSize = NOTIFYICONDATA_V2_SIZE;

    // the ID number can be anything you choose
    niData.uID = TRAYICONID;

    // state which structure members are valid
    niData.uFlags = NIF_ICON | NIF_MESSAGE;

    // load the icon
    niData.hIcon =
	(HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_MAIN), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
	GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);

    // the window to send messages to and the message to send
    //              note:   the message value should be in the
    //                              range of WM_APP through 0xBFFF
    niData.hWnd = hWnd;
    niData.uCallbackMessage = SWM_TRAYMSG;

    Shell_NotifyIcon(NIM_ADD, &niData);

    // free icon handle
    if (niData.hIcon && DestroyIcon(niData.hIcon))
	niData.hIcon = NULL;
}
示例#3
0
void CMainWindow::ShowTrayIcon()
{
    // since our main window is hidden most of the time
    // we have to add an auxiliary window to the system tray
    SecureZeroMemory(&niData,sizeof(NOTIFYICONDATA));

    ULONGLONG ullVersion = GetDllVersion(_T("Shell32.dll"));
    if (ullVersion >= MAKEDLLVERULL(6,0,0,0))
        niData.cbSize = sizeof(NOTIFYICONDATA);
    else if(ullVersion >= MAKEDLLVERULL(5,0,0,0))
        niData.cbSize = NOTIFYICONDATA_V2_SIZE;
    else niData.cbSize = NOTIFYICONDATA_V1_SIZE;

    niData.uID = IDI_AACLR;
    niData.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP|NIF_INFO;

    niData.hIcon = (HICON)LoadImage(hResource, MAKEINTRESOURCE(IDI_AACLR),
        IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);
    niData.hWnd = *this;
    niData.uCallbackMessage = TRAY_WM_MESSAGE;
    niData.uVersion = 6;

    Shell_NotifyIcon(NIM_DELETE,&niData);
    Shell_NotifyIcon(NIM_ADD,&niData);
    Shell_NotifyIcon(NIM_SETVERSION,&niData);
    DestroyIcon(niData.hIcon);
}
示例#4
0
// Shell Versions:
//   Win95/WinNT 4.0                                maj=4 min=00
//   IE 3.x, IE 4.0 without Web Integrated Desktop  maj=4 min=00
//   IE 4.0 with Web Integrated Desktop             maj=4 min=71
//   IE 4.01 with Web Integrated Desktop            maj=4 min=72
//   Win2000                                        maj=5 min=00
BOOL GetShellVersion( LPDWORD pdwMajor, LPDWORD pdwMinor )
{
	//FBL_CHECK(!::IsBadWritePtr(pdwMajor, sizeof(DWORD)) && !::IsBadWritePtr(pdwMinor, sizeof(DWORD)));

	DLLVERSIONINFO dvi;
	memset(&dvi, 0, sizeof(dvi));
	dvi.cbSize = sizeof(dvi);
	BOOL b = GetDllVersion(TEXT("shell32.dll"), &dvi);

	if( b )
	{
		*pdwMajor = dvi.dwMajorVersion;
		*pdwMinor = dvi.dwMinorVersion;
	}
	else if( b == -1 )
	{
		// If DllGetVersion is not there, then the DLL is a version
		// previous to the one shipped with IE 4.x
		*pdwMajor = 4;
		*pdwMinor = 0;
		b = TRUE;
	}

	return b;
}
示例#5
0
MusikTaskBarIcon::MusikTaskBarIcon(wxFrame * frame) 
{
#ifdef __WXMSW__
    m_dwShellDllVersion = GetDllVersion(wxT("shell32.dll"));
#endif			
    m_pFrame = frame;
};
示例#6
0
//---------------------------------------------------------------------------
// попробуем зарузить модуль
//---------------------------------------------------------------------------
void __fastcall TMainForm::OnLoadUsbDevice(TMessage& Message)
{
	char ModuleName[7];
	WORD i;

	if(!Buffer) { Application->MessageBox("Не могу выделить память под буфер данных!", "ОШИБКА!!!", MB_OK + MB_ICONINFORMATION); Close(); return; }

	Application->ProcessMessages();

	// проверим версию используемой DLL библиотеки
	if(GetDllVersion() != CURRENT_VERSION_LUSBAPI)
	{
		AnsiString ErrorMessage = "Неправильная версия библиотеки Lusbapi.dll!\n";
		ErrorMessage += "Текущая: " + IntToStr(GetDllVersion() >> 0x10) + "." + IntToStr(GetDllVersion() & 0xFFFF) + "      ";
		ErrorMessage += "Требуется: " + IntToStr(CURRENT_VERSION_LUSBAPI >> 0x10) + "." + IntToStr(CURRENT_VERSION_LUSBAPI & 0xFFFF);
		Application->MessageBox(ErrorMessage.c_str(), "ОШИБКА!!!", MB_OK + MB_ICONINFORMATION);
		Close(); return;
	}
示例#7
0
文件: LoginDlg.cpp 项目: 0anion0/IBN
void CLoginDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
    if(GetDllVersion(_T("comctl32.dll")) >= PACKVERSION(5,8))
    {
        ShowLoginTooltip(FALSE);
    }

    COFSNcDlg2::OnLButtonDown(nFlags,point);
}
示例#8
0
BOOL GetDllVersion( LPCTSTR lpDLLPath, DLLVERSIONINFO* pDllVersionInfo )
{
	HINSTANCE hInstDLL = ::LoadLibrary(lpDLLPath);
	if( hInstDLL == NULL )
		return FALSE;

	BOOL bRet = GetDllVersion(hInstDLL, pDllVersionInfo) == NO_ERROR;
	::FreeLibrary(hInstDLL);
	return bRet;
}
示例#9
0
BOOL ColourButton::SubclassDlgItem(UINT id, CWnd* parent)
{
  if (CButton::SubclassDlgItem(id,parent))
  {
    if (GetDllVersion("comctl32.dll") < MAKELONG(0,6))
      ModifyStyle(0,BS_OWNERDRAW,0);
    return TRUE;
  }
  return FALSE;
}
示例#10
0
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;
}
示例#11
0
/*Shell32.dll 
Version Distribution Platform 
4.0 Windows 95 and Microsoft Windows NT 4.0 
4.71 Microsoft Internet Explorer 4.0. See note 1. 
4.72 Microsoft Internet Explorer 4.01 and Windows 98. See note 1. 
5.0 Windows 2000 and Windows Millennium Edition (Windows Me). See note 2. 
6.0 Windows XP 
6.0.1 Windows Vista 
6.1 Windows 7 

Shlwapi.dll 
Version Distribution Platform 
4.0 Windows 95 and Microsoft Windows NT 4.0 
4.71 Microsoft Internet Explorer 4.0. See note 1. 
4.72 Microsoft Internet Explorer 4.01 and Windows 98. See note 1. 
4.7 Internet Explorer 3.x 
5.0 Microsoft Internet Explorer 5 and Windows 98 SE. See note 2. 
5.5 Microsoft Internet Explorer 5.5 and Windows Millennium Edition (Windows Me) 
6.0 Windows XP and Windows Vista 
*/
DWORD GetSysVersionInfo(BOOL isie)
{
	if (isie)
	{
		CString shellPath = GetSysFolderPath(CSIDL_SYSTEM);
		shellPath +=_T("\\Shlwapi.dll");
		return GetDllVersion(shellPath);
	}
	else
	{
		return GetVersion();
	}
}
示例#12
0
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);
}
示例#13
0
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;
}
示例#14
0
void MainDialog::initNotifyIcon()
{
   // Fill the NOTIFYICONDATA structure and call Shell_NotifyIcon

   // zero the structure - note:	Some Windows funtions require this but
   //								I can't be bothered which ones do and
   //								which ones don't.
   ZeroMemory(&niData,sizeof(NOTIFYICONDATA));

   // get Shell32 version number and set the size of the structure
   //		note:	the MSDN documentation about this is a little
   //				dubious and I'm not at all sure if the method
   //				bellow is correct
   ULONGLONG ullVersion = GetDllVersion("Shell32.dll");
   if(ullVersion >= MAKEDLLVERULL(5, 0,0,0))
      niData.cbSize = sizeof(NOTIFYICONDATA);
   else niData.cbSize = NOTIFYICONDATA_V2_SIZE;

   // the ID number can be anything you choose
   niData.uID = TRAYICONID;

   // state which structure members are valid
   niData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;

   // load the icon
   niData.hIcon = (HICON)LoadImage(_hInstance,MAKEINTRESOURCE(IDI_STEALTHDLG),
                                   IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),
                                   LR_DEFAULTCOLOR);

   // the window to send messages to and the message to send
   //		note:	the message value should be in the
   //				range of WM_APP through 0xBFFF
   niData.hWnd = _hWnd;
   niData.uCallbackMessage = SWM_TRAYMSG;

   // tooltip message
   lstrcpyn(niData.szTip, "Time flies like an arrow but\n   fruit flies like a banana!", sizeof(niData.szTip)/sizeof(TCHAR));

   Shell_NotifyIcon(NIM_ADD,&niData);

   // free icon handle
   if(niData.hIcon && DestroyIcon(niData.hIcon))
      niData.hIcon = NULL;

   // call ShowWindow here to make the dialog initially visible
}
示例#15
0
// Initialize the window and tray icon
static BOOL
InitInstance(HINSTANCE hInstance, int /* nCmdShow */)
{
	// prepare for XP style controls
	InitCommonControls();

	HWND hWnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, (DLGPROC) MainDlgProc);
	if (!hWnd)
		return FALSE;

	ZeroMemory(&niData, sizeof(NOTIFYICONDATA));

	ULONGLONG ullVersion = GetDllVersion(_T("shell32.dll"));
	if (ullVersion >= MAKEDLLVERULL(5, 0, 0, 0))
		niData.cbSize = sizeof(NOTIFYICONDATA);
	else
		niData.cbSize = NOTIFYICONDATA_V2_SIZE;

	// the ID number can be anything you choose
	niData.uID = TRAYICONID;

	// state which structure members are valid
	niData.uFlags = NIF_ICON | NIF_MESSAGE;

	// load the icon
	niData.hIcon =
		(HICON) LoadImage(hInstance, MAKEINTRESOURCE(IDI_MAIN), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON),
				  GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);

	// the window to send messages to and the message to send
	//              note:   the message value should be in the
	//                              range of WM_APP through 0xBFFF
	niData.hWnd = hWnd;
	niData.uCallbackMessage = SWM_TRAYMSG;

	Shell_NotifyIcon(NIM_ADD, &niData);

	// free icon handle
	if (niData.hIcon && DestroyIcon(niData.hIcon))
		niData.hIcon = NULL;

	// call ShowWindow here to make the dialog initially visible
	return TRUE;
}
示例#16
0
//------------------------------------------------------------------------
// основная программа
//------------------------------------------------------------------------
void main(void)
{
	WORD i;
	SHORT DacSample;

	// сбросим флажок завершения потока ввода данных
	IsReadThreadComplete = false;
	// пока ничего не выделено под буфер данных
	ReadBuffer = NULL;
	// пока не создан поток ввода данных
	hReadThread = NULL;
	// пока откытого файла нет :(
	hFile = INVALID_HANDLE_VALUE;
	// сбросим флаг ошибок потока ввода данных
	ReadThreadErrorNumber = 0x0;

	// сбросим флажок завершения потока вывода данных
	IsWriteThreadComplete = false;
	// пока ничего не выделено под буфер данных
	WriteBuffer = NULL;
	// пока не создан поток ввода данных
	hWriteThread = NULL;
	// сбросим флаг ошибок потока ввода данных
	WriteThreadErrorNumber = 0x0;

	// зачистим экран монитора
	system("cls");

	printf(" ************************************\n");
	printf(" Module E14-440                      \n");
	printf(" Console example for ADC&DAC Streams \n");
	printf(" ************************************\n\n");

	// проверим версию используемой библиотеки Lusbapi.dll
	if((DllVersion = GetDllVersion()) != CURRENT_VERSION_LUSBAPI)
	{
		char String[128];
		sprintf(String, " Lusbapi.dll Version Error!!!\n   Current: %1u.%1u. Required: %1u.%1u",
											DllVersion >> 0x10, DllVersion & 0xFFFF,
											CURRENT_VERSION_LUSBAPI >> 0x10, CURRENT_VERSION_LUSBAPI & 0xFFFF);

		AbortProgram(String);
	}
示例#17
0
//------------------------------------------------------------------------
// основная программа
//------------------------------------------------------------------------
void main(void)
{
	WORD i, j;

	// проинициализируем указатели и переменные
	for(i = 0x0; i < MaxVirtualSoltsQuantity; i++)
	{
		// обнулим указатель на интерфейс
		pModules[i] = NULL;
		// сбросим флажок прерывания потока сбора данных
		IsReadThreadTerminated[i] = false;
		// пока ничего не выделено под буфер данных
		Buffer[i] = NULL;
		// пока не создан поток ввода данных
		ReadThreadHandle[i] = NULL;
		// сбросим флаг ошибок потока ввода данных
		ReadThreadErrorNumber[i] = 0x0;
	}

	// зачищаем экран монитора
	clrscr();

	printf(" ***********************************\n");
	printf(" Module E14-440                     \n");
	printf(" Console example for Multi Modules  \n");
	printf(" ***********************************\n\n");

	// инициализация критической секции
	InitializeCriticalSection(&cs);

	// проверим версию используемой библиотеки Lusbapi.dll
	if((DllVersion = GetDllVersion()) != CURRENT_VERSION_LUSBAPI)
	{
		char String[128];
		sprintf(String, " Lusbapi.dll Version Error!!!\n   Current: %1u.%1u. Required: %1u.%1u",
											DllVersion >> 0x10, DllVersion & 0xFFFF,
											CURRENT_VERSION_LUSBAPI >> 0x10, CURRENT_VERSION_LUSBAPI & 0xFFFF);

		AbortProgram(String);
	}
示例#18
0
//------------------------------------------------------------------------
// основная программа
//------------------------------------------------------------------------
void main(void)
{
	WORD i;

	// зачистим экран монитора
	clrscr();

	printf(" *************************************\n");
	printf(" Module E14-140                       \n");
	printf(" Console example for DAC_SAMPLE Stream\n");
	printf(" *************************************\n\n");

	// проверим версию используемой библиотеки Lusbapi.dll
	if((DllVersion = GetDllVersion()) != CURRENT_VERSION_LUSBAPI)
	{
		char String[128];
		sprintf(String, " Lusbapi.dll Version Error!!!\n   Current: %1u.%1u. Required: %1u.%1u",
											DllVersion >> 0x10, DllVersion & 0xFFFF,
											CURRENT_VERSION_LUSBAPI >> 0x10, CURRENT_VERSION_LUSBAPI & 0xFFFF);

		AbortProgram(String);
	}
示例#19
0
//------------------------------------------------------------------------
// основная программа
//------------------------------------------------------------------------
void main(void)
{
	WORD i;

	// зачистим экран монитора
	system("cls");

	printf(" ***************************************\n");
	printf(" Module E-310									\n");
	printf(" Digital IO console example					\n");
	printf(" ***************************************\n\n");

	// проверим версию используемой библиотеки Lusbapi.dll
	if((DllVersion = GetDllVersion()) != CURRENT_VERSION_LUSBAPI)
	{
		char String[128];
		sprintf_s(String, " Lusbapi.dll Version Error!!!\n   Current: %1u.%1u. Required: %1u.%1u",
											DllVersion >> 0x10, DllVersion & 0xFFFF,
											CURRENT_VERSION_LUSBAPI >> 0x10, CURRENT_VERSION_LUSBAPI & 0xFFFF);

		AbortProgram(String);
	}
示例#20
0
bool InstallExifPro(const TCHAR* dest_dir, bool add_desk_icon, bool add_prog_icon)
{
	DWORD attribs= ::GetFileAttributes(dest_dir);
	if (attribs == INVALID_FILE_ATTRIBUTES || (attribs & FILE_ATTRIBUTE_DIRECTORY) == 0)
	{
		if (!::CreateDirectory(dest_dir, 0))
		{
			::MessageBox(0, _T("Cannot create destination folder."), g_INSTALLER, MB_ICONERROR | MB_OK);
			return false;
		}
	}

	if (!CopyExifFiles(dest_dir))
	{
		RemoveExifFiles(dest_dir);

		::MessageBox(0, _T("Copying files failed."), g_INSTALLER, MB_ICONERROR | MB_OK);
		return false;
	}

	TCHAR uninstall[MAX_PATH * 2];
	AppendFileName(dest_dir, g_UNINST_APP, uninstall);

	if (!CreateUninstallKey(uninstall))
	{
		RemoveExifFiles(dest_dir);

		::MessageBox(0, _T("Cannot create registry entries."), g_INSTALLER, MB_ICONERROR | MB_OK);
		return false;
	}

	TCHAR exif[MAX_PATH * 2]= { 0 };
	AppendFileName(dest_dir, g_EXIF_APP, exif);

	const TCHAR* exif_link_name= _T("ExifPro ") EP_VER _T(".lnk");
	const TCHAR* exif_description= _T("ExifPro ") EP_VER _T(" Photo Browser & Viewer");

	// add desk icon?
	if (add_desk_icon)
		CreateLinkToExifPro(exif, exif_description, exif_link_name, CSIDL_DESKTOP);

	// add programs icon?
	if (add_prog_icon)
		CreateLinkToExifPro(exif, exif_description, exif_link_name, CSIDL_PROGRAMS);

	// verify comm ctl lib version
	DWORD version= GetDllVersion(_T("comctl32.dll"));

	if (g_update_common_ctrls)
	{
		// execute common ctl update

		TCHAR update[MAX_PATH * 2]= { 0 };
		AppendFileName(dest_dir, g_COMM_CTL_UPD, update);

		SHELLEXECUTEINFO sei;
		memset(&sei, 0, sizeof sei);

		sei.cbSize = sizeof sei;
		sei.fMask = SEE_MASK_NOCLOSEPROCESS;
		sei.hwnd = 0;
		sei.lpVerb = _T("open");
		sei.lpFile = update;
		sei.lpParameters = _T("/Q");
		sei.lpDirectory = dest_dir;
		sei.nShow = SW_MINIMIZE;
		if (!::ShellExecuteEx(&sei) || sei.hProcess == 0)
		{
			::MessageBox(0, _T("Cannot execute CommCtl32 updater."), g_INSTALLER, MB_ICONERROR | MB_OK);
			return false;
		}

		// wait till it's ready before removing it...
		//::WaitForSingleObject(sei.hProcess, INFINITE);

		::CloseHandle(sei.hProcess);

		return true;
	}

	// remove updater
	RemoveFileFromDir(dest_dir, g_COMM_CTL_UPD);

	return true;
}
示例#21
0
//
//  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 );

}
示例#22
0
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;
}
示例#23
0
CWindowsVersion::CWindowsVersion()
{
	m_osv.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  
    if(!GetVersionEx(&m_osv))
    {
        ASSERT(0);
        // make sure nothing bad will happen trying to interpret OSVERSIONINFO
        memset((void*)&m_osv, 0, sizeof(m_osv));
    }
    else
    {
        switch(m_osv.dwPlatformId)
        {
        case VER_PLATFORM_WIN32s: //Win32s on Windows 3.1. 
            m_winVer = WV_32S;
            break;

        case VER_PLATFORM_WIN32_WINDOWS: //WIN32 on 95 or 98 or ME
            if(m_osv.dwMinorVersion == 0)
            {
                m_winVer = WV_95;
            }
            else if(m_osv.dwMinorVersion == 10)
            {
                m_winVer = WV_98;
            }
            if(m_osv.dwMinorVersion == 90)
            {
                m_winVer = WV_ME;
            }
            break;

        case VER_PLATFORM_WIN32_NT: //Win32 on Windows NT. 

            if(m_osv.dwMajorVersion == 4) 
            {
                m_winVer = WV_NT4;
            }
            else if(m_osv.dwMajorVersion >= 5)
            {
                m_winVer = WV_2K;
            }
            break;

        default: 
            m_winVer = WV_UNKNOWN;
            break;
        }
    }

    // get the language
    m_UILang = 0;
    switch(m_winVer)
    {
    case WV_2K:
        {
        // Disable this section to emulate Windows NT before Windows 2000, when testing
        // on Windows 2000
        // Use GetUserDefaultUILanguage to find the user's prefered UI language

        // Declare function pointer
        LANGID (WINAPI *pfnGetUserDefaultUILanguage) () = NULL ;

        HMODULE hMKernel32 = LoadLibraryW(L"kernel32.dll") ;
        
        pfnGetUserDefaultUILanguage = 
            (unsigned short (WINAPI *)(void)) 
                GetProcAddress(hMKernel32, "GetUserDefaultUILanguage") ;

        if(NULL != pfnGetUserDefaultUILanguage)
            m_UILang = pfnGetUserDefaultUILanguage() ;
        }
        break;
    case WV_NT4:
        {
            // Running on Windows NT 4.0 or earlier. Get UI language
            // from locale of .default user in registry:
            // HKEY_USERS\.DEFAULT\Control Panel\International\Locale
            CRegKeyEx key;
            if(ERROR_SUCCESS == key.Open(HKEY_USERS, _T(".DEFAULT\\Control Panel\\International"), KEY_READ))
            {
                CString value = key.QueryValueString(_T("Locale"));
                m_UILang = (LANGID)_tcstol(value,NULL,16);
            };
            
        }
        break;
    case WV_95:
    case WV_98:
    case WV_ME:
        {
            // Running on Windows 9x. Get the system UI language from registry:
            CRegKeyEx key;
            if(ERROR_SUCCESS == key.Open(HKEY_USERS, _T(".Default\\Control Panel\\desktop\\ResourceLocale"), KEY_READ))
            {
                CString value = key.QueryValueString(_T(""));
                m_UILang = (LANGID)_tcstol(value, 0, 16);
            };
            
        }
        break;
    }
	// get the common controls dll version
	m_comCtl32Version = GetDllVersion(_T("comctl32.dll"));
}
示例#24
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;
}
示例#25
0
void ShowActiveDesktop()
{
	if (GetDllVersion(TEXT("shell32.dll")) >= PACKVERSION(4,71))
		EnableActiveDesktop(true);
}
示例#26
0
文件: LoginDlg.cpp 项目: 0anion0/IBN
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]
}
示例#27
0
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, 
	LPSTR lpCmdLine, int nCmdShow)
{
	USES_CONVERSION;

	//
	// Resolve UNICOWS's thunk (required)
	//

	::DefWindowProc (NULL, 0, 0, 0);

	//
	// Load the application name
	//

	::LoadString (_Module .GetResourceInstance (),
		IDR_NWNEXPLORER, g_szAppName, _countof (g_szAppName));

	//
	// Test for FMOD
	//

	g_hFMODLibrary = ::LoadLibrary (_T ("FMOD.DLL"));

	//
	// Initialize FMOD
	//

	if (g_hFMODLibrary != NULL)
	{
		if (FSOUND_GetVersion () < FMOD_VERSION)
		{
			//FIXME
		}
		if (!FSOUND_Init (44100, 32, FSOUND_INIT_GLOBALFOCUS))
		{
			//FIXME
			FSOUND_Close ();
			return 0;
		}
	}

	//
	// Create our image lists
	//

	{
		CDC dcMem;
		dcMem .CreateCompatibleDC (NULL);
		if (dcMem .GetDeviceCaps (BITSPIXEL) > 8)
		{
			g_ilSmall .Create (16, 16, ILC_COLOR16 | ILC_MASK, 16, 16);
			g_ilLarge .Create (24, 24, ILC_COLOR16 | ILC_MASK, 16, 16);
			CBitmap bmSmall;
			bmSmall .LoadBitmap (IDB_TOOLBAR_16_256COLOR);
			g_ilSmall .Add (bmSmall, RGB (255, 0, 255));
			CBitmap bmLarge;
			bmLarge .LoadBitmap (IDB_TOOLBAR_24_256COLOR);
			g_ilLarge .Add (bmLarge, RGB (255, 0, 255));
		}
		else
		{
			g_ilSmall .Create (16, 16, ILC_COLOR | ILC_MASK, 16, 16);
			g_ilLarge .Create (24, 24, ILC_COLOR | ILC_MASK, 16, 16);
			CBitmap bmSmall;
			bmSmall .LoadBitmap (IDB_TOOLBAR_16_16COLOR);
			g_ilSmall .Add (bmSmall, RGB (255, 0, 255));
			CBitmap bmLarge;
			bmLarge .LoadBitmap (IDB_TOOLBAR_24_16COLOR);
			g_ilLarge .Add (bmLarge, RGB (255, 0, 255));
		}
		g_ilSmall .SetBkColor (::GetSysColor (COLOR_3DFACE));
		g_ilLarge .SetBkColor (::GetSysColor (COLOR_3DFACE));
	}

	//
	// Enable leak checking
	//

#if defined (_DEBUG)
	_CrtSetDbgFlag (_CrtSetDbgFlag (_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
#endif

	//
	// Initialize ATL
	//

	_Module.Init (ObjectMap, hInstance);

	//
	// Initialize the printer
	//

	g_sPrinter .OpenDefaultPrinter ();
	g_sDevMode .CopyFromPrinter (g_sPrinter);

	//
	// Validate the version of the common controls
	//

	DWORD dwComCtlMajor, dwComCtlMinor;
	if (!GetDllVersion (TEXT ("comctl32.dll"), 
	    dwComCtlMajor, dwComCtlMinor) || dwComCtlMajor < 5 ||
		(dwComCtlMajor == 5 && dwComCtlMinor < 80))
	{
		::MessageBox (NULL, 
			_T ("You are running an old version of comctl32.dll.\r\n")
			_T ("Please download a new version from:\r\n\r\n")
			_T ("http://www.torlack.com/other/50comupd.exe")
			, g_szAppName, MB_OK | MB_ICONHAND);
		return 0;
	}

	//
	// Initialize the common controls
	//

    INITCOMMONCONTROLSEX icex;    
	typedef WINCOMMCTRLAPI BOOL WINAPI _x (LPINITCOMMONCONTROLSEX); 
	_x *px;
	HINSTANCE hComCtl = LoadLibraryA ("comctl32.dll");
	px = (_x *) GetProcAddress (hComCtl, "InitCommonControlsEx");
	bool fWorked = false;
	if (px != NULL)
	{
		icex .dwSize = sizeof (INITCOMMONCONTROLSEX);
		icex .dwICC = ICC_WIN95_CLASSES | ICC_DATE_CLASSES | 
			ICC_USEREX_CLASSES | ICC_COOL_CLASSES;
		fWorked = (*px) (&icex) != 0;
	}
	if (!fWorked)
	{
		::MessageBox (NULL, 
	        _T ( "Unable to initialize COMCTL32.DLL"), 
			g_szAppName, MB_OK | MB_ICONHAND);
		return 0;
	}

	//
	// Create the message loop
	//

	CMyMessageLoop theLoop;
	_Module .AddMessageLoop (&theLoop);

	//
	// Create the window
	//

	CMainWnd sMainWnd;
	g_hWndMain = sMainWnd .Create ();
	if (g_hWndMain == NULL)
	{
		CString str (MAKEINTRESOURCE (IDS_ERR_MAIN_WINDOW));
		::MessageBox (NULL, str, g_szAppName, MB_OK | MB_ICONHAND);
		return 0;
	}

	//
	// Pump messages
	//

	theLoop .Run ();
	_Module .RemoveMessageLoop ();

	//
	// Delete the palettes
	//

	for (int i = 0; i < _countof (g_apPalettes); i++)
	{
		if (g_apPalettes [i])
			delete [] g_apPalettes [i];
	}

	//
	// Close up printer (Not required, but keeps Purify happy)
	//

	g_sPrinter .ClosePrinter ();
	g_sDevMode .Detach ();

	//
	// Close FMOD
	//

	if (g_hFMODLibrary != NULL)
	{
		FSOUND_Close ();
	}

	//
	// Terminate the module
	//

	_Module .Term ();
	return 0;
}
// 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;
}
示例#29
0
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;
}
示例#30
0
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPSTR /*lpCmdLine*/, int /*cmdShow*/)
{
	SetDllDirectory(L"");
	HANDLE hReloadProtection = ::CreateMutex(NULL, FALSE, GetCacheMutexName());

	if (hReloadProtection == 0 || GetLastError() == ERROR_ALREADY_EXISTS)
	{
		// An instance of TGitCache is already running
		ATLTRACE("TGitCache ignoring restart\n");
		return 0;
	}

//	apr_initialize();
//	svn_dso_initialize2();
	g_GitAdminDir.Init();
	CGitStatusCache::Create();
	CGitStatusCache::Instance().Init();

	SecureZeroMemory(szCurrentCrawledPath, sizeof(szCurrentCrawledPath));
	
	DWORD dwThreadId; 
	HANDLE hPipeThread; 
	HANDLE hCommandWaitThread;
	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 dwVersion = GetDllVersion(_T("Shell32.dll"));

		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 
	hPipeThread = CreateThread( 
		NULL,              // no security attribute 
		0,                 // default stack size 
		PipeThread, 
		(LPVOID) &bRun,    // thread parameter 
		0,                 // not suspended 
		&dwThreadId);      // returns thread ID 

	if (hPipeThread == NULL) 
	{
		//OutputDebugStringA("TSVNCache: Could not create pipe thread\n");
		//DebugOutputLastError();
		return 0;
	}
	else CloseHandle(hPipeThread); 

	// Create a thread which waits for incoming pipe connections 
	hCommandWaitThread = CreateThread( 
		NULL,              // no security attribute 
		0,                 // default stack size 
		CommandWaitThread, 
		(LPVOID) &bRun,    // thread parameter 
		0,                 // not suspended 
		&dwThreadId);      // returns thread ID 

	if (hCommandWaitThread == NULL) 
	{
		//OutputDebugStringA("TSVNCache: Could not create command wait thread\n");
		//DebugOutputLastError();
		return 0;
	}
	else CloseHandle(hCommandWaitThread); 


	// 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();
	g_GitAdminDir.Close();
//	apr_terminate();

	return 0;
}