예제 #1
0
파일: Runner.cpp 프로젝트: ki0ki0/sudoWin
int Runner::NewCmd(LPCTSTR taskname, LPTSTR lpCmdLine)
{
	Params::Save(lpCmdLine);

	DWORD dwProcessId = ::GetCurrentProcessId();
    CHandle hEventRun( ::CreateEvent( NULL, FALSE, TRUE, c_szEventRun));
	if (::WaitForSingleObject(hEventRun, c_dwRunTimeout) != WAIT_OBJECT_0)
		return ecSimultanius;

	CString strEvent;
	strEvent.Format(c_szEventExit, dwProcessId);
	CHandle hEventExit( ::CreateEvent( NULL, TRUE, FALSE, strEvent));
	::ResetEvent( hEventExit);

    CAtlString sApp;
	sApp.Format(_T("schtasks /run /TN \"%s\""), taskname);

    STARTUPINFO startup_info = {0};
    startup_info.cb = sizeof( STARTUPINFO );
    PROCESS_INFORMATION process_info = {0};

    BOOL bStatus = ::CreateProcess( NULL, sApp.GetBuffer(MAX_PATH), NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startup_info, &process_info );
    if ( bStatus == FALSE)
        return ecRunTask;
    ::CloseHandle( process_info.hProcess );
    ::CloseHandle( process_info.hThread );

	if (::WaitForSingleObject(hEventRun, c_dwRunTimeout) != WAIT_OBJECT_0)
		return ecUnknown;

    ::WaitForSingleObject(hEventExit, INFINITE);

    return ecNoError;
}
예제 #2
0
CAtlString GetErrorDescription(HRESULT hr)
{

	CAtlString aStr;
	aStr.Format("HRESULT=0x%x; ErrorString=%s; Description=%s", hr, DXGetErrorString8(hr), DXGetErrorDescription8(hr));
	return aStr; 
}
예제 #3
0
	std::wstring Desc() const
	{
		CAtlString s;
		s.Format(L"<TCP PID:%d Local:(%s:%d) Remote:(%s:%d), State:%d>",
			dwOwningPid, Local().c_str(), dwLocalPort, Remote().c_str(), dwRemotePort, dwState);
		return (LPCTSTR)s;
	}
void CFilePage::OnBnClickedBtnIocpTest()
{
    //BOOL bRet = FALSE;
    BOOL bRet = FALSE;

    //CFIocpFileReadTask  fileReadTask;
    //API_VERIFY(fileReadTask.Create(TEXT("D:\\test.jpg"), 
    //    GENERIC_WRITE | GENERIC_READ, 
    //    FILE_SHARE_READ, NULL,
    //    OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED));

    CFElapseCounter counter;
    for (INT i = 0; i < m_nCopyFileCount; i++)
    {
        CFIocpCopyFileTask* pFileCopyTask = new CFIocpCopyFileTask(&m_iocpMgr);
        CAtlString strTagetFile;
        strTagetFile.Format(TEXT("E:\\TargetCopy_%d.txt"), counter.GetElapseTime() % LONG_MAX);
        pFileCopyTask->OpenFiles(m_strCopySrcFile, strTagetFile);
        m_iocpMgr.AssociateTask(pFileCopyTask, TRUE);
    }


    //fileIocpTask.m_OverLapped.overLapped.Offset = 0;

    //fileIocpTask.WriteFileHeader((LPOVERLAPPED)&fileIocpTask.m_OverLapped);

    //fileReadTask.Close();

    //iocpMgr.Stop();
    //iocpMgr.Close();
}
예제 #5
0
HRESULT CIIS7XMLConfigHelper::GetSiteNode(IXMLDOMDocument* pDoc, LPCWSTR pszId, IXMLDOMNode** ppSite)
{
	if (pDoc == NULL || pszId == NULL || ppSite == NULL)
		return E_POINTER;

	// we want the site corresponding to the instance string
	CAtlString sSitesQuery;
	sSitesQuery.Format(_T("/configuration/system.applicationHost/sites/site[@id='%ls']"), pszId);

	CComPtr<IXMLDOMNode> pSite;
	HRESULT hr = pDoc->selectSingleNode(CComBSTR(sSitesQuery), &pSite);
	if (hr != S_OK)
		return hr;
		
	if (pSite == NULL)
		return E_FAIL;

	return pSite.CopyTo(ppSite);
}
예제 #6
0
HRESULT CIIS7XMLConfigHelper::AddNativeModuleNode(IXMLDOMDocument* pDoc, 
												  IXMLDOMNode* pModulesNode, 
												  LPCSTR pszModuleName,
												  LPCSTR pszModulePath,
												  int bitness)
{
	if (pDoc == NULL || pModulesNode == NULL || pszModuleName == NULL)
		return E_POINTER;

	CAtlStringW sQuery;
	sQuery.Format(L"add[@name='%hs']", pszModuleName);	

	CComBSTR bsQuery(sQuery);

	// find the module node, if it doesn't exist then add it
	CComPtr<IXMLDOMNode> pModuleNode;
	HRESULT hr = pModulesNode->selectSingleNode(bsQuery, &pModuleNode);
	if (hr != S_OK || pModuleNode == NULL)
	{		
		hr = pDoc->createNode(CComVariant(NODE_ELEMENT), L"add", L"", &pModuleNode);
		if (hr != S_OK || pModuleNode == NULL)
			return hr;

		CComPtr<IXMLDOMNamedNodeMap> pAttrs;
		hr = pModuleNode->get_attributes(&pAttrs);
		if (hr != S_OK || pAttrs == NULL)
			return hr;

		CComPtr<IXMLDOMAttribute> pNameAttr;
		hr = pDoc->createAttribute(L"name", &pNameAttr);
		if (hr != S_OK || pNameAttr == NULL)
			return hr;

		hr = pNameAttr->put_text(CComBSTR(pszModuleName));
		hr = pAttrs->setNamedItem(pNameAttr, NULL);

		if (pszModulePath != NULL)
		{
			CComPtr<IXMLDOMAttribute> pImageAttr;
			hr = pDoc->createAttribute(L"image", &pImageAttr);
			if (hr != S_OK || pNameAttr == NULL)
				return hr;

			hr = pImageAttr->put_text(CComBSTR(pszModulePath));
			hr = pAttrs->setNamedItem(pImageAttr, NULL);
		}

		// set the bitness precondition
		if (bitness > 0)
		{
			CComPtr<IXMLDOMAttribute> pPreconditionAttr;
			hr = pDoc->createAttribute(L"preCondition", &pPreconditionAttr);
			if (hr != S_OK || pPreconditionAttr == NULL)
				return hr;
			
			CAtlString sBitness;
			sBitness.Format(_T("bitness%d"), bitness);

			hr = pPreconditionAttr->put_text(CComBSTR(sBitness));
			hr = pAttrs->setNamedItem(pPreconditionAttr, NULL);
		}

		hr = pModulesNode->appendChild(pModuleNode, NULL);
	}

	return hr;
}