Exemple #1
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
    HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to
// make the EXE free threaded. This means that calls come in on a random RPC thread.
//	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
    ATLASSERT(SUCCEEDED(hRes));

    // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
    ::DefWindowProc(NULL, 0, 0, 0L);

    AtlInitCommonControls(ICC_BAR_CLASSES);	// add flags to support other controls

    hRes = _Module.Init(NULL, hInstance);
    ATLASSERT(SUCCEEDED(hRes));

    int nRet = Run(lpstrCmdLine, nCmdShow);

    _Module.Term();
    ::CoUninitialize();

    return nRet;
}
Exemple #2
0
	// thread proc
	static DWORD WINAPI RunThread(LPVOID lpData)
	{
		CMessageLoop theLoop;
		_Module.AddMessageLoop(&theLoop);

		_RunData* pData = (_RunData*)lpData;
		CMainFrame wndFrame;

		if(wndFrame.CreateEx() == NULL)
		{
			ATLTRACE(_T("Frame window creation failed!\n"));
			return 0;
		}

		wndFrame.ShowWindow(pData->nCmdShow);
		::SetForegroundWindow(wndFrame);	// Win95 needs this
		delete pData;

		int nRet = theLoop.Run();

		_Module.RemoveMessageLoop();
		return nRet;
	}
Exemple #3
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) {
	HRESULT hRes = ::CoInitialize(NULL);
  ATLASSERT(SUCCEEDED(hRes));
  
  //  this object must in main/ WinMain
  crash_report::CrAutoInstallHelper helper;
  if (!InstallCrashReport(helper)) {
    return -1;
  }

	/* Create another thread */
  g_CrashThreadInfo.m_bStop = false;
  g_CrashThreadInfo.m_hWakeUpEvent = CreateEvent(NULL, FALSE, FALSE, _T("WakeUpEvent"));
  ATLASSERT(g_CrashThreadInfo.m_hWakeUpEvent!=NULL);

  DWORD dwThreadId = 0;
  g_hWorkingThread = CreateThread(NULL, 0, CrashThread, (LPVOID)&g_CrashThreadInfo, 0, &dwThreadId);
  ATLASSERT(g_hWorkingThread!=NULL);

  // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
  ::DefWindowProc(NULL, 0, 0, 0L);
  AtlInitCommonControls(ICC_BAR_CLASSES);	// add flags to support other controls
  hRes = _Module.Init(NULL, hInstance);
  ATLASSERT(SUCCEEDED(hRes));

  int nRet = Run(lpstrCmdLine, nCmdShow);
  _Module.Term();

  // Close another thread
  g_CrashThreadInfo.m_bStop = true;
  SetEvent(g_CrashThreadInfo.m_hWakeUpEvent);
  // Wait until thread terminates
  WaitForSingleObject(g_hWorkingThread, INFINITE);
  ::CoUninitialize();

  return nRet;
}
Exemple #4
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
#ifdef _DEBUG	// ATLTRACEで日本語を使うために必要
	_tsetlocale(LC_ALL, _T("japanese"));
#endif

	HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to 
// make the EXE free threaded. This means that calls come in on a random RPC thread.
//	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
	::DefWindowProc(NULL, 0, 0, 0L);

	AtlInitCommonControls(ICC_BAR_CLASSES);	// add flags to support other controls

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	FILE* fp_out = freopen("result.txt", "w", stdout);

	g_atomicMegaThreadActive.store(true);
	std::thread threadMegaLoop(CMegaAppImpl::StartMegaLoop);

	int nRet = Run(lpstrCmdLine, nCmdShow);

	g_atomicMegaThreadActive.store(false);
	threadMegaLoop.join();

	fclose(fp_out);

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
Exemple #5
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/)
{
	HRESULT hRes = ::OleInitialize(NULL);
	ATLASSERT(SUCCEEDED(hRes));

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
	::DefWindowProc(NULL, 0, 0, 0L);

	AtlInitCommonControls(
		ICC_WIN95_CLASSES |
		ICC_DATE_CLASSES |
		ICC_USEREX_CLASSES |
		ICC_COOL_CLASSES |
		ICC_PAGESCROLLER_CLASS |
		ICC_NATIVEFNTCTL_CLASS);

	// We use a RichEdit control
	HINSTANCE hInstRich = ::LoadLibrary(CRichEditCtrl::GetLibraryName());
	ATLASSERT(hInstRich != NULL);

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	int nRet = 0;
	// BLOCK: Run application
	{
		CTestWizard wizard;
		wizard.ExecuteWizard();
	}

	::FreeLibrary(hInstRich);

	_Module.Term();
	::OleUninitialize();

	return nRet;
}
Exemple #6
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/)
{
	HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to 
// make the EXE free threaded. This means that calls come in on a random RPC thread.
//	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));


	::PRDataSource *pprdsNew = new ::PRSpoolerDataFile();	
	tstring file = _T("D:\\SUNNET\\SkyBoard\\Component\\PosterPrinter\\PrintResizer\\prpreview\\objfre_w2k_x86\\i386\\483.tmp");
	if (pprdsNew->Open( file )) {
		//this->OnNewDataSource(pprdsNew);
	} else {
		MessageBox(0, L"Fail", 0, 0);		
	}	

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
	::DefWindowProc(NULL, 0, 0, 0L);

	AtlInitCommonControls(ICC_BAR_CLASSES);	// add flags to support other controls

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	int nRet = 0;
	// BLOCK: Run application
	{
		CMainDlg dlgMain;
		nRet = dlgMain.DoModal();
	}

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
Exemple #7
0
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
    CMessageLoop theLoop;
    _Module.AddMessageLoop(&theLoop);

    // 
    AsyncInet::Init();

    //
    WindowRunner wr;
    HWND h = wr.Create(NULL);
    ATLASSERT(h);

    //
    SiteCrank crank;
    crank.Init();

    crank.Run(&wr);

    // 
    VerifyImgDlg wndMain;

    if(wndMain.Create(0) == NULL)
    {
        ATLTRACE(_T("Main window creation failed!\n"));
        return 0;
    }

    wndMain.ShowWindow(nCmdShow);

    int nRet = theLoop.Run();

    wr.DestroyWindow();

    _Module.RemoveMessageLoop();
    return nRet;
}
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
	HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to 
