BOOL CShadowmapApp::InitInstance()
{
	// Standard initialization

	// Change the registry key under which our settings are stored.

	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	// To create the main window, this code creates a new frame window
	// object and then sets it as the application's main window object.

	m_pMainWnd = NULL;
	CMainFrame* pFrame = new CMainFrame;

	if (!pFrame->Create(NULL,"ZwqXin.com"))
		return FALSE;

	m_pMainWnd = pFrame;
	pFrame->ShowWindow(m_nCmdShow);
	pFrame->UpdateWindow();

	return TRUE;
}
Beispiel #2
0
int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
	CPaintManagerUI::SetInstance(hInstance);//设置程序实例
	CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("skin"));//实例句柄与渲染类关联,获得皮肤文件目录(加载皮肤文件在OnCreate之中)

	HRESULT Hr = ::CoInitialize(NULL);//初始化COM库, 为加载COM库提供支持
	if( FAILED(Hr) ) 
		return 0;

	CMainFrame* pMainFrame = new CMainFrame();//创建应用程序窗口类对象
	if( pMainFrame == NULL ) 
		return 0;
	pMainFrame->SetIcon(IDI_ICON1);
	//以背景的句柄为父窗口创建DLG,如果不这样的话,在任务栏会产生两个窗体,不信,你就把下面create的第一个参数改成NULL试试,你就懂了
	pMainFrame->Create(pMainFrame->m_pBackWnd->GetHandle(), _T("AdderCalc"), UI_WNDSTYLE_DIALOG, 0);
	//让背景图片居中
	pMainFrame->m_pBackWnd->CenterWindow();
	
	pMainFrame->ShowWindow(true);//显示窗口
	CPaintManagerUI::MessageLoop();//进入消息循环

	::CoUninitialize();//退出程序并释放COM库
	return 0;
}
Beispiel #3
0
int __stdcall WinMain(HINSTANCE hinst, HINSTANCE, PSTR cmdLine, int cmdShow)
{
    _Module.Init(0, hinst, 0);

    CMessageLoop msgLoop;
    _Module.AddMessageLoop(&msgLoop);

    int result = -1;

    CMainFrame frame;

    frame.Create(
        ::GetDesktopWindow(),
        CWindow::rcDefault,
        TEXT("Notepad--"));

    if (frame.IsWindow()) {
        frame.ShowWindow(cmdShow);
        result = msgLoop.Run();
    }

    _Module.RemoveMessageLoop();
    _Module.Term();

    return result;
}
Beispiel #4
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, PTSTR, int nShowCmd)
{
    AtlInitCommonControls(ICC_WIN95_CLASSES);
    _Module.Init(NULL, hInstance);

    CMainFrame *frameWnd = new CMainFrame;
    if (!frameWnd->Create(NULL, NULL, PDBEXP_WNDCAPTION)) {
        delete frameWnd;
        return EXIT_FAILURE;
    }

    frameWnd->CenterWindow();
    frameWnd->ShowWindow(nShowCmd);

    MSG msg;
    HACCEL hAccTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR));
    while (GetMessage(&msg, NULL, 0, 0)) {
        if (0 == TranslateAccelerator(*frameWnd, hAccTable, &msg)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }

    _Module.Term();
    return (int)msg.wParam;
}
BOOL CMyApp::InitInstance()
{
	CMainFrame* pFrame = new CMainFrame;
	pFrame->Create(0, "MFC");
	pFrame->ShowWindow( SW_SHOW );
	pFrame->UpdateWindow();

	m_pMainWnd = pFrame;

	return TRUE;
}
	virtual BOOL InitInstance()
	{
		CMainFrame* pFrame = new CMainFrame;

		pFrame->Create(0, "Message");
		pFrame->ShowWindow( SW_SHOW );
		pFrame->UpdateWindow( );

		m_pMainWnd = pFrame;

		return TRUE;
	}
