コード例 #1
0
ファイル: KillGamesDlg.cpp プロジェクト: byd/KidsNoGame
LONG CKillGamesDlg::OnHotKey(WPARAM wParam, LPARAM lParam)
{
	if(hide)
	{
		ShowWindow(FALSE);
		hide = !hide;
	}
	else
	{
		CString inPass = pMR->GetPassword();
		if(inPass.GetLength() == 0)
		{
			ShowWindow(TRUE);
			hide = !hide;
			AfxMessageBox("首次使用请设置密码!\n\n密码只能是数字,请至少设置5位以上。\t\t");
		}else{
			CLoginDialog *lg = new CLoginDialog();
			lg->SetInPass(inPass);
			if(lg->DoModal() == IDOK)
			{
				if(lg->bConfirmed) //验证成功
				{
					ShowWindow(TRUE);
					hide = !hide;
					delete lg;
				}
			}
		}
	}
	return 0;
}
コード例 #2
0
ファイル: main.cpp プロジェクト: ray-x/SMonitor
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);

	//禁止双开
	HANDLE hObject = CreateMutex(NULL, FALSE, "SMonitorServer.exe");
	if(ERROR_ALREADY_EXISTS == GetLastError())
	{
		CloseHandle(hObject);
		QMessageBox::warning(NULL, QString::fromLocal8Bit("警告"), QString::fromLocal8Bit("服务器已经启动"));
		return 0;
	}

	if(!loadSocket())
	{
		QMessageBox::information(NULL, "error", QString::fromLocal8Bit("加载SOCKET库失败, 服务器启动失败"));
		return 0;
	}

	
	//读取配置文件
	readConfigure();

	//启动服务器业务日志管理器
	QString dataPath = QApplication::applicationDirPath() + "/ServerLogger/SvrLog";
	QDir dir;
	if(!dir.mkpath(dataPath))
	{
		QMessageBox::warning(NULL, "Error", 
			QString::fromLocal8Bit("日志目录[%1]创建失败,请确认目标磁盘是否空间已满").arg(dataPath),
			QString::fromLocal8Bit("确定"));
		return false;
	}

	//dataPath = "d:/ServerLogger/SvrLog";  //yhb
	if(!ServerLogger->Start(dataPath.toLocal8Bit().constData()))
	{
		QMessageBox::information(NULL, "error", QString::fromLocal8Bit("加载服务器日志系统失败, 服务器启动失败"));
		return 0;
	}


	CLoginDialog dlg;
	if(dlg.exec() == QDialog::Rejected)
	{
		return 0;
	}

	//启动数据管理器线程
	if(!CDataManagerThread::Instance()->Start())
	{
		QMessageBox::information(NULL, "error", QString::fromLocal8Bit("数据管理器线程启动失败, 服务器启动失败"));
		return 0;
	}

	ServerLogger->AddLog("服务器软件运行");

	CSMonitorServer w;
	w.show();
	return a.exec();
}
コード例 #3
0
ファイル: networks.cpp プロジェクト: jordanchuang/geeknimo
	// 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

	/*
	CNetworksDlg dlg;
	m_pMainWnd = &dlg;
	*/

	CLoginDialog dlg;
	m_pMainWnd = &dlg;

	int nResponse = dlg.DoModal();

	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}
	