// make the EXE free threaded. This means that calls come in on a random RPC thread.
//	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
	::DefWindowProc(NULL, 0, 0, 0L);

	HMODULE hInstRichEdit = ::LoadLibrary(_T("Msftedit.dll"));

	AtlInitCommonControls(ICC_BAR_CLASSES);	// add flags to support other controls
	GdiplusStartupInput		m_gdiplusStartupInput;
	ULONG_PTR				m_gdiplusToken;
	Status sta = GdiplusStartup(&m_gdiplusToken, &m_gdiplusStartupInput, NULL);		//GDI+³õʼ»¯
	

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	int nRet = Run(lpstrCmdLine, nCmdShow);

	GdiplusShutdown(m_gdiplusToken);

	if( hInstRichEdit != NULL )
	{
		FreeLibrary( hInstRichEdit );
	}

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT) {
	FLAGS_logtostderr = false;
	FLAGS_alsologtostderr = true;

	google::InitGoogleLogging("ImageEditor.exe");

	LoadLibrary(WinUtils::GetAppFolder() + L"gdiplus.dll");
	CMessageLoop theLoop;
	_Module.AddMessageLoop( &theLoop );

	ImageEditor::ImageEditorWindow wndMain("screenshot.png");
	wndMain.setInitialDrawingTool(ImageEditor::Canvas::dtCrop);

	

	//wndMain.ShowWindow( nCmdShow );
	ImageEditorWindow::DialogResult dr = wndMain.DoModal(0, ImageEditorWindow::wdmWindowed);
	//LOG(INFO) << "DoModal returned "<<dr;
	//int nRet = theLoop.Run();

	_Module.RemoveMessageLoop();
	//wndMain.DestroyWindow();
	return 0;
}
Exemple #10
0
extern "C" __declspec(dllexport) void LoadLuaRunTime(char* szInstallDir,char* szParam)
{
	TSTRACEAUTO();
	HRESULT hr = ::CoInitialize(NULL);
	hr = _Module.Init(NULL, gInstance);


	CMessageLoop theLoop;
	_Module.AddMessageLoop(&theLoop);

	CLRTAgent lrtAgent;
	if (lrtAgent.InitLua(szInstallDir,szParam))
	{
		TSDEBUG4CXX(_T(">>>>>theLoop.Run()"));
		theLoop.Run();
		TSDEBUG4CXX(_T("<<<<<theLoop.Run()"));
	}
	_Module.RemoveMessageLoop();
	_Module.Term();
	::CoUninitialize();
	TerminateProcess(::GetCurrentProcess(), S_OK);

	return;
}
Exemple #11
0
int server_main()
{
	HRESULT hRes = _Module.Init(NULL, GetModuleHandle(NULL));
	ATLASSERT(SUCCEEDED(hRes));

	weasel::Server server;
	boost::scoped_ptr<weasel::RequestHandler> handler(new TestRequestHandler);
	server.SetRequestHandler(handler.get());
	if (!server.Start())
		return -4;
	cerr << "server running." << endl;
	int ret = server.Run();
	cerr << "server quitting." << endl;
	return ret;
}
Exemple #12
0
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{


	CMessageLoop theLoop;
	_Module.AddMessageLoop(&theLoop);

	CMainFrame wndMain;

	if(wndMain.CreateEx() == NULL)
	{
		ATLTRACE(_T("Main window creation failed!\n"));
		return 0;
	}

	wndMain.ShowWindow(nCmdShow);

	int nRet = theLoop.Run();

	_Module.RemoveMessageLoop();
	

	return nRet;
}
Exemple #13
0
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/) 
{
	if (dwReason == DLL_PROCESS_ATTACH) {
		_Module.Init(ObjectMap, hInstance);
		DisableThreadLibraryCalls(hInstance);

	CRegKey regCfg;
	DWORD dwSize = _MAX_PATH;
	
		if (ERROR_SUCCESS != regCfg.Open(HKEY_CURRENT_USER, _T("Software"), KEY_READ) ||
			ERROR_SUCCESS != regCfg.Open(regCfg, REG_COMPANY_KEY, KEY_READ) ||
			ERROR_SUCCESS != regCfg.Open(regCfg, REG_PRODUCT_KEY, KEY_READ) ||
			ERROR_SUCCESS != regCfg.Open(regCfg, _T("Config"), KEY_READ) ||
			ERROR_SUCCESS != regCfg.QueryValue(g_cbTRiAS, _T("TRiASName"), &dwSize) ||
			0 == dwSize)
		{
			strcpy (g_cbTRiAS, g_cbTRiASDefaultName);		// default
		}
	} 
	else if (dwReason == DLL_PROCESS_DETACH) {
		_Module.Term();
	}
	return TRUE;    // ok
}
Exemple #14
0
int InitializeGui(HINSTANCE hInstance, LPARAM param)
{
	CoInitialize(NULL);

	AtlInitCommonControls(ICC_LISTVIEW_CLASSES | ICC_TREEVIEW_CLASSES);

	Scylla::initAsGuiApp();

	IsDllMode = false;

	HRESULT hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	

	int nRet = 0;
	// BLOCK: Run application
	{
		MainGui dlgMain;
		pMainGui = &dlgMain; // o_O

		CMessageLoop loop;
		_Module.AddMessageLoop(&loop);

		dlgMain.Create(GetDesktopWindow(), param);

		dlgMain.ShowWindow(SW_SHOW);

		loop.Run();
	}

	_Module.Term();
	CoUninitialize();

	return nRet;
}
int 
WINAPI 
_tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
	//NdasUiDbgCall( 1, "in, IsDebuggerPresent() = %d\n", IDebugClient2::IsKernelDebuggerEnabled() );
	NdasUiDbgCall( 1, "in, IsDebuggerPresent() = %d\n", IsDebuggerPresent() );

	OutputDebugString( _T("IsDebuggerPresent()\n") );

	// If you are running on NT 4.0 or higher you can use the following call instead to 
	// make the EXE free threaded. This means that calls come in on a random RPC thread.
	// HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);

	HRESULT hRes = ::CoInitialize(NULL);
	ATLASSERT(SUCCEEDED(hRes));

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used

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

	::AtlInitCommonControls( ICC_COOL_CLASSES | ICC_BAR_CLASSES );

	// add flags to support other controls

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	int ret = Run( lpstrCmdLine, nCmdShow );

	_Module.Term();
	::CoUninitialize();

	NdasUiDbgCall( 1, "*********out**********\n" );

	return ret;
}
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{

	CMessageLoop theLoop;
	_Module.AddMessageLoop(&theLoop);

	CMainDlg dlgMain;


	if(dlgMain.Create(NULL) == NULL)
	{
		ATLTRACE(_T("Main dialog creation failed!\n"));
		return 0;
	}

	dlgMain.ShowWindow(nCmdShow);
	dlgMain.UpdateWindow();


	int nRet = theLoop.Run();

	_Module.RemoveMessageLoop();
	return nRet;
}
Exemple #17
0
int __stdcall WinMain(HINSTANCE hInstance,
            HINSTANCE hPrevInstance,
            LPSTR lpCmdLine,
            int nShowCmd)
{
    _Module.Init(0, hInstance);
    zl::GdiPlusAutoInit init;

    test_basic();
    test_gdi();
    test_zlui();
    test_lab();
    test_gdiplus();

    return 0; // (int)msg.wParam;
}
Exemple #18
0
// 加载主xar
bool LoadXAR()
{
	wchar_t szPath[MAX_PATH];
	::GetModuleFileName(_Module.GetModuleInstance(), szPath, MAX_PATH);

	::PathCombine(szPath, szPath, L"..\\..\\samples\\Wizard\\xar\\");

	XLUE_AddXARSearchPath(szPath);

	if(XLUE_LoadXAR("wizard") != 0)
	{
		::MessageBox(0, L"Load XAR failed!", 0 , 0);
		return false;
	}

	return true;
}
Exemple #19
0
LRESULT CTipDlg::OnInitDialog(UINT , WPARAM , LPARAM , BOOL &)
{
	_Module.GetMessageLoop()->AddMessageFilter(this);
	//m_list = GetDlgItem(IDC_LIST);
	m_list.SubclassWindow(GetDlgItem(IDC_LIST));
	m_list.SetExtendedListViewStyle(LVS_EX_FULLROWSELECT|LVS_EX_INFOTIP|LVS_EX_BORDERSELECT);
	m_list.AddColumn(L"", 0);
	m_list.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);

	m_il.Create(16, 16, ILC_COLOR32 | ILC_MASK, 4, 4);
	m_il.SetBkColor(CLR_NONE);
	HBITMAP bmp = AtlLoadBitmap(IDB_UD);
	m_il.Add(bmp); DeleteObject(bmp);

	cfg::config * c = cfg::config::instance();
	for (int i = 0; i < c->index_mgr.cs_count(); i++)
	{
		HICON icon = NULL;
		index_info *ii = c->get_index_info(i);
		if (!ii->icon.file.empty())
		{
			std::wstring path = hlp::abs_path(ii->icon.file.c_str());
			ExtractIconEx(path.c_str(), ii->icon.index, NULL, &icon, 1);
			if (icon == NULL)
			{
				icon = (HICON)LoadImage(NULL, path.c_str(), IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
			}
		}
		if (icon == NULL)
		{
			bmp = AtlLoadBitmap(IDB_QUICK_LAUNCH);
			m_il.Add(bmp); 
			DeleteObject(bmp);
		}
		else
		{
			m_il.AddIcon(icon);
			DestroyIcon(icon);
		}
	}

	m_list.SetImageList(m_il, LVSIL_SMALL);

	return TRUE;
}
Exemple #20
0
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
	UNREFERENCED_PARAMETER(hPrevInstance);
	UNREFERENCED_PARAMETER(lpCmdLine);

	Logging::CLoggerFactory::getDefaultInstance()->AddTarget(new Logging::CLogTargetDebugger(Logging::LOG_LEVEL_INFO));
	Logging::CLoggerFactory::getDefaultInstance()->AddTarget(new Logging::CLogTargetMessageBox(Logging::LOG_LEVEL_ERROR));
	
	LOGMSG_DEBUG(_T("Application started.\n"));
	::CoInitialize(NULL);
	_Module.Init(NULL, hInstance);

	CDxWindow win;
	if (!win.CreateEx())
	{
		LOGMSG_ERROR(_T("Failed to create main window!\n"));
		return 1;       // Window creation failed
	}

	win.ShowWindow(nCmdShow);
	win.UpdateWindow();

	// Hauptmeldungsschleife:
	MSG msg;
	bool bDone = false;
	while (!bDone)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if (msg.message == WM_QUIT) 
				bDone = true;
			TranslateMessage(&msg); 
			DispatchMessage(&msg); 
		}
		else
		{
			win.Render();
		}
	}

	::CoUninitialize();
	LOGMSG_DEBUG(_T("Application finished.\n"));

	return (int)msg.wParam;
}
CCrashHandler::CCrashHandler(LPGETLOGFILE lpfn /*=NULL*/,
                             const char * lpcszTo /*=NULL*/,
                             const char * lpcszSubject /*=NULL*/,
							 bool bInstallHandler /*= true*/)
{
   // wtl initialization stuff...
	HRESULT hRes = ::CoInitialize(NULL);
	//Если COM уже проинициализировали, но в другом режиме - мы не бужем вызывать разинициализацию
	if (hRes == RPC_E_CHANGED_MODE)
		m_COMInited = false;
	else
	{
		ATLASSERT(SUCCEEDED(hRes));
		m_COMInited = SUCCEEDED(hRes);
	}


   hRes = _Module.Init(NULL, GetModuleHandle("CrashRpt.dll"));
   ATLASSERT(SUCCEEDED(hRes));

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

   // initialize member data
   m_lpfnCallback = NULL;
   m_oldFilter    = NULL;

   // save user supplied callback
   if (lpfn)
      m_lpfnCallback = lpfn;

   if (bInstallHandler)
   {
	// add this filter in the exception callback chain
	m_oldFilter = SetUnhandledExceptionFilter(CustomUnhandledExceptionFilter);

	// attach this handler with this process
	m_pid = _getpid();
	if (!_crashStateMap.SetAt(m_pid, this))
		_crashStateMap.Add(m_pid, this);
   }
   // save optional email info
   m_sTo = lpcszTo;
   m_sSubject = lpcszSubject;
}
Exemple #22
0
App::App(HINSTANCE hInstance)
{
#ifdef _DEBUG
   // turn on leak-checking
   int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
   _CrtSetDbgFlag(flag | _CRTDBG_LEAK_CHECK_DF);
#endif

   // note: Apartment Threading needed for Canon ED-SDK
   ATLVERIFY(SUCCEEDED(::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED)));

   // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