Beispiel #7
0
BOOL CTestUIApp::InitInstance()
{
	// 如果一个运行在 Windows XP 上的应用程序清单指定要
	// 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式,
	//则需要 InitCommonControlsEx()。否则,将无法创建窗口。
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// 将它设置为包括所有要在应用程序中使用的
	// 公共控件类。
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	CWinApp::InitInstance();

	AfxEnableControlContainer();

	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO: 应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("应用程序向导生成的本地应用程序"));

	DuiLib::CPaintManagerUI::SetInstance(AfxGetInstanceHandle());
	DuiLib::CPaintManagerUI::SetResourcePath(DuiLib::CPaintManagerUI::GetInstancePath());

	CMainFrame* pFrame = new CMainFrame();
	if( pFrame == NULL ) return 0;
	pFrame->Create(NULL, _T("这是一个最简单的测试用exe,修改test1.xml就可以看到效果"), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
	pFrame->CenterWindow();
	pFrame->ShowWindow(true);
	DuiLib::CPaintManagerUI::MessageLoop();

// 	CTestUIDlg dlg;
// 	m_pMainWnd = &dlg;
// 	INT_PTR nResponse = dlg.DoModal();
// 	if (nResponse == IDOK)
// 	{
// 		// TODO: 在此放置处理何时用
// 		//  “确定”来关闭对话框的代码
// 	}
// 	else if (nResponse == IDCANCEL)
// 	{
// 		// TODO: 在此放置处理何时用
// 		//  “取消”来关闭对话框的代码
// 	}

	// 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序,
	//  而不是启动应用程序的消息泵。
	return FALSE;
}
Beispiel #8
0
int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT)
{
	CMessageLoop theLoop;
	_Module.AddMessageLoop(&theLoop);

	CMainFrame wndMain;
	
	pGlobalMain=&wndMain;

#ifdef APP_PLAYER_UI
	RegisterStuffs();
#endif

	LoadAll();


#ifdef APP_PLAYER_UI
	if(wndMain.Create(NULL,wndMain.rcDefault,GetAppName())== NULL)
#else
	if(wndMain.Create()== NULL)
#endif
	{
		ATLTRACE(_T("Main  window creation failed!\n"));
		return 0;
	}
	
#ifdef APP_PLAYER_UI
	if(wndMain.m_bLoaded)
	{wndMain.m_wndsPlacement.showCmd|=wndMain.m_uShowState;
	SetWindowPlacement(wndMain,&wndMain.m_wndsPlacement);
	}
	else
		wndMain.ShowWindow(SW_SHOW);
#endif

	int nRet = theLoop.Run();

	_Module.RemoveMessageLoop();
	return nRet;
}
Beispiel #9
0
BOOL CUnitrayApp::InitInstance()
{
	// Initialize OLE libraries
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}

	AfxEnableControlContainer();

	if (!FirstInstance ())	return FALSE ;

	WNDCLASS wndcls ;

	memset (&wndcls, 0, sizeof (WNDCLASS)) ;

	wndcls.style = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW ;
	wndcls.lpfnWndProc = ::DefWindowProc ;
	wndcls.hInstance = AfxGetInstanceHandle () ;

	wndcls.hIcon = LoadIcon (IDR_MAINFRAME) ;

	wndcls.hCursor = LoadCursor (IDC_ARROW) ;
	wndcls.hbrBackground = (HBRUSH) (COLOR_WINDOW+1) ;
	wndcls.lpszMenuName = NULL ;

	wndcls.lpszClassName = _T("cubrid_tray") ;

	if (!AfxRegisterClass (&wndcls))
	{
		TRACE ("Class Registration Failed\n") ;
		return FALSE ;
	}
	bClassRegistered = TRUE ;

	/*Enable3dControls();*/

	CMainFrame* pMainFrame = new CMainFrame;

	m_pMainWnd = pMainFrame;

	if (!pMainFrame->Create(NULL, _T("cubrid_tray")))
	{
		return FALSE;
	}

	m_pMainWnd->ShowWindow(SW_HIDE);
	m_pMainWnd->UpdateWindow();

	return TRUE;
}
Beispiel #10
0
BOOL CTrayApp::InitInstance()
{
  //Initialize ATL
  _Module.Init(NULL, m_hInstance);

  CMainFrame* pMainFrame = new CMainFrame;
  m_pMainWnd = pMainFrame;
  if (!pMainFrame->Create(NULL, _T("Traytest")))
    return FALSE;

  m_pMainWnd->ShowWindow(SW_HIDE);
  m_pMainWnd->UpdateWindow();

	return TRUE;
}
BOOL CDataViewApp::InitInstance()
	{
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);
//	ProcessShellCommand(cmdInfo);

	CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
		//Set up date and time defaults so they're the same as system defaults
	setlocale(LC_ALL, "usa");

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	AfxEnableControlContainer();

	HBRUSH hBrush=(HBRUSH)GetStockObject(WHITE_BRUSH);
	HCURSOR hCur=(HCURSOR)::LoadCursor(NULL,IDC_ARROW);
	HICON hIco=LoadIcon(MAKEINTRESOURCE(IDR_MAINFRAME));
	LPCTSTR lpClass=AfxRegisterWndClass(CS_DBLCLKS|CS_VREDRAW,hCur,hBrush,hIco);

	CMainFrame *pMainFrame = new CMainFrame;
	RECT rcM = { 0,0,100,100 };
	::GetWindowRect(::GetDesktopWindow(),&rcM);
	if (!pMainFrame->Create(lpClass,"Interactive Time Series Viewer", WS_VISIBLE | WS_OVERLAPPEDWINDOW,rcM,NULL,NULL))	return FALSE;

	m_pMainWnd = pMainFrame;
	pMainFrame->ShowWindow(m_nCmdShow|SW_SHOWMAXIMIZED);
	pMainFrame->UpdateWindow();

	pMainFrame->MaiFrameMenu.LoadMenu(IDR_MAINFRAME);

	pMainFrame->SetMenu(&pMainFrame->MaiFrameMenu);
	pMainFrame->SendMessage(WM_COMMAND,IDC_AUTOAMP);
	LoadGainMenu();
	LoadFilterMenu();
	return TRUE;

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


	//
	// Check USER API DLL availability
	//

	HMODULE hDll = ::LoadLibraryEx(_T("ndasuser.dll"), NULL, 0);
	if (NULL == hDll) {
		(VOID) ::MessageBox(::GetDesktopWindow(), 
			_T("Unable to load NDASUSER.DLL.\n")
			_T("Please check the installation."),
			_T("NDAS Management Error"),
			MB_OK | MB_ICONERROR | MB_SETFOREGROUND);
		return -1;
	}

	BOOL fSuccess = ::FreeLibrary(hDll);
	ATLASSERT(fSuccess);

	CMainFrame wndMain;