コード例 #4
0
ファイル: MCUDemoDlg.cpp プロジェクト: dalinhuang/ffmpeg-port
void CMCUDemoDlg::Login()
{
	tstringstream strServerFullUrl;	

	BOOL bHasInterface;
	CConfig::Instance()->GetLoginInterface( bHasInterface );
	if ( bHasInterface )
	{
		CLoginDialog loginDlg;
		int nloginType = loginDlg.DoModal();
		if ( CLoginDialog::LOGIN_CANCEL == nloginType )
		{
			// 退出程序。
			EndDialog(0);
			return;
		}

		this->m_htmlWnd.ClearHistoryURL();

		TCHAR ServerFullUrl[1024];
		memset(ServerFullUrl, 0, sizeof(ServerFullUrl));
		if( CConfig::Instance()->GetServerFullUrl((LPTSTR)ServerFullUrl) )
		{
			Log() << L"ServerFullUrl:"<<ServerFullUrl << endl;
		}
		else
		{
			Log() << L"服务器地址不是合法的HTTP地址:"<< endl;
			MessageBox(L"服务器地址不是合法的HTTP地址!", L"错误", MB_OK);
			return;
		}

		HRESULT hr = IsValidURL( NULL, (LPCTSTR)ServerFullUrl, 0 );
		if( S_OK != hr )
		{
			MessageBox(L"服务器地址配置不合法!", L"错误", MB_OK);
			return; 
		}

		strServerFullUrl << ServerFullUrl;

		tstring strRegionId;
		CConfig::Instance()->GetRegionId( strRegionId );
		tstringstream ssAccount;
		ssAccount << (LPCTSTR)loginDlg.m_strUserId << _T( "@" ) << strRegionId;

		string strResult = UTF16toUTF8( ssAccount.str() );
		char* strAccount = (char *) LocalAlloc(LMEM_FIXED, 10240);
		memset(strAccount, 0, 10240);
		UTF_8ToAsciiDisplay( strAccount, 10240, strResult.c_str(), strlen(strResult.c_str()));

		strServerFullUrl << _T( "?" );
		//strServerFullUrl << _T( "Account=" ) << ssAccount.str() << _T( "&" );
		//strServerFullUrl << _T( "Account=" ) << L"admin@%E4%BB%96.wx.js@110000"<<_T( "&" );
		strServerFullUrl << _T( "Account=" ) << strAccount << _T( "&" );
		strServerFullUrl << _T( "Password="******"&" );
		strServerFullUrl << _T( "StreamingType=" ) << int( loginDlg.m_b3GStream ? STREAM_EVDO : STREAM_1X )  << _T( "&" );
		strServerFullUrl << _T( "LoginType=" ) << (int)loginDlg.m_eLoginType;
		LocalFree (strAccount);

		// 保存.
		CMCUSession::Instance()->UserId( ssAccount.str() );
		CMCUSession::Instance()->Password( (LPCTSTR)loginDlg.m_strPassword );
		
	}
	else
	{
		tstring strServer;
		CConfig::Instance()->GetServer( strServer );
		strServerFullUrl << strServer;
	}

	this->m_htmlWnd.OpenUrl( strServerFullUrl.str().c_str() );

}
コード例 #5
0
BOOL CmicrosipApp::InitInstance()
{
	 bool AlreadyRunning;
	 HANDLE hMutexOneInstance = ::CreateMutex( NULL, TRUE,
        _T("MICROTALKNG-088FA840-B10D-11D3-BC36-006067709674"));
    AlreadyRunning = (GetLastError() == ERROR_ALREADY_EXISTS);
    if (hMutexOneInstance != NULL) {
        ::ReleaseMutex(hMutexOneInstance);
    }
    if ( AlreadyRunning && hGlobal != NULL) {
		if ( lstrcmp(theApp.m_lpCmdLine, _T("/exit"))==0) {
			::SendMessage(hGlobal, WM_CLOSE, NULL, NULL);
		} else if ( lstrcmp(theApp.m_lpCmdLine, _T("/minimized"))==0) {
		} else if ( lstrcmp(theApp.m_lpCmdLine, _T("/hidden"))==0) {
		} else {
#ifndef _GLOBAL_HIDDEN
			::ShowWindow(hGlobal, SW_SHOW);
			::SetForegroundWindow(hGlobal);
#endif
			if (lstrlen(theApp.m_lpCmdLine)) {
				COPYDATASTRUCT cd;
				cd.dwData = 1;
				cd.lpData = theApp.m_lpCmdLine;
				cd.cbData = sizeof(TCHAR) * (lstrlen(theApp.m_lpCmdLine) + 1);
				::SendMessage(hGlobal, WM_COPYDATA, NULL, (LPARAM)&cd);
			}
		}
        return FALSE;
	} else {
		if ( lstrcmp(theApp.m_lpCmdLine, _T("/exit"))==0) {
			return FALSE;
		}
	}

#ifdef _GLOBAL_PRIORITY
   SetPriorityClass(GetCurrentProcess(), _GLOBAL_PRIORITY);
#endif

	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	// Set this to include all the common control classes you want to use
	// in your application.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	InitCtrls.dwICC = ICC_LISTVIEW_CLASSES |
		ICC_LINK_CLASS | 
		ICC_BAR_CLASSES | 
		ICC_LINK_CLASS | 
		ICC_STANDARD_CLASSES | 
		ICC_TAB_CLASSES | 
		ICC_UPDOWN_CLASS;

	InitCommonControlsEx(&InitCtrls);

#ifdef _DEBUG
	if (!AllocConsole())
		AfxMessageBox(L"Failed to create the console!");
#endif

	CWinApp::InitInstance();

	//AfxEnableControlContainer();

	CoInitializeEx(NULL, COINIT_MULTITHREADED);

	AfxInitRichEdit2();
	CmicrosipDlg *microsipDlg = new CmicrosipDlg;
	m_pMainWnd = microsipDlg;
	hGlobal = m_pMainWnd->m_hWnd;

	CLoginDialog* dlg = new CLoginDialog(microsipDlg);
	if(dlg->DoModal()>1){
	m_pMainWnd->DestroyWindow();
	return false;
	}
		

	//microsipDlg->AccountSettingsPendingSave();
	//microsipDlg->PJAccountAdd();
	microsipDlg->onPowerBroadcast(PBT_APMRESUMEAUTOMATIC, NULL);

	//--
	LRESULT pResult;
	microsipDlg->OnTcnSelchangeTab(NULL, &pResult);

#if !defined _GLOBAL_NO_ACCOUNT && !defined _GLOBAL_NO_AUTO_ACCOUNT_ACTIVATION
#ifdef _GLOBAL_ACCOUNT_MINI
	if (
#ifndef _GLOBAL_NO_AUTO_REGISTER
		!accountSettings.accountId
#else
		1
#endif
		)
	{
		accountSettings.accountId = 1;
		accountSettings.SettingsSave();
	}
#endif
#endif
#ifdef _GLOBAL_CONFERENCE_DIALOG
	new ConferenceDlg(microsipDlg);
#endif

#ifdef _GLOBAL_MINIMIZED
	m_pMainWnd->ShowWindow(SW_HIDE);
#else

#endif
	m_pMainWnd->ShowWindow(SW_HIDE);
	//microsipDlg->onPowerBroadcast(PBT_APMRESUMEAUTOMATIC, NULL);

//	accountSettings.Init();
	if (!microsipDlg->m_startMinimized) {
		m_pMainWnd->ShowWindow(SW_SHOW);
	}

	//--

	if (m_pMainWnd)
      return TRUE;
   else
	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}