#pragma warning(suppress: 6387)
   ::DefWindowProc(NULL, 0, 0, 0L);

   AtlInitCommonControls(ICC_WIN95_CLASSES);

   ATLVERIFY(SUCCEEDED(_Module.Init(NULL, hInstance)));
}
//
// 从资源中加载动画光标
// 如果动画光标是 256 色的,CreateIconFromResource() 就会失败返回 NULL,但 GetLastError() 返回 0
//
HCURSOR
LoadAniCursor(
	const char *pResourceType,  // 资源类型
	UINT        uID )           // 资源 ID
{
	HINSTANCE hInst = _Module.GetResourceInstance();
	HRSRC hRes = FindResource( hInst, MAKEINTRESOURCE( uID ), pResourceType );
	if( hRes )
	{
		DWORD   dwSize = SizeofResource( hInst, hRes );
		HGLOBAL hGlob  = LoadResource( hInst, hRes );
		if( hGlob )
		{
			LPBYTE pBytes = (LPBYTE)LockResource( hGlob ); 
			if( pBytes )
				return( (HCURSOR)CreateIconFromResource( pBytes, dwSize, FALSE, 0x00030000 ) );
		}
	}

	return( NULL );
}
Exemple #24
0
void LoadLocalizedResources()
{
	HMODULE hResources = NULL;

	wchar_t szLang[9];

	// user language
	if(::GetLocaleInfo(LOCALE_CUSTOM_UI_DEFAULT, LOCALE_SISO639LANGNAME2, szLang, 9) > 0)
	{
		wstring dll (L"console_");
		dll += szLang;
		dll += L".dll";
		hResources = ::LoadLibraryEx(dll.c_str(), NULL, LOAD_LIBRARY_AS_DATAFILE);

		Win32Exception ex("LoadLibraryEx", ::GetLastError());
		TRACE(L"LOCALE_CUSTOM_UI_DEFAULT LOCALE_SISO639LANGNAME2=%s dll=%s hResources=%p (%S)\n", szLang, dll.c_str(), hResources, ex.what());
	}

	// default resources are in english
	if(!hResources && ::_wcsicmp(szLang, L"eng") == 0) return;

	// system language
	if(!hResources && ::GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_SISO639LANGNAME2, szLang, 9) > 0)
	{
		wstring dll (L"console_");
		dll += szLang;
		dll += L".dll";
		hResources = ::LoadLibraryEx(dll.c_str(), NULL, LOAD_LIBRARY_AS_DATAFILE);

		Win32Exception ex("LoadLibraryEx", ::GetLastError());
		TRACE(L"LOCALE_SYSTEM_DEFAULT LOCALE_SISO639LANGNAME2=%s dll=%s hResources=%p (%S)\n", szLang, dll.c_str(), hResources, ex.what());
	}

	if(hResources)
	{
		_Module.SetResourceInstance(hResources);
	}
}
Exemple #25
0
int __stdcall wWinMain(HINSTANCE instance,
                       HINSTANCE,
                       LPWSTR /*cmdLine*/,
                       int /*cmdShow*/)
{
	{
		BOOL isx64;
		IsWow64Process(GetCurrentProcess(), &isx64);
		onx64 = isx64 == TRUE;
	}

	try
	{
		transaction = CreateTransaction(NULL, NULL, NULL, NULL, NULL, NULL, L"Taglib Handler Setup");
		if (transaction == INVALID_HANDLE_VALUE)
			throw win32_error(L"Couldn't create a transaction");
		makeGuard(CloseHandle, transaction);

		HRESULT hr;
		if (FAILED(hr = _Module.Init(0, instance)))
			throw std::exception("Initialisation failed", hr);
		makeGuard(&CAppModule::Term, _Module);

		InstallDialog dialog;
		return dialog.DoModal();
	}
	catch (std::exception& e)
	{
		MessageBoxA(msgbox, e.what(), "Fatal error, exiting", MB_ICONERROR | MB_OK);
		return -1;
	}
	catch (win32_error& e)
	{
		MessageBox(msgbox, e.what().c_str(), L"Unexpected Win32 error, exiting", MB_ICONERROR | MB_OK);
		return -2;
	}
}
int Run(LPTSTR lpstrCmdLine = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
	CMessageLoop theLoop;
	_Module.AddMessageLoop(&theLoop);

	wstring			strConfigFile(L"");
	wstring			strWindowTitle(L"");
	vector<wstring>	startupTabs;
	vector<wstring>	startupDirs;
	vector<wstring>	startupCmds;
	int				nMultiStartSleep = 0;
	wstring			strDbgCmdLine(L"");

	ParseCommandLine(
		lpstrCmdLine, 
		strConfigFile, 
		strWindowTitle, 
		startupTabs, 
		startupDirs, 
		startupCmds, 
		nMultiStartSleep, 
		strDbgCmdLine);

	if (strConfigFile.length() == 0)
	{
		strConfigFile = wstring(L"console.xml");
//		strConfigFile = Helpers::GetModulePath(NULL) + wstring(L"console.xml");
//		strConfigFile = wstring(::_wgetenv(L"APPDATA")) + wstring(L"\\Console\\console.xml");
	}

	if (!g_settingsHandler->LoadSettings(Helpers::ExpandEnvironmentStrings(strConfigFile)))
	{
		//TODO: error handling
		return 1;
	}

	// create main window
	NoTaskbarParent noTaskbarParent;
	MainFrame wndMain(strWindowTitle, startupTabs, startupDirs, startupCmds, nMultiStartSleep, strDbgCmdLine);

	if (!g_settingsHandler->GetAppearanceSettings().stylesSettings.bTaskbarButton)
	{
		noTaskbarParent.Create(NULL);
	}

	if(wndMain.CreateEx(noTaskbarParent.m_hWnd) == NULL)
	{
		ATLTRACE(_T("Main window creation failed!\n"));
		return 1;
	}

	wndMain.ShowWindow(nCmdShow);

	int nRet = theLoop.Run();

	if (noTaskbarParent.m_hWnd != NULL) noTaskbarParent.DestroyWindow();

	_Module.RemoveMessageLoop();

	return nRet;
}
Exemple #27
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
    HRESULT hRes = ::CoInitialize(NULL);
    // If you are running on NT 4.0 or higher you can use the following call instead to 
    // make the EXE free threaded. This means that calls come in on a random RPC thread.
    //	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
    ATLASSERT(SUCCEEDED(hRes));

    // Install crash reporting

    CR_INSTALL_INFO info;
    memset(&info, 0, sizeof(CR_INSTALL_INFO));
    info.cb = sizeof(CR_INSTALL_INFO);  
    info.pszAppName = _T("WTLDemo"); // Define application name.
    //info.pszAppVersion = _T("1.3.1");     // Define application version.
    info.pszEmailSubject = _T("WTLDemo Error Report"); // Define subject for email.
    info.pszEmailTo = _T("*****@*****.**");   // Define E-mail recipient address.  
	//info.pszSmtpProxy = _T("127.0.0.1");  // Use SMTP proxy.
	//info.pszSmtpLogin = _T("test");      // SMTP Login
	//info.pszSmtpPassword = _T("test");       // SMTP Password
    info.pszUrl = _T("http://localhost:80/crashrpt.php"); // URL for sending reports over HTTP.				
    info.pfnCrashCallback = CrashCallback; // Define crash callback function.   
    // Define delivery methods priorities. 
    info.uPriorities[CR_HTTP] = 3;         // Use HTTP the first.
    info.uPriorities[CR_SMTP] = 2;         // Use SMTP the second.
    info.uPriorities[CR_SMAPI] = 1;        // Use Simple MAPI the last.  
    info.dwFlags = 0;                    
    info.dwFlags |= CR_INST_ALL_POSSIBLE_HANDLERS; // Install all available exception handlers.    
    //info.dwFlags |= CR_INST_APP_RESTART;            // Restart the application on crash.  
    //info.dwFlags |= CR_INST_NO_MINIDUMP;          // Do not include minidump.
    //info.dwFlags |= CR_INST_NO_GUI;               // Don't display GUI.
    //info.dwFlags |= CR_INST_DONT_SEND_REPORT;     // Don't send report immediately, just queue for later delivery.
    //info.dwFlags |= CR_INST_STORE_ZIP_ARCHIVES;   // Store ZIP archives along with uncompressed files (to be used with CR_INST_DONT_SEND_REPORT)
    //info.dwFlags |= CR_INST_SEND_MANDATORY;         // Remove "Close" and "Other actions..." buttons from Error Report dialog.
	//info.dwFlags |= CR_INST_SHOW_ADDITIONAL_INFO_FIELDS; //!< Make "Your E-mail" and "Describe what you were doing when the problem occurred" fields of Error Report dialog always visible.
	info.dwFlags |= CR_INST_ALLOW_ATTACH_MORE_FILES; //!< Adds an ability for user to attach more files to crash report by clicking "Attach More File(s)" item from context menu of Error Report Details dialog.
	//info.dwFlags |= CR_INST_SEND_QUEUED_REPORTS;    // Send reports that were failed to send recently.	
	//info.dwFlags |= CR_INST_AUTO_THREAD_HANDLERS; 
    info.pszDebugHelpDLL = NULL;                    // Search for dbghelp.dll using default search sequence.
    info.uMiniDumpType = MiniDumpNormal;            // Define minidump size.
    // Define privacy policy URL.
    info.pszPrivacyPolicyURL = _T("http://code.google.com/p/crashrpt/wiki/PrivacyPolicyTemplate");
    info.pszErrorReportSaveDir = NULL;       // Save error reports to the default location.
    info.pszRestartCmdLine = _T("/restart"); // Command line for automatic app restart.
    //info.pszLangFilePath = _T("D:\\");       // Specify custom dir or filename for language file.
    //info.pszCustomSenderIcon = _T("C:\\WINDOWS\\System32\\user32.dll, 1"); // Specify custom icon for CrashRpt dialogs.
	info.nRestartTimeout = 50;

    // Install crash handlers.
    CrAutoInstallHelper cr_install_helper(&info);
    if(cr_install_helper.m_nInstallStatus!=0)
    {
        TCHAR buff[256];
        crGetLastErrorMsg(buff, 256);
        MessageBox(NULL, buff, _T("crInstall error"), MB_OK);
        return FALSE;
    }
    ATLASSERT(cr_install_helper.m_nInstallStatus==0); 

    CString sLogFile = GetAppDir() + _T("\\*.log");
    CString sIniFile = _T("\\\\?\\") + GetAppDir() + _T("\\dummy.ini");

    int nResult = crAddFile2(sLogFile, NULL, _T("Dummy Log File"), CR_AF_MAKE_FILE_COPY|CR_AF_ALLOW_DELETE);
    ATLASSERT(nResult==0);
    
    nResult = crAddFile2(sIniFile, NULL, _T("Dummy INI File"), 0);
    ATLASSERT(nResult==0);

    nResult = crAddScreenshot2(CR_AS_PROCESS_WINDOWS|CR_AS_USE_JPEG_FORMAT|CR_AS_ALLOW_DELETE, 10);
    //nResult = crAddScreenshot(CR_AS_MAIN_WINDOW);
    ATLASSERT(nResult==0);
	
	nResult = crAddProperty(_T("AnExampleProperty"),_T("Property value"));
    ATLASSERT(nResult==0);

    nResult = crAddProperty(_T("VideoCard"),_T("nVidia GeForce 9800"));
    ATLASSERT(nResult==0);
		
	nResult = crAddProperty(_T("HDDSerialNumber"),_T("1234512345098765"));
    ATLASSERT(nResult==0);

	nResult = crAddProperty(_T("MACAddress"),_T("11.11.11.11"));
    ATLASSERT(nResult==0);

	nResult = crAddProperty(_T("UserName"),_T("TheUserName"));
    ATLASSERT(nResult==0);

    nResult = crAddRegKey(_T("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"), _T("regkey.xml"), CR_AR_ALLOW_DELETE);
    ATLASSERT(nResult==0);

    nResult = crAddRegKey(_T("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), _T("regkey.xml"), CR_AR_ALLOW_DELETE);
    ATLASSERT(nResult==0);

    /* Create another thread */
    g_CrashThreadInfo.m_bStop = false;
    g_CrashThreadInfo.m_hWakeUpEvent = CreateEvent(NULL, FALSE, FALSE, _T("WakeUpEvent"));
    ATLASSERT(g_CrashThreadInfo.m_hWakeUpEvent!=NULL);

    DWORD dwThreadId = 0;
    g_hWorkingThread = CreateThread(NULL, 0, CrashThread, (LPVOID)&g_CrashThreadInfo, 0, &dwThreadId);
    ATLASSERT(g_hWorkingThread!=NULL);

    // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
    ::DefWindowProc(NULL, 0, 0, 0L);

    AtlInitCommonControls(ICC_BAR_CLASSES);	// add flags to support other controls

    hRes = _Module.Init(NULL, hInstance);
    ATLASSERT(SUCCEEDED(hRes));

    int nRet = Run(lpstrCmdLine, nCmdShow);

    _Module.Term();

    // Close another thread
    g_CrashThreadInfo.m_bStop = true;
    SetEvent(g_CrashThreadInfo.m_hWakeUpEvent);
    // Wait until thread terminates
    WaitForSingleObject(g_hWorkingThread, INFINITE);

    ::CoUninitialize();

    return nRet;
}
Exemple #28
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
	HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to 
// make the EXE free threaded. This means that calls come in on a random RPC thread.
//	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

#ifdef _DEBUG
	// ATLTRACEで日本語を使うために必要
	_tsetlocale( LC_ALL, _T("japanese") );
#endif

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
	::DefWindowProc(NULL, 0, 0, 0L);

	AtlInitCommonControls(ICC_BAR_CLASSES);	// add flags to support other controls

    // リッチエディットコントロール初期化
    HINSTANCE hRich = LoadLibrary(CRichEditCtrl::GetLibraryName());
    if(hRich == NULL){
        AtlMessageBox(NULL, _T("リッチエディットコントロール初期化失敗"),
            _T("エラー"), MB_OK | MB_ICONERROR);
        return 0;
    }

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));
	
	int nRet = 0;
	try {

		CVersionControl::Run();

		CSettings::LoadSettings();

		CSocket::Init();

		WinHTTPWrapper::InitWinHTTP();

		CSettings::s_SSLFilter = InitSSL();

		nRet = Run(lpstrCmdLine, nCmdShow);

		if (CSettings::s_SSLFilter)
			TermSSL();

		WinHTTPWrapper::TermWinHTTP();

		CSocket::Term();

		CSettings::SaveSettings();
	}
	catch (std::exception& e) {
		ERROR_LOG << e.what();
	}

	FreeLibrary(hRich);

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
Exemple #29
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
#ifdef __EXPIRATION__
	// Program Expiration routines
	CTime expirationTime(2010,	// year
		2,					// month
		30,					// date
		23,					// hour 24
		59,					// minute
		59);				// second
	CTime currentTime = CTime::GetCurrentTime();

    CTimeSpan leftTime = expirationTime - currentTime;   

	// 사용 기간이 남았을 경우
	if(leftTime.GetTotalSeconds() > 0)
    {
		 CString msg;
		 msg = L"";
		 msg += L"This is a trial version of BTools2\n";
		 msg += expirationTime.Format(L"Expiration date :\n %Y-%m-%d  %H:%M:%S\n\n");
		 msg += leftTime.Format(L"%D day(s) and\n %H:%M:%S left" );
     
		 // 사용 기간이 3일 미만 남았을 경우
		 if(leftTime.GetDays() < 7)
		 {
			 msg = leftTime.Format(L"This software will expire after %D day(s)");// %H Hour(s) %M Minute(s)");
			 //AtlMessageBox(NULL, msg.GetBuffer(), L"Expiration Warning");
		 }
		 //AfxMessageBox(msg);
    }
    else // 사용 기간이 만료된 경우
    {
		CString msg("This is a trial version of BTools2\n"
				"If you want to use this software more\n"
				"Please contact to me.\[email protected]\n"
				"Thank you for your interest\n");

		msg += expirationTime.Format(L"Expiration date :\n %Y-%m-%d  %H:%M\n\n");
		msg += leftTime.Format(L"%D day(s) and\n %H:%M:%S passed" );
        //msg.Format(L"This software is submitted for the Windows Mobile Contest");
		//AtlMessageBox(NULL, msg.GetBuffer(), L"Warning");
		return FALSE;
	 }