#ifndef HWND_MESSAGE
#define HWND_MESSAGE     ((HWND)-3)
#endif

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

	wndMain.ShowWindow(SW_HIDE); // nCmdShow);

	int nRet = theLoop.Run();

	_Module.RemoveMessageLoop();
	return nRet;
}
Beispiel #13
0
INT WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow )
{
#if	_DEBUG
	// メモリリーク検出
	int	Flag = _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG );
	Flag |= _CRTDBG_LEAK_CHECK_DF;
	Flag &= ~_CRTDBG_CHECK_ALWAYS_DF;
	_CrtSetDbgFlag( Flag );
#endif

	// 簡易ウィルスチェック
	if( SimpleVirusChecker() > 0 ) {
		if( ::GetUserDefaultLCID() == 0x0411 ) {
			if( ::MessageBox( NULL, "このPCはウィルスプログラムに感染している可能性があります。\n"
						"危険ですのでなるべく早急にウィルスチェックを行って下さい。\n\n"
						"それでも実行しますか?", "VirtuaNES 簡易ウィルスチェッカー", MB_ICONWARNING|MB_YESNO|MB_DEFBUTTON2 ) == IDNO )
				return	-1L;
		} else {
			if( ::MessageBox( NULL, "This PC may be infected with a virus program!!!\n"
						"Should become danger, and please do a check to it immediately!!!\n\n"
						"Do execute even it?", "VirtuaNES simple virus checker", MB_ICONWARNING|MB_YESNO|MB_DEFBUTTON2 ) == IDNO )
				return	-1L;
		}
	}

	// メインフレームウインドウオブジェクト
	CMainFrame	MainFrame;

	// Mutex
	HANDLE	hMutex = NULL;

	// アプリケーションインスタンス等の設定
	CHAR	szPath[ _MAX_PATH ];
	GetModuleFileName( hInstance, szPath, sizeof(szPath) );
	string	ModulePath = CPathlib::SplitPath( szPath );
	CApp::SetModulePath( ModulePath.c_str() );
	DEBUGOUT( "Module Path:\"%s\"\n", ModulePath.c_str() );

	CApp::SetInstance( hInstance );
	CApp::SetPrevInstance( hPrevInstance );
	CApp::SetCmdLine( lpCmdLine );
	CApp::SetCmdShow( nCmdShow );

//DEBUGOUT( "ThreadID:%08X\n", ::GetCurrentThreadId() );