コード例 #6
0
BOOL CKLinePrintApp::InitInstance()
{
#if 0

	//	维持网络连接/会话
	Net net("192.168.1.1:8080");
	net.start();

	//	执行命令
	CommandExecutor ce(&net);
	string ret = ce.Execute("login");

	//	接收数据
	DataHandler dh(&net);
	

	//	初始化网络连接
	//	创建线程,发起并维持连接
	//	

	CLoginDialog loginDlg;

	if(loginDlg.DoModal()!=IDOK)
	{
		return FALSE;
	}

	CommandExecutor ce();

	string result = ce.Execute("login:oscar,12345,sr");



#endif

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

	CWinAppEx::InitInstance();

	// 初始化 OLE 库
	if (!AfxOleInit())
	{
		AfxMessageBox(IDP_OLE_INIT_FAILED);
		return FALSE;
	}
	AfxEnableControlContainer();
	// 标准初始化
	// 如果未使用这些功能并希望减小
	// 最终可执行文件的大小,则应移除下列
	// 不需要的特定初始化例程
	// 更改用于存储设置的注册表项
	// TODO: 应适当修改该字符串,
	// 例如修改为公司或组织名
	SetRegistryKey(_T("Oscar"));
	LoadStdProfileSettings(4);  // 加载标准 INI 文件选项(包括 MRU)

	InitContextMenuManager();

	InitKeyboardManager();

	// 注册应用程序的文档模板。文档模板
	// 将用作文档、框架窗口和视图之间的连接
	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CKLinePrintDoc),
		RUNTIME_CLASS(CMainFrame),       // 主 SDI 框架窗口
		RUNTIME_CLASS(CKLinePrintView));
	if (!pDocTemplate)
		return FALSE;
	AddDocTemplate(pDocTemplate);

	// 分析标准外壳命令、DDE、打开文件操作的命令行
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// 调度在命令行中指定的命令。如果
	// 用 /RegServer、/Register、/Unregserver 或 /Unregister 启动应用程序,则返回 FALSE。
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	CalendarGenerator cg;
	cg.Generate("C:\\FutureData\\ZZ", m_cal);

	//	读入账户/品种信息
	EXCHANGE.SetBalance(Utility::ReadBalance());
	TP = Utility::ReadExchangeConfig();

	//	设置默认交易日志文件
	EXCHANGE.SetLogFile(Utility::GetProgramPath() + "log\\manual.log.txt");

	srand(time(0));

	//	加载回放配置并生成日历
	m_PlaybackConfig = Utility::ReadPlaybackConfig();
	LoadPlaybackCalendar(m_PlaybackConfig);

	//	自动打开上次的文件
	char path[MAX_PATH];

	::GetPrivateProfileStringA("Files","Current","", 
							path, sizeof(path), 
							(Utility::GetProgramPath() + "klinep.ini").c_str());

	CKLinePrintDoc* pDoc = NULL;

	if(strlen(path))
	{
		pDoc = (CKLinePrintDoc*)OpenDocumentFile(CString(path));
		pDoc->LoadNextDay();
	}

	// 唯一的一个窗口已初始化,因此显示它并对其进行更新
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();
	// 仅当具有后缀时才调用 DragAcceptFiles
	//  在 SDI 应用程序中,这应在 ProcessShellCommand 之后发生
	return TRUE;
}