Exemplo n.º 1
0
//------------------------------------------------------------------------
//! Checks if it is possible to modify the collapse state of a group.
//! This is only possible in Windows Vista.
//!
//! @return Groups can be collapsed (true / false)
//------------------------------------------------------------------------
BOOL CGridListCtrlGroups::IsGroupStateEnabled()
{
	if (!IsGroupViewEnabled())
		return FALSE;

	return CheckOSVersion(0x0600);
}
Exemplo n.º 2
0
//*=================================================================================
//*原型: void TServer::RunService(LPCTSTR pszServiceName, 
//*                               LPCTSTR pszDisplayName, LPSTR lpCmdLine)
//*功能: 服务器入口
//*参数: pszServiceName -- 服务器名称
//*      pszDisplayName -- 服务器显示名称
//*      lpCmdLine      -- 命令行
//*返回: 无
//*说明: WINNT服务器基类
//*=================================================================================
void TServer::RunService(LPCTSTR pszServiceName, LPCTSTR pszDisplayName, LPSTR lpCmdLine)
{
	//检测操作系统版本
	CheckOSVersion();

	m_pszServiceName = pszServiceName ;
	m_pszDisplayName = pszDisplayName ;
	
	bDebug = TRUE; //add by lina 20050311
	//帮助
	if( !lstrcmp(lpCmdLine, "help") )
	{
		PrintHelp();
		return ;
	}
	
	//调试模式(仅供现场测试及内部测试用)
	else if( !lstrcmp(lpCmdLine, "debug") )
	{
		bDebug = TRUE ;
	}
	//安装为服务器
	else if( !lstrcmp(lpCmdLine, "install") )
	{
		InstallService(m_pszServiceName, m_pszDisplayName);
		return ;
	}
	//删除服务器
	else if( !lstrcmp(lpCmdLine, "delete") )
	{
		DeleteService(m_pszServiceName);
		return ;
	}
	//Start服务器
	else if( !lstrcmp(lpCmdLine, "start") )
	{
		StartServer(m_pszServiceName);
		return ;
	}
	//停止服务器
	else if( !lstrcmp(lpCmdLine, "stop") )
	{
		WriteLog("停止服务器!!!!........\n");
		printf("停止服务器!!!!........\n");
		//StopServer(m_pszServiceName);
		EndService(m_pszServiceName);
		return ;
	}

	CheckInstance();

    /*SECURITY_ATTRIBUTES sa;
    SECURITY_DESCRIPTOR sd;

	sa.nLength = sizeof(SECURITY_ATTRIBUTES);
	sa.bInheritHandle = TRUE;
	sa.lpSecurityDescriptor = &sd;

    if( InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION) ) 
	{
		SetSecurityDescriptorDacl(&sd, TRUE, (PACL)NULL, FALSE);
	}

	m_hShutdown = CreateEvent(&sa, FALSE, FALSE, "__SMART_SERVER_SHUTDOWN__");
	if( m_hShutdown == NULL )
	{
		throw TException("Call CreateEvent() Faild!",
			GetLastError());
	}*/

	if( bDebug )
	{
		SetConsole();
		ServiceMain(0, NULL);
	}
	else
	{
		SERVICE_TABLE_ENTRY   DispatchTable[] = 
		{ 
			{(LPTSTR)m_pszServiceName, ServiceMain}, 
			{NULL, NULL}
		};

		//先试着从服务管理器中启动, 如失败, 则用无窗口的方式启动
		if( !StartServiceCtrlDispatcher(DispatchTable))
		{
		/*	bDebug = TRUE;
			ServiceMain(0, NULL);

		    MSG msg;
			while (GetMessage(&msg, 0, 0, 0))
				DispatchMessage(&msg);
		*/
		}
	}
}