//	CRegistry::SetRegistryKey( "Emulators\\VirtuaNES" );
	CRegistry::SetRegistryKey( "VirtuaNES.ini" );

	if( !CPlugin::FindPlugin( CApp::GetModulePath() ) ) {
		::MessageBox( NULL, "Language plug-in is not found.", "VirtuaNES", MB_ICONERROR|MB_OK );
		goto	_Error_Exit;
	}
	DEBUGOUT( "Plugin Path:\"%s\"\n", CPlugin::GetPluginPath() );
	DEBUGOUT( "Language   :\"%s\"\n", CPlugin::GetPluginLanguage() );
	DEBUGOUT( "LCID       :\"%d\" \"0x%04X\"\n", CPlugin::GetPluginLocaleID(), CPlugin::GetPluginLocaleID() );

	HINSTANCE hPlugin;
	if( !(hPlugin = CPlugin::LoadPlugin()) ) {
		::MessageBox( NULL, "Language plug-in load failed.", "VirtuaNES", MB_ICONERROR|MB_OK );
		goto	_Error_Exit;
	}
	CApp::SetPlugin( hPlugin );

	::InitCommonControls();

	// 設定のロード
	CRegistry::SetRegistryKey( "VirtuaNES.ini" );
	Config.Load();
	CRecent::Load();

	// 二重起動の防止
	hMutex = ::CreateMutex( NULL, FALSE, VIRTUANES_MUTEX );
	if( ::GetLastError() == ERROR_ALREADY_EXISTS ) {
		::CloseHandle( hMutex );
		if( Config.general.bDoubleExecute ) {
			HWND	hWnd = ::FindWindow( VIRTUANES_WNDCLASS, NULL );
//			HWND	hWnd = ::FindWindow( VIRTUANES_WNDCLASS, VIRTUANES_CAPTION );

			CHAR	szTitle[256];
			::GetWindowText( hWnd, szTitle, sizeof(szTitle)-1 );

			// タイトルバーが同じかどうかチェック
			if( ::strncmp( szTitle, VIRTUANES_CAPTION, ::strlen(VIRTUANES_CAPTION) ) == 0 ) {
				// 起動していた方をフォアグラウンドにする
				::SetForegroundWindow( hWnd );

				// コマンドライン引数があるなら動作中のVirtuaNESのウインドウにファイル名
				// メッセージを送りつけてそちらで動作させる
				// (当然の様に対応バージョンでないとダメ)
				if( ::strlen( lpCmdLine ) > 0 ) {
					CHAR	szCmdLine[_MAX_PATH];
					::strcpy( szCmdLine, lpCmdLine );
					::PathUnquoteSpaces( szCmdLine );

					COPYDATASTRUCT	cds;
					cds.dwData = 0;
					cds.lpData = (void*)szCmdLine;
					cds.cbData = ::strlen(szCmdLine)+1; //  終端のNULLも送る
					//  文字列送信
					::SendMessage( hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds );
				}

				// 終了
				goto	_DoubleExecute_Exit;
			}
		}
	}

	if( !MainFrame.Create(NULL) )
		goto	_Error_Exit;
	DEBUGOUT( "CreateWindow ok.\n" );

	// メインウインドウの表示
	::ShowWindow( CApp::GetHWnd(), CApp::GetCmdShow() );
	::UpdateWindow( CApp::GetHWnd() );

	// フック
	CWndHook::Initialize();

	// ランチャー同時起動
	if( Config.general.bStartupLauncher ) {
		::PostMessage( CApp::GetHWnd(), WM_COMMAND, ID_LAUNCHER, 0 );
	}

	// コマンドライン
	if( ::strlen( lpCmdLine ) > 0 ) {
		LPSTR	pCmd = lpCmdLine;
		if( lpCmdLine[0] == '"' ) {	// Shell execute!!
			lpCmdLine++;
			if( lpCmdLine[::strlen( lpCmdLine )-1] == '"' ) {
				lpCmdLine[::strlen( lpCmdLine )-1] = '\0';
			}
		}
	}

	if( ::strlen( lpCmdLine ) > 0 ) {
		::PostMessage( CApp::GetHWnd(), WM_VNS_COMMANDLINE, 0, (LPARAM)lpCmdLine );
	}

	MSG	msg;
	BOOL	bRet;
	while( (bRet = ::GetMessage( &msg, NULL, 0, 0 )) != 0 ) {
		// エラー?
		if( bRet == -1 )
			break;
		// メインウインドウのメッセージフィルタリング
		if( CApp::GetHWnd() == msg.hwnd ) {
			CWnd* pWnd = (CWnd*)::GetWindowLong( msg.hwnd, GWL_USERDATA );
			if( pWnd ) {
				if( pWnd->PreTranslateMessage( &msg ) )
					continue;
			}
		}
		if( CWndList::IsDialogMessage( &msg ) )
			continue;
		::TranslateMessage( &msg );
		::DispatchMessage( &msg );
	}
	// フック
	CWndHook::Release();

	// 設定の保存
	CRegistry::SetRegistryKey( "VirtuaNES.ini" );
	Config.Save();
	CRecent::Save();

	// DirectX系破棄
	DirectDraw.ReleaseDDraw();
	DirectSound.ReleaseDSound();
	DirectInput.ReleaseDInput();

	if( hMutex )
		::ReleaseMutex( hMutex );
	CLOSEHANDLE( hMutex );

_DoubleExecute_Exit:
	::FreeLibrary( CApp::GetPlugin() );

	return	msg.wParam;