#endif

#ifdef __TSTORE_ARM__0
	// ARM
	T_RETURN ret;
	TAPPID *APPID = TSTORE_APPLICATION_ID;

	bool aSuccess=true;

	T_RETURN res; 
	ARM_PLUGIN_Initialize(&res,APPID);
	if (res.code == ARM_SUCCESS) 
	{
		ARM_PLUGIN_CheckLicense(&res); 
		if (res.code == ARM_SUCCESS) 
		{ 
			ARM_PLUGIN_RequestLicense(&res); 
			if (res.code !=ARM_SUCCESS) 
			{ //실패시 구현 
				aSuccess=false;
				TCHAR wszMsg[1024];
				if(ret.pMsg)
				{
					ansi_to_unicode(ret.pMsg, strlen(ret.pMsg), wszMsg, 1024);
					::AtlMessageBox(NULL, wszMsg, L"[ARM]Request License");
				}
			}
		
		} 
		else 
		{//실패시 메시 구현 
			aSuccess=false;

			TCHAR wszMsg[1024];

			switch(res.code)
			{
			case CLICENSE_DENY:
			case CLICENSE_NOT_EXIST:
			case CLICENSE_EXPIRED:
			case CLICENSE_INVALID:
				{
					if(ret.pMsg)
					{
						ansi_to_unicode(ret.pMsg, strlen(ret.pMsg), wszMsg, 1024);
						::AtlMessageBox(NULL, wszMsg, L"[ARM]Check License");
					}
				}

			default:
				;
			}
		} 
	} 
	else 
	{ 
		aSuccess=false; 
	} 
	ARM_PLUGIN_Uninitialize(&res); 


	//if (! aSuccess) return 0;//PostQuitMessage(0); 

#endif

	//CAboutDlg aboutDlg;	aboutDlg.DoModal();
    //
	HRESULT hRes = CBTools2Frame::ActivatePreviousInstance(hInstance, lpstrCmdLine);

	if(FAILED(hRes) || S_FALSE == hRes)
	{
		return hRes;
	}

	hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

	AtlInitCommonControls(ICC_DATE_CLASSES);
	SHInitExtraControls();

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	int nRet = CBTools2Frame::AppRun(lpstrCmdLine, nCmdShow);

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
App::~App()
{
   _Module.Term();
   ::CoUninitialize();
}