_Error_Exit:
	// DirectX系破棄
	DirectDraw.ReleaseDDraw();
	DirectSound.ReleaseDSound();
	DirectInput.ReleaseDInput();

	if( CApp::GetPlugin() ) {
		::FreeLibrary( CApp::GetPlugin() );
	}

	return	-1;
}
Beispiel #14
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
	CExceptionHandle::MapSEtoCE();
	try
	{
		// 在最开始需要进行初始化,否则可能会导致程序中的硬件id不一致.
		// 读取Hardware id
		InitHardwareId();

	}
	catch(CExceptionHandle eH)
	{
		g_strHardwareId = "NULL Can not get Hardware";
		eH.SetThreadName ("BKUI _tWinMain GetHardwareId Error");
		eH.RecordException ();
	}

	CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"读取了硬件ID");
	//判断gid的长度,如果不为32位,则补充为32位长度
	g_AppBranch.CheckHID();

	// 检测访问自身进程权限的句柄,如果限制访问,退出
	if(!g_AppBranch.CheckToken())
	{
		CRecordProgram::GetInstance()->FeedbackError(MY_PRO_NAME, MY_COMMON_ERROR, L"CheckToken错误");
		return 0;
	}
	if(wcslen(lpstrCmdLine) > 0)
	{
		WCHAR sLine[256] = {0};
		swprintf(sLine, 256, L"输入参数%s",lpstrCmdLine);
		CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, sLine);
	}

	if(_tcsncmp(lpstrCmdLine, _T("-renamechk"), 10) == 0)
	{
		g_AppBranch.RenameChk();
		return 0;
	}

	//注释掉该部分的支持,改为反馈处理,时间设置为5s超时
	//if (_tcsncmp(lpstrCmdLine, _T("-ifeedback"), 10) == 0)
	//{
	//	// 如果本地没有SN,生成一个SN并写入注册表,否则返回原有的SN
	//	CSNManager::GetInstance()->GetSN();

	//	//CUserBehavior::GetInstance()->BeginFeedBack();//!!!!!这个放在这里,创建反馈线程,否则有些消息反馈不回去
	//	CUserBehavior::GetInstance()->Action_Install(1);

	//	CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"安装反馈");
	//	//g_AppBranch.Install();
	//	//CUserBehavior::GetInstance()->CloseFeedBack();

	//	// 安装并启动驱动
	//	return 0;
	//}
	//else if (_tcsncmp(lpstrCmdLine, _T("-dfeedback"), 10) == 0)
	//{
	//	// 发送卸载程序的数据到服务器
	//	CUserBehavior::GetInstance()->Action_Uninstall(1);
	//	//CUserBehavior::GetInstance()->BeginFeedBack();
	//	CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"卸载驱动");
	//	// 卸载驱动
	//	//g_AppBranch.UnInstall();
	//	//CUserBehavior::GetInstance()->CloseFeedBack();
	//	return 0;
	//}


	setlocale(LC_ALL, "CHS");
	// 初始化
	CResourceManager::Initialize();
	if(_tcsncmp(lpstrCmdLine, _T("-startuac "), 10) == 0)
	{
		g_AppBranch.RunUAC(lpstrCmdLine);
		return 0;
	}

	if(_tcsncmp(lpstrCmdLine, _T("-ShellExecute "), 14) == 0)
	{
		g_AppBranch.Shell(lpstrCmdLine);
		return 0;
	}

	if(_tcsncmp(lpstrCmdLine, _T("-uac"), 4) == 0)
	{
		CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"启动了UAC");
		// 提升权限,进行驱动安装
		CListManager::Initialize(true);
		return 0;
	}

	//////////////////////////////////////////////////////////////////////////
	// 参数解析
	if (_tcsncmp(lpstrCmdLine, _T("-wait"), 5) == 0)
	{
		CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"延迟启动");
		Sleep(5000);//5s后重启财金汇
	}
	// IE内核进程
	else if (_tcsncmp(lpstrCmdLine, _T("-! "), 3) == 0)
	{
		// 启动内核进程
		CUserBehavior::GetInstance()->BeginFeedBack();//!!!!!这个放在这里,创建反馈线程,否则有些消息反馈不回去
		CHostContainer::GetInstance()->GetHostName(kFeedback);
		g_AppBranch.RunIECoreProcess(lpstrCmdLine);
		return 0;
	}

	// 安装驱动
	if (_tcsncmp(lpstrCmdLine, _T("-i"), 2) == 0)
	{
		// 如果本地没有SN,生成一个SN并写入注册表,否则返回原有的SN
		CSNManager::GetInstance()->GetSN();

		CUserBehavior::GetInstance()->Action_Install(1);
		//CUserBehavior::GetInstance()->BeginFeedBack();//!!!!!这个放在这里,创建反馈线程,否则有些消息反馈不回去

		CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"安装驱动");
		g_AppBranch.Install();
		//CUserBehavior::GetInstance()->CloseFeedBack();

		// 安装并启动驱动
		return 0;
	}
	else if (_tcsncmp(lpstrCmdLine, _T("-upi"), 4) == 0)
	{
		// 如果本地没有SN,生成一个SN并写入注册表,否则返回原有的SN
		CSNManager::GetInstance()->GetSN();

		//CBankData::GetInstance()->UpdateDB();//新版本的安装要升级旧版本的数据库

		CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"升级安装驱动");
		// 安装并启动驱动
		return g_AppBranch.Install();
	}
	// 卸载程序
	else if (_tcsncmp(lpstrCmdLine, _T("-d"), 2) == 0)
	{
		// 发送卸载程序的数据到服务器
		CUserBehavior::GetInstance()->Action_Uninstall(1);
		CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"卸载驱动");
		// 卸载驱动
		g_AppBranch.UnInstall();
		TerminateProcess(::GetCurrentProcess(), 0);
		return 0;
	}
	else if (_tcsncmp(lpstrCmdLine, _T("-upd"), 4) == 0 && wcslen(lpstrCmdLine) == 4)
	{
		CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"升级卸载驱动");
		// 卸载驱动
		return g_AppBranch.UnInstall();
	}
	// 清除用户信息,在内核进程中被调用
	else if (_tcsncmp(lpstrCmdLine, _T("-clean"), 6) == 0)
	{
		HANDLE hMutex = CreateMutexW(NULL, FALSE, L"UI_SECURITY_MUTEX");

		// 根据操作系统的版本来清除历史记录
		CleanHistoryMain();

		//if( hMutex )
			//::CloseHandle(hMutex);
		
		return 0;
	}

	// pop 调用,用来更改显示页
	if (_tcsncmp(lpstrCmdLine, _T("-agent"), 6) == 0)
	{
		wstring mail = lpstrCmdLine;
		mail = mail.substr(6, wstring::npos);
		if(g_AppBranch.PopSetPage(mail))
			return 0;
		CUserBehavior::GetInstance()->Action_ProgramStartup(kPopupWin);//Svr启动反馈
		// 错误代码写入到本地日志中
		CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"Svr启动财金汇");
	}
		//RunUAC();
	//重新生成黑名单
	//add by bh 2011 3 20 保护UI
	if (_tcsncmp(lpstrCmdLine, _T("-ncheck"), 7) != 0 &&  _tcsncmp(lpstrCmdLine, _T("-verchange"), 10) != 0)
	{
		g_AppBranch.GenerationBlackCache();
		//黑白名单由pop发送到驱动,故把该检测pop是否启动的位置提到最前,这样做才能解决UI进程被有道注入的问题
		if(!g_AppBranch.CheckPop(false)) // 检测Pop是否在运行中,如果pop没有运行那么就启动泡泡
		{
			g_AppBranch.CloseHandle();
			return 0;
		}
	}

	if (g_AppBranch.IsAlreadyRunning())
	{
		return 0;
	}

	if (_tcsncmp(lpstrCmdLine, _T("-ncheck"), 7) != 0 &&  _tcsncmp(lpstrCmdLine, _T("-verchange"), 10) != 0)
	{
		CProcessManager::_()->SetFilterId( 0 );
		CProcessManager::_()->SetFilterId( (UINT32)GetCurrentProcessId() );
	}
	
		g_strSkinDir = ::GetModulePath();
		g_strSkinDir += _T("\\Skin\\");

		::OleInitialize(NULL);

		// 初始化GDI对象
		Gdiplus::GdiplusStartupInput gdiplusStartupInput; 
		ULONG_PTR gdiplusToken;
		Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

		// 初始化CRichEditCtrl对象,并对其进行挂钩
		::AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES);
		::LoadLibrary(CRichEditCtrl::GetLibraryName());

		DoPatchRichEditHook();

		// 初始化皮肤显示
		CSkinLoader::Initialize();
		ThreadCacheDC::CreateThreadCacheDC();
		new CSkinManager();
		g_pSkin->RefreshAllSkins(false);

		// 安装时的安全检测,由于需要资源,所以要放在这个位置
		if (_tcsncmp(lpstrCmdLine, _T("-ncheck"), 7) == 0)
		{			
			g_AppBranch.CloseHandle();
			return  g_AppBranch.InstallCheck();
		}

		INT64 tBase = 129383136000000000;//s2,100纳秒为单位,格林尼治时间2011.1.1号和1601年之间的差值
		FILETIME tCurrent;
		GetSystemTimeAsFileTime(&tCurrent);
		INT64 tIntCur = tCurrent.dwHighDateTime * 0x100000000 + tCurrent.dwLowDateTime;//
		if(tIntCur < tBase)
		{
			mhMessageBox(NULL,L"检测到您的系统时间异常,您将无法使用财金汇,请修改您的系统时间后再运行财金汇",L"财金汇",MB_OK);
			return 1;		
		}

		if (_tcsncmp(lpstrCmdLine, _T("-verchange"), 10) == 0 && wcslen(lpstrCmdLine) == 10)
		{
			// 如果本地没有SN,生成一个SN并写入注册表,否则返回原有的SN
			CBankData::GetInstance()->InstallUpdateDB();//升级数据库

			// 安装并启动驱动
			return 0;
		}
		// 检查是否需要安装升级包
		if(!g_AppBranch.UpdateCheck())
		{
			g_AppBranch.CloseHandle();
			return 0;
		}
		CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"检查是否需要安装升级包");

		//////////////////////////////////////////////////////////////////////////
		//////////////////////////////////////////////////////////////////////////
		// gao 2010-12-16 将listmanager读取内核和UI数据分开
		CListManager::Initialize(false);
		CHostContainer::GetInstance()->GetHostName(kFeedback);
		CBankData::GetInstance()->CloseDB();
		CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"初始化ListManager");		// 初始化全局变量
		// 等待IE内核进程退出
		int testtime = 0;
		while(g_AppBranch.CheckIECoreProcess() == true)
		{
			testtime ++;
			if(testtime > 15)
			{
				mhMessageBox(NULL,L"财金汇运行异常,请稍等后重新启动财金汇",L"财金汇检测",MB_OK);
				CRecordProgram::GetInstance()->FeedbackError(MY_PRO_NAME, MY_COMMON_ERROR, L"内核运行异常,关闭内核");

				// 这里应该增加关闭另一个进程的函数。
				//::TerminateProcess();
				g_AppBranch.TerminateIECore();
				g_AppBranch.CloseHandle();
				return 0;			
			}

			Sleep(2000);
		}

		//////////////////////////////////////////////////////////////////////////
		// Main Frame

		// 显示界面
		int nShowWindow = SW_SHOW;
		RECT rcWnd;
		DWORD dwMax = 0;
		//获得frame的大小和显示状态
		g_AppBranch.GetFramePos(nShowWindow,rcWnd,dwMax);

		// 安装时用于找窗口用的空窗口
		CSignalWnd* pSignalWnd = new CSignalWnd;
		HWND hSignalWnd = pSignalWnd->Create(NULL, CWindow::rcDefault);
	


#ifndef SINGLE_PROCESS
		// 安全检测
		if(!g_AppBranch.SecurityCheck())
		{
			g_AppBranch.CloseHandle();
			return 0;
		}

		CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"通过安全检查");

#endif
		CUserBehavior::GetInstance()->BeginFeedBack();//!!!!!这个放在这里,创建反馈线程,否则有些消息反馈不回去
		//////////////////////////////////////////////////////////////////////////
		// 用户行为反馈(启动)
		if (_tcsncmp(lpstrCmdLine, _T(""), 1) == 0)
		{
			CUserBehavior::GetInstance()->Action_ProgramStartup(kDesktop);

			// 在本地记录错误日志
			CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"用户启动程序");
		}


		//////////////////////////////////////////////////////////////////////////

		g_AppBranch.RefreshCurrency();
#ifndef SINGLE_PROCESS
		// 开启定时检测挂钩和注册表的函数
		g_AppBranch.StartMonitor();
#endif

		//////////////////////////////////////////////////////////////////////////

		// 创建亲显示UI框架
		CMainFrame *pFrame = new CMainFrame();
		dwMax = 1;//启动最大化
		HWND hFrame = pFrame->Create(NULL, rcWnd, _T("财金汇"), (dwMax ? WS_MAXIMIZE : 0) | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN);

		CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"财金汇界面启动");

		pFrame->ShowWindow(nShowWindow);
		pFrame->UpdateWindow();

		// 创建ie内核进程
		CProcessManager::_()->CreateProcess(pFrame->m_hWnd);

		//RunUAC();
		HOOKKEY::disablePrintKey();
	
 		HOOKKEY::installHook();// 安装键盘钩子
 		HOOKKEY::addNPB();

		//控制显示向导
		//g_AppBranch.CheckGuide(hFrame);去掉该显示功能

		CRecordProgram::GetInstance()->RecordCommonInfo(MY_PRO_NAME, MY_COMMON_PROCESS, L"财金汇界面消息");


		//消息循环
		MSG msg;
		while (::GetMessage(&msg, NULL, 0, 0))
		{
			if (msg.message == WM_KEYDOWN && msg.wParam == VK_TAB)
			{
				if (GetKeyState(VK_CONTROL) & 0x8000)
				{
					pFrame->FS()->pCate->ToggleItem();
					continue;
				}
			}

			::TranslateMessage(&msg);
			::DispatchMessage(&msg);
 			HOOKKEY::uninstallHook();
 			HOOKKEY::installHook();
		}

		//////////////////////////////////////////////////////////////////////////
		// 用户行为反馈(退出)


		CUserBehavior::GetInstance()->Action_ProgramExit();
		CUserBehavior::GetInstance()->CloseFeedBack();//关闭反馈线程
		// 在本地记录错误日志
		// 反馈过滤名单
		//////////////////////////////////////////////////////////////////////////

#ifndef SINGLE_PROCESS
		// 关闭检测
		g_AppBranch.StopMonitor();
#endif

		CleanHistoryMain(FALSE);


	try
	{
		OleUninitialize( );
		HOOKKEY::EnablePrintKey();
		g_AppBranch.CloseHandle();
	}
	catch(CExceptionHandle eH)
	{
		eH.SetThreadName ("BKUI _tWinMain Thread Error");
		eH.RecordException ();
	}
	return 0;
}
Beispiel #15
0
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
	_In_opt_ HINSTANCE hPrevInstance,
	_In_ LPTSTR    lpCmdLine,
	_In_ int       nCmdShow)
{

	m_cefApp = new ClientApp();
	if (!(m_cefApp->Init(hInstance) < 0))
		return FALSE;

	CWndShadow::Initialize(hInstance);


	wstring strFileName = ZYM::CPath::GetAppPath() + _T("ImageOleCtrl.dll");

	BOOL bRet = DllRegisterServer(strFileName.c_str());	// 注册COM组件
	if (!bRet)
	{
		::MessageBox(NULL, _T("COM组件注册失败,应用程序无法完成初始化操作!"), _T("提示"), MB_OK);
		return 0;
	}

	HRESULT hr = ::OleInitialize(NULL);
	if (FAILED(hr))
		return 0;

	GdiplusStartup(&g_gdiplusToken, &g_gdiplusStartupInput, NULL);	// 初始化GDI+
	HMODULE hRichEditDll = ::LoadLibrary(_T("Riched20.dll"));	// 加载RichEdit控件DLL

	CPaintManagerUI::SetInstance(hInstance);
	CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath() + _T("SkinRes"));

	HRESULT Hr = ::CoInitialize(NULL);
	if (FAILED(Hr)) return 0;

	CLoginWnd* pLoginFrame = new CLoginWnd();
	CMainFrame *pWndFrame = new CMainFrame(pLoginFrame->m_manager);
	pLoginFrame->Create(NULL, _T(""), UI_WNDSTYLE_DIALOG, 0, 0, 0, 0, 0, NULL);
	pLoginFrame->CenterWindow();

	pWndFrame->SetHandler();
	int result = pLoginFrame->ShowModal();

	if (result == 1)
	{
		
		pWndFrame->Create(NULL, _T(""), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE | WS_EX_ACCEPTFILES);
		pWndFrame->CenterWindow();
		pWndFrame->ShowModal();
		

	}
	else
	{
		//登录失败
	}

	

	CPaintManagerUI::MessageLoop();
	::CoUninitialize();


	if (hRichEditDll != NULL)					// 卸载RichEdit控件DLL
		::FreeLibrary(hRichEditDll);

	Gdiplus::GdiplusShutdown(g_gdiplusToken);	// 反初始化GDI+
	::OleUninitialize();


	m_cefApp->Exit();
	m_cefApp = NULL;

	
	if (_globalSetting.m_logoutState == 1)
	{
		CDuiString path = GetCurrentPathW();
		path += L"\\YunKa.exe";
		ShellExecute(NULL, L"open", path.GetData(), NULL, NULL, SW_SHOWNOACTIVATE);
	}


	return 0;
}
Beispiel #16
0
BOOL CLoginWnd::Login()
{
	HANDLE hFile = CreateFile(L"..\\sqlconfig.dat",GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
	if (hFile == INVALID_HANDLE_VALUE)
	{
		CloseHandle(hFile);
		MessageBox(NULL,_T("请先配置数据库"),_T("提示"),NULL);
		return FALSE;
	}
	char buf[48];
	memset(buf,0,sizeof(buf));
	DWORD len = sizeof(buf);
	ReadFile(hFile,buf,len,&len,NULL);
	std::string	UserName = buf;
	SetFilePointer(hFile,50,NULL,FILE_BEGIN);
	ReadFile(hFile,buf,len,&len,NULL);
	std::string PassWord = buf;
	SetFilePointer(hFile,100,NULL,FILE_BEGIN);
	ReadFile(hFile,buf,len,&len,NULL);
	std::string IP = buf;
	SetFilePointer(hFile,150,NULL,FILE_BEGIN);
	ReadFile(hFile,buf,len,&len,NULL);
	USHORT port = (USHORT)atoi(buf);
	CloseHandle(hFile);
	if (!m_mySql.ConnectToDB(IP,port,UserName,PassWord))
	{
		CloseHandle(hFile);
		MessageBox(NULL,_T("连接服务器失败"),_T("提示"),NULL);
		return FALSE;
	}
	GetData();
	std::string y = "'";
	std::string strsql = "select * from manager where name="+y+m_strAccount.GetStringA()+y;
	std::auto_ptr<sql::ResultSet> res = m_mySql.ExecuteQuery(strsql);
	if (res->next())
	{
		m_iPower = res->getInt("power");
		if (m_strPassWord.GetStringA() == res->getString("password"))
		{
			::DestroyWindow(m_hWnd);
			WriteLogState();
			CMainFrame *pFrame = new CMainFrame;
			pFrame->Create(NULL, _T("MainFrameWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);
			pFrame->ShowModal();
			delete pFrame; 
		}
		else
		{
			CloseHandle(hFile);
			MessageBox(NULL,_T("密码错误"),_T("提示"),NULL);
			return FALSE;
		}
	}
	else
	{
		CloseHandle(hFile);
		MessageBox(NULL,_T("用户名不存在"),_T("提示"),NULL);
		return FALSE;
	}
	CloseHandle(hFile);
	return TRUE;
}
Beispiel #17
0
void CFrameWnd::Notify( TNotifyUI& msg )
{
	if( msg.sType == _T("click") ) 
	{
		if (_tcsicmp(msg.pSender->GetName(), _T("closebtn")) == 0)
		{
			OnExit(msg);
		}
		else if (_tcsicmp(msg.pSender->GetName(), _T("minbtn")) == 0)
		{
#if defined(UNDER_CE)
			::ShowWindow(m_hWnd, SW_MINIMIZE);
#else
			SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0);
#endif
		}
// 		else if (_tcsicmp(msg.pSender->GetName(), _T("maxbtn")) == 0)
// 		{
// #if defined(UNDER_CE)
// 			::ShowWindow(m_hWnd, SW_MAXIMIZE);
// 			CControlUI* pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(kMaxButtonControlName));
// 			if( pControl ) pControl->SetVisible(false);
// 			pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(kRestoreButtonControlName));
// 			if( pControl ) pControl->SetVisible(true);
// #else
// 			SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0);
// #endif
// 		}
// 		else if (_tcsicmp(msg.pSender->GetName(), _T("restorebtn")) == 0)
// 		{
// #if defined(UNDER_CE)
// 			::ShowWindow(m_hWnd, SW_RESTORE);
// 			CControlUI* pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(kMaxButtonControlName));
// 			if( pControl ) pControl->SetVisible(true);
// 			pControl = static_cast<CControlUI*>(m_PaintManager.FindControl(kRestoreButtonControlName));
// 			if( pControl ) pControl->SetVisible(false);
// #else
// 			SendMessage(WM_SYSCOMMAND, SC_RESTORE, 0);
// #endif
// 		}
		else if( msg.pSender->GetName() == _T("login") ) 
		{
			
			this->ShowWindow(SW_HIDE);
			
	
			HINSTANCE hInst;
			//MessageBox(NULL,_T("login click"),_T("文件名"),0);


			::CoInitialize(NULL);
			CPaintManagerUI::SetInstance(hInst );
#ifdef mydebug
	CMainFrame *pFrame = new CMainFrame(_T("E:\\code\\duilib\\duilib\\r387\\fim\\Release\\images\\main_frame.xml"));
#else
	CMainFrame *pFrame = new CMainFrame(_T("./images/main_frame.xml"));
#endif
			
			pFrame->Create(NULL, _T("fim 0.1"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);
	//		pFrame->SetBkColor(Colors[0][0]);
			
			
// 			pFrame->UpdateFriendsList();
// 			pFrame->UpdateGroupsList();
// 			pFrame->UpdateMicroBlogList();
			pFrame->ShowModal();
			//MoveWindow(hInst,1,1,100,100);
			this->Close();
			delete pFrame;
			::CoUninitialize();
		}
	}


	__super::Notify(msg);
}