Пример #1
0
void SourceView::showFile(std::wstring path, int proclinenum, const std::vector<double> &linecounts)
{
	currentfile = path;

	// Don't show error messages with CPP highlighting
	setPlainMode();
	if (path == "[hint KiFastSystemCallRet]")
	{
		updateText(
			" Hint: KiFastSystemCallRet often means the thread was waiting for something else to finish.\n"
			" \n"
			" Possible causes might be disk I/O, waiting for an event, or maybe just calling Sleep().\n"
			);
		return;
	}

	if (path == "" || path == "[unknown]")
	{
		updateText("[ No source file available for this location. ]");
		return;
	}


	FILE *file = _wfopen(path.c_str(),L"r, ccs=UNICODE");
	if(!file)
	{
		wchar_t *crtSub = L"\\crt\\src\\";
		wchar_t *crt = wcsstr((wchar_t *)path.c_str(), crtSub);
		if(crt) {
			for(size_t i=0;i<msDevPaths.size();i++) {
				std::wstring newPath(msDevPaths[i]);
				newPath += crt+wcslen(crtSub);
				path = newPath;
				file = _wfopen(path.c_str(),L"r");
				if(file)
					break;
			}
		}
	}

	if(!file)
	{
		updateText(std::wstring("[ Could not open file '" + path + "'. ]").c_str());
		return;
	}

	std::wstring displaytext;
	wchar_t line[1024];
	while(fgetws(line,countof(line),file))
	{
		displaytext += line;
	}

	fclose(file);

	setCppMode();

	updateText(displaytext);

	// Show line counts in margin
	for (int line=1,lineCount=linecounts.size(); line<lineCount; ++line)
	{
		if (linecounts[line])
		{
			wchar_t currCount[32];
			swprintf(currCount, countof(currCount), L"%0.2fs ", linecounts[line]);
			MarginSetText (line-1, currCount);
			MarginSetStyle(line-1, MARGIN_TEXT_STYLE);
		}
	}

	SetYCaretPolicy(wxSTC_CARET_STRICT|wxSTC_CARET_EVEN, 0);
	GotoLine(proclinenum);
	SetYCaretPolicy(wxSTC_CARET_EVEN, 0);

	MarkerDefine(1, wxSTC_MARK_BACKGROUND, wxNullColour, *wxYELLOW);
	MarkerAdd(proclinenum-1, 1);
}
Пример #2
0
void CContextMenu::AddChapterItem_Menu(HMENU parent, MatroskaChapterEntry *chapter, std::wstring chapterTitle, UINT &idCmd, UINT &indexMenu)
{
	CRASH_PROTECT_START;

	HMENU hmChapterItem = CreatePopupMenu();				
	InsertMenu(parent, indexMenu++, MF_STRING|MF_BYPOSITION|MF_POPUP, (UINT_PTR)hmChapterItem, chapterTitle.c_str());
	
	// Insert UID
	{
		SmartStringFormat wBuf;
		wBuf << _W("UID");
		wBuf << L": ";
		wBuf << chapter->chapterUID;
		InsertMenu(hmChapterItem, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
	}
	// Insert Start, End Times
	{
		SmartStringFormat wBuf;
		wBuf << _W("Start Time");
		wBuf << L": ";
		wBuf << chapter->GetTimeStartStr().c_str();
		InsertMenu(hmChapterItem, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
	}	
	if (chapter->timeEnd != 0) {
		SmartStringFormat wBuf;
		wBuf << _W("End Time");
		wBuf << L": ";
		wBuf << chapter->GetTimeEndStr().c_str();
		InsertMenu(hmChapterItem, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
	}	

	// Insert Display Strings
	for (size_t d = 0; d < chapter->display.size(); d++) {
		MatroskaChapterDisplayInfo &displayInfo = chapter->display.at(d);
		
		HMENU hmDisplayInfo = CreatePopupMenu();				
		InsertMenu(hmChapterItem, indexMenu++, MF_STRING|MF_BYPOSITION|MF_POPUP, (UINT_PTR)hmDisplayInfo, _W("Display String"));

		if (displayInfo.string.length() > 0) {
			SmartStringFormat wBuf;
			wBuf << _W("String");
			wBuf << L": ";
			wBuf << displayInfo.string.c_str();			
			InsertMenu(hmDisplayInfo, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
		}
		if (displayInfo.lang.length() > 0) {
			SmartStringFormat wBuf;
			wBuf << _W("Language");
			wBuf << L": ";
			wBuf << displayInfo.lang.c_str();
			InsertMenu(hmDisplayInfo, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
		}
		if (displayInfo.country.length() > 0) {			
			SmartStringFormat wBuf;
			wBuf << _W("Country");
			wBuf << L": ";
			wBuf << displayInfo.country.c_str();
			InsertMenu(hmDisplayInfo, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
		}
	}	

	// Insert Track UID
	HMENU hmTrackUID; 
	if (chapter->tracks.size() > 0) {
		hmTrackUID = CreatePopupMenu();				
		InsertMenu(hmChapterItem, indexMenu++, MF_STRING|MF_BYPOSITION|MF_POPUP, (UINT_PTR)hmTrackUID, _W("Track UID(s))"));
	}
	for (size_t t = 0; t < chapter->tracks.size(); t++) {
		SmartStringFormat wBuf;
		wBuf << _W("Track UID");
		wBuf << L": ";
		wBuf << (uint64)chapter->tracks.at(t);
		InsertMenu(hmTrackUID, indexMenu++, MF_STRING|MF_BYPOSITION, idCmd++, wBuf.str().c_str());
	}

	for (size_t c = 0; c < chapter->children.size(); c++) {
		MatroskaChapterEntry *childChapter = chapter->children.at(c);
		SmartStringFormat wBuf;
		wBuf << chapterTitle.c_str();
		wBuf << L"-";
		wBuf << (c+1);
		AddChapterItem_Menu(hmChapterItem, childChapter, wBuf.str(), idCmd, indexMenu);
	}

	CRASH_PROTECT_END;
}
Пример #3
0
std::wstring Team::getPlayerHudFileMapped(std::wstring const & map, u8 id){
	u8 index = getIndexMapped(map.c_str());
	return getPlayer(index)->getHudFile(id);
}
Пример #4
0
RemoteDesktop::EventLog::EventLog(std::wstring name){
	Name = name;
	auto key_path(L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\" + name);

	HKEY key;

	DWORD last_error = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
		key_path.c_str(),
		0,
		0,
		REG_OPTION_NON_VOLATILE,
		KEY_SET_VALUE,
		0,
		&key,
		0);
	if (ERROR_SUCCESS == last_error)
	{
		wchar_t szPath[MAX_PATH];
		bool ret = false;

		GetModuleFileName(NULL, szPath, ARRAYSIZE(szPath));

		const DWORD types_supported = EVENTLOG_ERROR_TYPE |
			EVENTLOG_WARNING_TYPE |
			EVENTLOG_INFORMATION_TYPE;

		RegSetValueEx(key,
			L"EventMessageFile",
			0,
			REG_SZ,
			(BYTE*)szPath,
			wcsnlen_s(szPath, MAX_PATH) * 2);

		RegSetValueEx(key,
			L"CategoryMessageFile",
			0,
			REG_SZ,
			(BYTE*)szPath,
			wcsnlen_s(szPath, MAX_PATH) * 2);

		RegSetValueEx(key,
			L"ParameterMessageFile",
			0,
			REG_SZ,
			(BYTE*)szPath,
			wcsnlen_s(szPath, MAX_PATH) * 2);

		RegSetValueEx(key,
			L"TypesSupported",
			0,
			REG_DWORD,
			(LPBYTE)&types_supported,
			sizeof(types_supported));
		DWORD catcount = 3;
		RegSetValueEx(key,
			L"CategoryCount",
			0,
			REG_DWORD,
			(LPBYTE)&catcount,
			sizeof(catcount));
		RegCloseKey(key);
	}
	else
	{
		std::cerr << "Failed to install source: " << last_error << "\n";
	}

	_EventSource = RegisterEventSource(NULL, name.c_str());
}
ATL::CString ToCString(const std::wstring& s)
{
  return ATL::CString(s.c_str());
}
Пример #6
0
void RenderContext::drawString(const std::wstring& str, const D2D1_POINT_2F& pt, IDWriteTextFormat* pFormat, ID2D1Brush* pBrush)
{
	this->pInternalContext->DrawTextW(str.c_str(), static_cast<UINT>(str.length()), pFormat, 
		D2D1::RectF(pt.x, pt.y, floatMax, floatMax), pBrush);
}
Пример #7
0
		bool SelectCertificate(const std::wstring& certStoreName, const std::string& certHash)
		{
			certStore = CertOpenStore(CERT_STORE_PROV_SYSTEM, 0, NULL, CERT_SYSTEM_STORE_CURRENT_USER, certStoreName.c_str());

			if (!certStore)
			{
				std::wcerr << L"Failed to open cert store. Error: " << std::hex << GetLastError() << L", Store: " << certStoreName << std::endl;
				return false;
			}

			CRYPT_HASH_BLOB hashBlob;
			hashBlob.pbData = (BYTE*)certHash.data();
			hashBlob.cbData = (DWORD)certHash.size();

			CERT_ID id;
			id.dwIdChoice = CERT_ID_SHA1_HASH;
			id.HashId = hashBlob;
			certContext = CertFindCertificateInStore(certStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, CERT_FIND_CERT_ID, (void *)&id, NULL);

			if (!certContext)
			{
				std::cerr << "Failed to open cert context. Error: " << std::hex << GetLastError() << ", Certificate: " << certHash << std::endl;
				return false;
			}

			return true;
		}
Пример #8
0
bool WindowsWindow::create(
    const ContextFormat & format
,   const std::string & title
,   const unsigned int width
,   const unsigned int height)
{
    const std::wstring wtitle = std::wstring(title.begin(), title.end());
    static const LPCWSTR className = L"glow::Window";

    const HINSTANCE hInstance(GetModuleHandle(NULL));

    WNDCLASSEX wcex;
    ZeroMemory(&wcex, sizeof(WNDCLASSEX));

    if (FALSE == GetClassInfoEx(hInstance, className, &wcex))
    {
        // register window class

        wcex.cbSize         = sizeof(WNDCLASSEX);
        wcex.style          = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
        wcex.lpfnWndProc    = InitialProc;
        wcex.cbClsExtra     = 0;
        wcex.cbWndExtra     = 0;
        wcex.hInstance      = hInstance;
        wcex.hIcon          = NULL;
        wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
        wcex.hbrBackground  = NULL;
        wcex.lpszMenuName   = NULL;
        wcex.lpszClassName  = className;
        wcex.hIconSm        = NULL;

        if (!RegisterClassEx(&wcex))
        {
            fatal() << "Registering the window class failed (RegisterClassEx). Error: " << GetLastError();
            return false;
        }
    }

    m_hWnd = CreateWindowEx(
        WS_EX_APPWINDOW | WS_EX_WINDOWEDGE
    ,   className
    ,   wtitle.c_str()
    ,   WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN
    ,   CW_USEDEFAULT
    ,   CW_USEDEFAULT
    ,   width
    ,   height
    ,   NULL
    ,   NULL
    ,   hInstance
    ,   this);

    if (NULL == m_hWnd)
    {
        fatal() << "Creating a window failed (CreateWindowEx). Error: " << GetLastError();
        return false;
    }

    GetWindowRect(m_hWnd, &m_rect);

    return true;
}
Пример #9
0
//-------------------------------------------------------------------------------------
bool Script::install(const wchar_t* pythonHomeDir, std::wstring pyPaths, 
	const char* moduleName, COMPONENT_TYPE componentType)
{
	std::wstring pySysPaths = SCRIPT_PATH;
	wchar_t* pwpySysResPath = strutil::char2wchar(const_cast<char*>(Resmgr::getSingleton().getPySysResPath().c_str()));
	strutil::kbe_replace(pySysPaths, L"../../res/", pwpySysResPath);
	pyPaths += pySysPaths;
	free(pwpySysResPath);

	Py_SetPythonHome(const_cast<wchar_t*>(pythonHomeDir));								// 先设置python的环境变量

#if KBE_PLATFORM != PLATFORM_WIN32
	std::wstring fs = L";";
	std::wstring rs = L":";
	size_t pos = 0; 

	while(true)
	{ 
		pos = pyPaths.find(fs, pos);
		if (pos == std::wstring::npos) break;
		pyPaths.replace(pos, fs.length(), rs);
	}  

	char* tmpchar = strutil::wchar2char(const_cast<wchar_t*>(pyPaths.c_str()));
	DEBUG_MSG(fmt::format("Script::install(): paths={}.\n", tmpchar));
	free(tmpchar);
	
#endif
	// Initialise python
	// Py_VerboseFlag = 2;
	Py_FrozenFlag = 1;

	// Warn if tab and spaces are mixed in indentation.
	// Py_TabcheckFlag = 1;
	Py_NoSiteFlag = 1;
	Py_IgnoreEnvironmentFlag = 1;

	Py_SetPath(pyPaths.c_str());

	// python解释器的初始化  
	Py_Initialize();                      											
    if (!Py_IsInitialized())
    {
    	ERROR_MSG("Script::install(): Py_Initialize is failed!\n");
        return false;
    } 

	PyObject *m = PyImport_AddModule("__main__");

	// 添加一个脚本基础模块
	module_ = PyImport_AddModule(moduleName);										
	if (module_ == NULL)
		return false;
	
	const char* componentName = COMPONENT_NAME_EX(componentType);
	if (PyModule_AddStringConstant(module_, "component", componentName))
	{
		ERROR_MSG(fmt::format("Script::install(): Unable to set KBEngine.component to {}\n",
			componentName));
		return false;
	}
	
	// 注册产生uuid方法到py
	APPEND_SCRIPT_MODULE_METHOD(module_,		genUUID64,			__py_genUUID64,					METH_VARARGS,			0);

	if(!install_py_dlls())
	{
		ERROR_MSG("Script::install(): install_py_dlls() is failed!\n");
		return false;
	}

	// 安装py重定向模块
	ScriptStdOut::installScript(NULL);												
	ScriptStdErr::installScript(NULL);	

	static struct PyModuleDef moduleDesc =   
	{  
			 PyModuleDef_HEAD_INIT,  
			 moduleName,  
			 "This module is created by KBEngine!",  
			 -1,  
			 NULL  
	};  

	// 初始化基础模块
	PyModule_Create(&moduleDesc);		

	// 将模块对象加入main
	PyObject_SetAttrString(m, moduleName, module_);									

	// 重定向python输出
	pyStdouterr_ = new ScriptStdOutErr();											
	
	// 安装py重定向脚本模块
	if(!pyStdouterr_->install()){													
		ERROR_MSG("Script::install::pyStdouterr_->install() is failed!\n");
		delete pyStdouterr_;
		SCRIPT_ERROR_CHECK();
		return false;
	}
	
	PyGC::initialize();
	Pickler::initialize();
	PyProfile::initialize(this);
	PyStruct::initialize();
	Copy::initialize();
	SCRIPT_ERROR_CHECK();

	math::installModule("Math");
	INFO_MSG(fmt::format("Script::install(): is successfully, Python=({})!\n", Py_GetVersion()));
	return installExtraModule("KBExtra");
}
Пример #10
0
extern "C" void generate_type_list(const std::wstring &input)
{

		lex_t *lex = __build_lex();
		psrGrammar_t	*gmr = __build_grammar(&__g_handler);
		const parser_t		*parser = Parser_CreateParser(gmr, PARSER_LALR);
		psrContext_t *parser_ctx = Parser_CreateContext(parser, NULL);






		ARSpace::lexMatch_t *match = ARSpace::Lex_CreateMatch(lex);
		ARSpace::Lex_ResetInput(match, input.c_str());
		
		ARSpace::Lex_MatchClearFlags(match);
		
		ARSpace::lexToken_t		token;

		memset(&token, 0, sizeof(token));
		
		arStatus_t status = AR_S_YES;

		while(status == AR_S_YES)
		{

				status = ARSpace::Lex_Match(match, &token);

				if(status == AR_S_YES)
				{
						ARSpace::psrToken_t		psr_tok;

						PARSER_TOTERMTOK(&token, &psr_tok);

						status = ARSpace::Parser_AddToken(parser_ctx, &psr_tok);
						
						if(token.value == 0)
						{
								break;
						}

				}else if(status == AR_S_NO)
				{
						size_t len = wcslen(ARSpace::Lex_GetNextInput(match));
						if(len > 20) len = 20;

						size_t line;
						ARSpace::Lex_MatchGetCoordinate(match, NULL, &line, NULL);

						
						wchar_t msg[1024];
						AR_wcsncpy(msg, ARSpace::Lex_GetNextInput(match),  (int)len);
						AR_error(AR_ERR_FATAL, L"Input Error : %ls line : %Iu", msg, line);
						AR_abort();

				}else
				{
						AR_error(AR_ERR_FATAL, L"inner error !\r\n");
						AR_abort();
				}

		}

		Parser_DestroyContext(parser_ctx);
		parser_ctx = NULL;

		Parser_DestroyParser(parser);
		parser = NULL;

		Parser_DestroyGrammar(gmr);
		gmr = NULL;

		Lex_Destroy(lex);
		lex = NULL;

		Lex_DestroyMatch(match);
		match = NULL;

}
Пример #11
0
void WindowsWindow::setTitle(const std::string & title)
{
    const std::wstring wtitle = std::wstring(title.begin(), title.end());
    SetWindowText(m_hWnd, wtitle.c_str());
}
Пример #12
0
static inline std::string utf8(const std::wstring& p)
{
    return msra::strfun::wcstombs(p.c_str());
} // output: UTF-8... not really
Пример #13
0
/*
** Gets the value of a section variable. Returns true if strValue is set.
** The selector is stripped from strVariable.
**
*/
bool ConfigParser::GetSectionVariable(std::wstring& strVariable, std::wstring& strValue)
{
	size_t colonPos = strVariable.find_last_of(L':');
	if (colonPos == std::wstring::npos)
	{
		return false;
	}

	const std::wstring selector = strVariable.substr(colonPos + 1);
	const WCHAR* selectorSz = selector.c_str();
	strVariable.resize(colonPos);

	bool isKeySelector = (!selector.empty() && iswalpha(selectorSz[0]));

	if (isKeySelector)
	{
		// [Meter:X], [Meter:Y], [Meter:W], [Meter:H]
		Meter* meter = m_Skin->GetMeter(strVariable);
		if (meter)
		{
			WCHAR buffer[32];
			if (_wcsicmp(selectorSz, L"X") == 0)
			{
				_itow_s(meter->GetX(), buffer, 10);
			}
			else if (_wcsicmp(selectorSz, L"Y") == 0)
			{
				_itow_s(meter->GetY(), buffer, 10);
			}
			else if (_wcsicmp(selectorSz, L"W") == 0)
			{
				_itow_s(meter->GetW(), buffer, 10);
			}
			else if (_wcsicmp(selectorSz, L"H") == 0)
			{
				_itow_s(meter->GetH(), buffer, 10);
			}
			else
			{
				return false;
			}

			strValue = buffer;
			return true;
		}
	}

	// Number: [Measure:], [Measure:dec]
	// Percentual: [Measure:%], [Measure:%, dec]
	// Scale: [Measure:/scale], [Measure:/scale, dec]
	// Max/Min: [Measure:MaxValue], [Measure:MaxValue:/scale, dec] ('%' cannot be used)
	// EscapeRegExp: [Measure:EscapeRegExp] (Escapes regular expression syntax, used for 'IfMatch')
	// EncodeUrl: [Measure:EncodeUrl] (Escapes URL reserved characters)
	// TimeStamp: [TimeMeasure:TimeStamp] (ONLY for Time measures, returns the Windows timestamp of the measure)
	enum class ValueType
	{
		Raw,
		Percentual,
		Max,
		Min,
		EscapeRegExp,
		EncodeUrl,
		TimeStamp
	} valueType = ValueType::Raw;

	if (isKeySelector)
	{
		if (_wcsicmp(selectorSz, L"MaxValue") == 0)
		{
			valueType = ValueType::Max;
		}
		else if (_wcsicmp(selectorSz, L"MinValue") == 0)
		{
			valueType = ValueType::Min;
		}
		else if (_wcsicmp(selectorSz, L"EscapeRegExp") == 0)
		{
			valueType = ValueType::EscapeRegExp;
		}
		else if (_wcsicmp(selectorSz, L"EncodeUrl") == 0)
		{
			valueType = ValueType::EncodeUrl;
		}
		else if (_wcsicmp(selectorSz, L"TimeStamp") == 0)
		{
			valueType = ValueType::TimeStamp;
		}
		else
		{
			return false;
		}

		selectorSz = L"";
	}
	else
	{
		colonPos = strVariable.find_last_of(L':');
		if (colonPos != std::wstring::npos)
		{
			do
			{
				const WCHAR* keySelectorSz = strVariable.c_str() + colonPos + 1;

				if (_wcsicmp(keySelectorSz, L"MaxValue") == 0)
				{
					valueType = ValueType::Max;
				}
				else if (_wcsicmp(keySelectorSz, L"MinValue") == 0)
				{
					valueType = ValueType::Min;
				}
				else
				{
					// Section name contains ':' ?
					break;
				}

				strVariable.resize(colonPos);
			}
			while (0);
		}
	}

	Measure* measure = m_Skin->GetMeasure(strVariable);
	if (measure)
	{
		if (valueType == ValueType::EscapeRegExp)
		{
			strValue = measure->GetStringValue();
			StringUtil::EscapeRegExp(strValue);
			return true;
		}
		else if (valueType == ValueType::EncodeUrl)
		{
			strValue = measure->GetStringValue();
			StringUtil::EncodeUrl(strValue);
			return true;
		}
		else if (measure->GetTypeID() == TypeID<MeasureTime>() && valueType == ValueType::TimeStamp)
		{
			MeasureTime* time = (MeasureTime*)measure;
			strValue = std::to_wstring(time->GetTimeStamp().QuadPart / 10000000);
			return true;
		}

		int scale = 1;

		const WCHAR* decimalsSz = wcschr(selectorSz, L',');
		if (decimalsSz)
		{
			++decimalsSz;
		}

		if (*selectorSz == L'%')  // Percentual
		{
			if (valueType == ValueType::Max || valueType == ValueType::Min)
			{
				// '%' cannot be used with Max/Min values.
				return false;
			}

			valueType = ValueType::Percentual;
		}
		else if (*selectorSz == L'/')  // Scale
		{
			errno = 0;
			scale = _wtoi(selectorSz + 1);
			if (errno == EINVAL || scale == 0)
			{
				// Invalid scale value.
				return false;
			}
		}
		else
		{
			if (decimalsSz)
			{
				return false;
			}

			decimalsSz = selectorSz;
		}

		const double value =
			(valueType == ValueType::Percentual) ? measure->GetRelativeValue() * 100.0 :
			(valueType == ValueType::Max)        ? measure->GetMaxValue() / scale :
			(valueType == ValueType::Min)        ? measure->GetMinValue() / scale :
			                                       measure->GetValue() / scale;
		int decimals = 10;
		if (decimalsSz)
		{
			while (iswspace(*decimalsSz)) ++decimalsSz;

			if (*decimalsSz)
			{
				decimals = _wtoi(decimalsSz);
				decimals = max(0, decimals);
				decimals = min(32, decimals);
			}
			else
			{
				decimalsSz = nullptr;
			}
		}

		WCHAR format[32];
		WCHAR buffer[128];
		_snwprintf_s(format, _TRUNCATE, L"%%.%if", decimals);
		int bufferLen = _snwprintf_s(buffer, _TRUNCATE, format, value);
			
		if (!decimalsSz)
		{
			// Remove trailing zeros if decimal count was not specified.
			measure->RemoveTrailingZero(buffer, bufferLen);
			bufferLen = (int)wcslen(buffer);
		}

		strValue.assign(buffer, bufferLen);
		return true;
	}
	
	return false;
}
Пример #14
0
/*
** Reads the given ini file and fills the m_Values and m_Keys maps.
**
*/
void ConfigParser::ReadIniFile(const std::wstring& iniFile, LPCTSTR skinSection, int depth)
{
	if (depth > 100)	// Is 100 enough to assume the include loop never ends?
	{
		GetRainmeter().ShowMessage(nullptr, GetString(ID_STR_INCLUDEINFINITELOOP), MB_OK | MB_ICONERROR);
		return;
	}

	// Verify whether the file exists
	if (_waccess(iniFile.c_str(), 0) == -1)
	{
		LogErrorF(m_Skin, L"Unable to read file: %s", iniFile.c_str());
		return;
	}

	// Avoid "IniFileMapping"
	std::wstring iniRead = System::GetTemporaryFile(iniFile);
	bool temporary = (!iniRead.empty() && (iniRead.size() != 1 || iniRead[0] != L'?'));

	if (temporary)
	{
		if (GetRainmeter().GetDebug()) LogDebugF(m_Skin, L"Reading file: %s (Temp: %s)", iniFile.c_str(), iniRead.c_str());
	}
	else
	{
		if (GetRainmeter().GetDebug()) LogDebugF(m_Skin, L"Reading file: %s", iniFile.c_str());
		iniRead = iniFile;
	}

	// Get all the sections (i.e. different meters)
	std::list<std::wstring> sections;
	std::unordered_set<std::wstring> unique;
	std::wstring key, value;  // buffer

	DWORD itemsSize = MAX_LINE_LENGTH;
	WCHAR* items = new WCHAR[itemsSize];
	WCHAR* pos = nullptr;
	WCHAR* epos = nullptr;

	if (skinSection == nullptr)
	{
		// Get all the sections
		do
		{
			items[0] = 0;
			DWORD res = GetPrivateProfileSectionNames(items, itemsSize, iniRead.c_str());
			if (res == 0)		// File not found
			{
				delete [] items;
				if (temporary) System::RemoveFile(iniRead);
				return;
			}
			if (res < itemsSize - 2)		// Fits in the buffer
			{
				epos = items + res;
				break;
			}

			delete [] items;
			itemsSize *= 2;
			items = new WCHAR[itemsSize];
		}
		while (true);

		// Read the sections
		pos = items;
		while (pos < epos)
		{
			if (*pos)
			{
				value = pos;  // section name
				StrToUpperC(key.assign(value));
				if (unique.insert(key).second)
				{
					if (m_FoundSections.insert(key).second)
					{
						m_Sections.insert(m_SectionInsertPos, value);
					}
					sections.push_back(value);
				}
				pos += value.size() + 1;
			}
			else  // Empty string
			{
				++pos;
			}
		}
	}
	else
	{
		// Special case: Read only "Rainmeter" and specified section from "Rainmeter.ini"
		const std::wstring strRainmeter = L"Rainmeter";
		const std::wstring strFolder = skinSection;

		sections.push_back(strRainmeter);
		sections.push_back(strFolder);

		if (depth == 0)  // Add once
		{
			m_Sections.push_back(strRainmeter);
			m_Sections.push_back(strFolder);
		}
	}

	// Read the keys and values
	for (auto it = sections.cbegin(); it != sections.cend(); ++it)
	{
		unique.clear();

		const WCHAR* sectionName = (*it).c_str();
		bool isVariables = (_wcsicmp(sectionName, L"Variables") == 0);
		bool isMetadata = (skinSection == nullptr && !isVariables && _wcsicmp(sectionName, L"Metadata") == 0);
		bool resetInsertPos = true;

		// Read all "key=value" from the section
		do
		{
			items[0] = 0;
			DWORD res = GetPrivateProfileSection(sectionName, items, itemsSize, iniRead.c_str());
			if (res < itemsSize - 2)		// Fits in the buffer
			{
				epos = items + res;
				break;
			}

			delete [] items;
			itemsSize *= 2;
			items = new WCHAR[itemsSize];
		}
		while (true);

		pos = items;
		while (pos < epos)
		{
			if (*pos)
			{
				size_t len = wcslen(pos);
				WCHAR* sep = wmemchr(pos, L'=', len);
				if (sep != nullptr && sep != pos)
				{
					size_t clen = sep - pos;  // key's length

					StrToUpperC(key.assign(pos, clen));
					if (unique.insert(key).second)
					{
						++sep;
						clen = len - (clen + 1);  // value's length

						// Trim surrounded quotes from value
						if (clen >= 2 && (sep[0] == L'"' || sep[0] == L'\'') && sep[clen - 1] == sep[0])
						{
							clen -= 2;
							++sep;
						}

						if (wcsncmp(key.c_str(), L"@INCLUDE", 8) == 0)
						{
							if (clen > 0)
							{
								value.assign(sep, clen);
								ReadVariables();
								ReplaceVariables(value);
								if (!PathUtil::IsAbsolute(value))
								{
									// Relative to the ini folder
									value.insert(0, PathUtil::GetFolderFromFilePath(iniFile));
								}

								if (resetInsertPos)
								{
									auto jt = it;
									if (++jt == sections.end())  // Special case: @include was used in the last section of the current file
									{
										// Set the insertion place to the last
										m_SectionInsertPos = m_Sections.end();
										resetInsertPos = false;
									}
									else
									{
										// Find the appropriate insertion place
										for (jt = m_Sections.cbegin(); jt != m_Sections.cend(); ++jt)
										{
											if (_wcsicmp((*jt).c_str(), sectionName) == 0)
											{
												m_SectionInsertPos = ++jt;
												resetInsertPos = false;
												break;
											}
										}
									}
								}

								ReadIniFile(value, skinSection, depth + 1);
							}
						}
						else
						{
							if (!isMetadata)  // Uncache Metadata's key-value pair in the skin
							{
								value.assign(sep, clen);
								SetValue((*it), key, value);

								if (isVariables)
								{
									m_ListVariables.push_back(key);
								}
							}
						}
					}
				}
				pos += len + 1;
			}
			else  // Empty string
			{
				++pos;
			}
		}
	}

	delete [] items;
	if (temporary) System::RemoveFile(iniRead);
}
Пример #15
0
bool RTMPMP4Stream::Play(std::wstring& url)
{
	char filename[1024];

	//Print it
	snprintf(filename,1024,"%ls",url.c_str());

	//Open it and play
	if (!streamer.Open(filename))
	{
		//Send error comand
		SendCommand(L"onStatus", new RTMPNetStatusEvent(L"NetStream.Play.StreamNotFound",L"error",L"Stream not found"));
		//Error
		return Error("Error opening mp4 file [path:\"%ls\"",filename);
	}
	
	//Send play comand
	SendCommand(L"onStatus", new RTMPNetStatusEvent(L"NetStream.Play.Reset",L"status",L"Playback reset") );

	//Send play comand
	SendCommand(L"onStatus", new RTMPNetStatusEvent(L"NetStream.Play.Start",L"status",L"Playback started") );

	//Create metadata object
	RTMPMetaData *meta = new RTMPMetaData(0);

	//Set name
	meta->AddParam(new AMFString(L"onMetaData"));

	//Create properties string
	AMFEcmaArray *prop = new AMFEcmaArray();

	//Add default properties
	if (streamer.HasAudioTrack())
	{
		switch (streamer.GetAudioCodec())
		{
			case AudioCodec::PCMU:
				//Set properties
				prop->AddProperty(L"audiocodecid"	,(float)RTMPAudioFrame::SPEEX	);	//Number Audio codec ID used in the file (see E.4.2.1 for available SoundFormat values)
				prop->AddProperty(L"audiodatarate"	,(float)16000			);	// Number Audio bit rate in kilobits per second
				//Set decoder
				decoder = new PCMUCodec();
				//Set encode
				encoder = new SpeexCodec();
				break;
			case AudioCodec::PCMA:
				prop->AddProperty(L"audiocodecid"	,(float)RTMPAudioFrame::SPEEX	);	//Number Audio codec ID used in the file (see E.4.2.1 for available SoundFormat values)
				prop->AddProperty(L"audiodatarate"	,(float)16000			);	// Number Audio bit rate in kilobits per second
				//Set decoder
				decoder = new PCMACodec();
				//Set encode
				encoder = new SpeexCodec();
				break;
		}
		//prop->AddProperty(L"stereo"		,new AMFBoolean(false)	);	// Boolean Indicating stereo audio
		prop->AddProperty(L"audiodelay"		,0.0	);	// Number Delay introduced by the audio codec in seconds
		prop->AddProperty(L"audiosamplerate"	,8000.0	);	// Number Frequency at which the audio stream is replayed
		prop->AddProperty(L"audiosamplesize"	,160.0	);	// Number Resolution of a single audio sample
	}

	//If ti has video track
	if (streamer.HasVideoTrack())
	{
		switch (streamer.GetVideoCodec())
		{
			case VideoCodec::H263_1996:
			case VideoCodec::H263_1998:
				prop->AddProperty(L"videocodecid"	,(float)RTMPVideoFrame::FLV1	);	// Number Video codec ID used in the file (see E.4.3.1 for available CodecID values)
				break;
			case VideoCodec::H264:
				prop->AddProperty(L"videocodecid"	,new AMFString(L"avc1")		);	// Number Video codec ID used in the file (see E.4.3.1 for available CodecID values)
				break;
		}

		prop->AddProperty(L"framerate"		,(float)streamer.GetVideoFramerate()	);	// Number Number of frames per second
		prop->AddProperty(L"height"		,(float)streamer.GetVideoHeight()	);	// Number Height of the video in pixels
		prop->AddProperty(L"videodatarate"	,(float)streamer.GetVideoBitrate()/1024	);	// Number Video bit rate in kilobits per second
		prop->AddProperty(L"width"		,(float)streamer.GetVideoWidth()	);	// Number Width of the video in pixels
	}

	prop->AddProperty(L"canSeekToEnd"	,0.0	);			// Boolean Indicating the last video frame is a key frame
	prop->AddProperty(L"duration"		,(float)streamer.GetDuration());	// Number Total duration of the file in seconds

	//Add param
	meta->AddParam(prop);

	//Send metadata
	PlayMetaData(meta);

	//Get AVC descriptor if any
	desc = streamer.GetAVCDescriptor();

	//If we have one
	if (desc)
	{
		//Create the frame
		RTMPVideoFrame fdesc(0,desc);
		//Play it
		PlayMediaFrame(&fdesc);
	}

	//Play it
	if (!streamer.Play())
	{
		//Close it
		streamer.Close();
		//Send error comand
		SendCommand(L"onStatus", new RTMPNetStatusEvent(L"NetStream.Play.Error",L"error",L"Error openeing stream"));
		//Error
		return Error("Error starting playback of mp4 file [path:\"%ls\"",url.c_str());
	}
	
	return true;
}
Пример #16
0
	bool FileSystem::isExist(const std::wstring& path)
	{
		return waccess(path.c_str(), FILE_READ_FLAG);
	}
Пример #17
0
/*
** Handles the OpenPlayer bang.
**
*/
void PlayerITunes::OpenPlayer(std::wstring& path)
{
	ShellExecute(nullptr, L"open", path.empty() ? L"iTunes.exe" : path.c_str(), nullptr, nullptr, SW_SHOW);
}
Пример #18
0
void Log::print(const std::wstring& str) const
{
	const wchar_t* p=str.c_str();
	this->print(L"%ls",p);
}
Пример #19
0
HINTERNET Fetcher::openUrl(const std::wstring& uri) const
{
    DEBUG("Calling InternetOpenUrl: " << wchars_to_utf8chars(uri.c_str()));
    return check("InternetOpenUrl",
                 InternetOpenUrl(mInet, uri.c_str(), NULL, 0, INTERNET_FLAG_NEED_FILE, NULL));
}
Пример #20
0
 void dc::draw_text(const std::wstring & text, const ak::point<int> & pt)
 {
     RECT rt;
     SetRect(&rt, pt.x, pt.y, pt.x, pt.y);
     ::DrawTextW((HDC)_dc, text.c_str(), (int)text.size(), &rt, DT_LEFT | DT_TOP | DT_NOCLIP);
 }
Пример #21
0
		bool SignFile(const std::wstring& path, std::vector<std::wstring> timestampUrls)
		{
			if (!signerSignEx || !signerFreeSignerContext || !signerTimestampEx)
				return false;

			HANDLE file = CreateFile(path.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

			if (file == INVALID_HANDLE_VALUE)
			{
				std::wcerr << L"Failed to open file. Error: " << std::hex << GetLastError() << ", File: " << path << std::endl;
				return false;
			}

			std::shared_ptr<int> doomOfFile(nullptr, [file](void*) { CloseHandle(file); });

			SIGNER_FILE_INFO signerFileInfo;
			signerFileInfo.cbSize = sizeof(SIGNER_FILE_INFO);
			signerFileInfo.pwszFileName = path.c_str();
			signerFileInfo.hFile = file;

			SIGNER_SUBJECT_INFO signerSubjectInfo;
			signerSubjectInfo.cbSize = sizeof(SIGNER_SUBJECT_INFO);
			DWORD index = 0;
			signerSubjectInfo.pdwIndex = &index;
			signerSubjectInfo.dwSubjectChoice = 1; // SIGNER_SUBJECT_FILE
			signerSubjectInfo.pSignerFileInfo = &signerFileInfo;

			SIGNER_CERT_STORE_INFO signerCertStoreInfo;
			signerCertStoreInfo.cbSize = sizeof(SIGNER_CERT_STORE_INFO);
			signerCertStoreInfo.pSigningCert = certContext;
			signerCertStoreInfo.dwCertPolicy = 2; // SIGNER_CERT_POLICY_CHAIN
			signerCertStoreInfo.hCertStore = NULL;

			SIGNER_CERT signerCert;
			signerCert.cbSize = sizeof(SIGNER_CERT);
			signerCert.dwCertChoice = 2; // SIGNER_CERT_STORE
			signerCert.pCertStoreInfo = &signerCertStoreInfo;
			signerCert.hwnd = NULL;

			SIGNER_SIGNATURE_INFO signerSignatureInfo;
			signerSignatureInfo.cbSize = sizeof(SIGNER_SIGNATURE_INFO);
			signerSignatureInfo.algidHash = CALG_SHA_256;
			signerSignatureInfo.dwAttrChoice = 0; // SIGNER_NO_ATTR
			signerSignatureInfo.pAttrAuthcode = NULL;
			signerSignatureInfo.psAuthenticated = NULL;
			signerSignatureInfo.psUnauthenticated = NULL;

			HRESULT res = signerSignEx(0, &signerSubjectInfo, &signerCert, &signerSignatureInfo, NULL, NULL, NULL, NULL, NULL);

			if (res != S_OK)
			{
				std::wcerr << L"Failed to sign file. Error: " << res << ", File: " << path << std::endl;
				return false;
			}
			else
				std::wcerr << L"Signed: " << path << std::endl;

			for (auto it = timestampUrls.begin(); it != timestampUrls.end(); ++it)
			{
				res = signerTimestampEx(0, &signerSubjectInfo, it->c_str(), NULL, NULL, NULL);
				if (res == S_OK)
				{
					std::wcerr << L"Timestamped: " << path << std::endl;
					break;
				}
				else
					std::wcerr << L"Failed to timestamp file. Error: " << res << ", Url: " << *it << std::endl;
			}

			return res == S_OK;
		}
Пример #22
0
 void dc::draw_text(const std::wstring & text, const ak::rectangle<int> & rect)
 {
     RECT rt;
     SetRect(&rt, 0, 0, rect.right() - rect.left(), rect.bottom() - rect.top());
     ::DrawTextW((HDC)_dc, text.c_str(), (int)text.size(), &rt, DT_LEFT | DT_TOP | DT_WORDBREAK);
 }
bool FreeTypeTextPrinter::PutText(cv::Mat& img, const std::wstring& string, cv::Point begin_point, cv::Point& end_point)
{
	for (size_t i = 0; i != string.size(); ++i)
	{
		if (!this->Select_Char(string.c_str()[i]))
		{
			end_point = begin_point;
			return false;
		}

		std::pair<cv::Mat, cv::Mat> char_p;
		signed int left, top;

		std::tie(char_p.first, char_p.second, top, left) = this->GetCharMat();

		auto rect = cv::Rect(
			begin_point.x,
			begin_point.y - top,
			char_p.first.size().width,
			char_p.first.size().height
		);

		if (
			0 < rect.x &&
			0 < rect.y &&
			rect.br().x < img.cols &&
			rect.br().y < img.rows
			)
		{
			auto roi = img(rect);
			bitwise_and(roi, char_p.second, roi);
			bitwise_or(roi, char_p.first, roi);
		}
		else
		{
			// 裁剪算法

			auto p1 = rect.tl();
			auto p2 = rect.br();
			cv::Point p0{ 0,0 };

			int width = rect.width;
			int height = rect.height;

			// 角点区内移动
			if (p2.x > img.cols)
			{
				width -= p2.x - img.cols;
				p2.x = img.cols;
			}
			if (p2.y > img.rows)
			{
				height -= p2.y - img.rows;
				p2.y = img.rows;
			}
			if (p1.x < 0)
			{
				width += p1.x;
				p0.x -= p1.x;
				p1.x = 0;
			}
			if (p1.y < 0)
			{
				height += p1.y;
				p0.y -= p1.y;
				p1.y = 0;
			}

			// 实际出区检查
			if (width > 0 && height > 0)
			{

				// 新的放置区
				rect = cv::Rect{ p1, p2 };
				auto rect_i = cv::Rect{ p0,rect.size() };

				// 拷贝

				auto roi = img(rect);
				bitwise_and(roi, char_p.second(rect_i), roi);
				bitwise_or(roi, char_p.first(rect_i), roi);
			}

		}
		// 不进行自动换行

		// 下一个字  此处字符间距从A中计算得来
		begin_point.x += char_p.first.size().width + character_spacing_empty_width_;
	}
	end_point = begin_point;
	return true;
}
Пример #24
0
bool StringUtil::MatchByFirstLetter(const std::wstring& src, const std::wstring& dst)
{
	return std::search(src.c_str(), src.c_str() + src.size(), dst.c_str(), dst.c_str() + dst.size(), MatchCharByPinyin) != src.c_str() + src.size();
}
Пример #25
0
// private
adcontrols::translate_state
rawdata::fetchSpectrum( int64_t objid
                        , const std::wstring& dataInterpreterClsid
                        , uint64_t npos, adcontrols::MassSpectrum& ms
						, const std::wstring& traceId ) const
{
    if ( auto interpreter = adcontrols::DataInterpreterBroker::make_datainterpreter( adportable::utf::to_utf8( dataInterpreterClsid ) ) ) {

        //auto interpreter = spectrometer->getDataInterpreter();
        auto spectrometer = adcontrols::MassSpectrometerBroker::make_massspectrometer( adportable::utf::to_utf8( dataInterpreterClsid ) );

        adfs::stmt sql( dbf_.db() );

        if ( sql.prepare( "SELECT fcn, data, meta FROM AcquiredData WHERE oid = :oid AND npos = :npos" ) ) {

            sql.bind( 1 ) = objid;
            sql.bind( 2 ) = npos;

            if ( sql.step() == adfs::sqlite_row ) {
                int fcn = int( sql.get_column_value< int64_t >( 0 ) );
                (void)fcn;
                adfs::blob xdata = sql.get_column_value< adfs::blob >( 1 );
                adfs::blob xmeta = sql.get_column_value< adfs::blob >( 2 );

                size_t idData = 0;
                return interpreter->translate( ms, reinterpret_cast< const char *>(xdata.data()), xdata.size()
                                              , reinterpret_cast<const char *>(xmeta.data()), xmeta.size(), *spectrometer, idData++, traceId.c_str() );

            }
        }
        return adcontrols::no_more_data;
    }
    return adcontrols::no_interpreter;
}
Пример #26
0
void ColoredCubeApp::drawScene()
{
	D3DApp::drawScene();

	// Restore default states, input layout and primitive topology 
	// because mFont->DrawText changes them.  Note that we can 
	// restore the default states by passing null.
	md3dDevice->OMSetDepthStencilState(0, 0);
	float blendFactors[] = {0.0f, 0.0f, 0.0f, 0.0f};
	md3dDevice->OMSetBlendState(0, blendFactors, 0xffffffff);
    md3dDevice->IASetInputLayout(mVertexLayout);

	mfxEyePosVar->SetRawValue(&player.getPosition(), 0, sizeof(D3DXVECTOR3));

	//set the number of lights to use
	mfxNumLights->SetInt(numLights);

	// set the light array
	lights[0] = flashLightObject.lightSource;
	//lights[2] = lightObject1.getLight();
	if(gamestate == level2)
	{
		for(int i = 0; i < ghosts.getNumEnemies(); i++)
		{
			lights[2+i] = ghosts.getEnemies()[i].getLight();
		}
	}
	for(int i = 0; i < numLightObjects; i++)
	{
		lights[2+ghosts.getNumEnemies()+i] = lamps[i].getLight();
	}
	lights[numLights-1] = endLight;

	mfxLightVar->SetRawValue(&lights[0], 0, numLights*sizeof(Light));
 
	// Don't transform texture coordinates, so just use identity transformation.
	D3DXMATRIX texMtx;
	D3DXMatrixIdentity(&texMtx);
	mfxTexMtxVar->SetMatrix((float*)&texMtx);

	// set the point to the shader technique
	D3D10_TECHNIQUE_DESC techDesc;
	mTech->GetDesc(&techDesc);

	//draw the maze
	maze.draw(mTech,mView,mProj);
	
	//draw the keys
	if(gamestate == level1)
	{
		for(int i = 0; i < totalKeys; i++)
		{
			keyObject[i].draw(mView,mProj,mTech);
		}
	}

	//draw the end cube
	endCube.draw(mView,mProj,mTech);

	//draw the origin
	origin.draw(mView, mProj, mTech);
	
	for(int i = 0; i < numLightObjects; i++)
	{
		lamps[i].draw(mView,mProj,mTech);
	}

	for(int i = 0; i < numBatteries; i++)
	{
		batteries[i].draw(mView,mProj,mTechColor2);
	}

	//flashLightObject.draw(mView,mProj,mTechColor2);
	//flashLightObject.hitBox.draw(mView,mProj,mTechColor2);
	
	//batteryObject.draw(mView,mProj,mTechColor2);
	//player.draw(mView,mProj,mTechColor2);
	ghosts.draw(mView,mProj,mTech);

	/*floor.draw(mView, mProj, mTech);
	wall1.draw(mView, mProj, mTech);
	wall2.draw(mView, mProj, mTech);
	wall3.draw(mView, mProj, mTech);
	wall4.draw(mView, mProj, mTech);*/
	//lightObject1.draw(mView,mProj,mTech);

	// We specify DT_NOCLIP, so we do not care about width/height of the rect.
	RECT R = {5, 5, 0, 0};
	mFont->DrawText(0, mTimer.c_str(), -1, &R, DT_NOCLIP, BLUE);
	mSwapChain->Present(0, 0);
}
Пример #27
0
void Window::Retitle(const std::wstring &title)
{
	SetWindowText(title.c_str());
}
Пример #28
0
	size_t ExecuteProcess(std::wstring FullPathToExe, std::wstring Parameters,
                                 size_t SecondsToWait)
	{
		 size_t iMyCounter = 0, iReturnVal = 0, iPos = 0;
		 DWORD dwExitCode = 0;
		 std::wstring sTempStr = L"";
		 
		 /* Add a space to the beginning of the Parameters */
		 if (Parameters.size() != 0)
		 { 
			  if (Parameters[0] != L' ')
			  {
				   Parameters.insert(0,L" ");
			  }
		 }

		 /* The first parameter needs to be the exe itself */
		 sTempStr = FullPathToExe;
		 iPos = sTempStr.find_last_of(L"\\");
		 sTempStr.erase(0, iPos +1);
		 Parameters = sTempStr.append(Parameters);

		 /*
			  CreateProcessW can modify Parameters thus we
			  allocate needed memory
		 */
		 wchar_t * pwszParam = new wchar_t[Parameters.size() + 1];
		 if (pwszParam == 0)
		 {
			  return 1;
		 } 
		 const wchar_t* pchrTemp = Parameters.c_str();
		 wcscpy_s(pwszParam, Parameters.size() + 1, pchrTemp);

		 /* CreateProcess API initialization */
		 STARTUPINFOW siStartupInfo;
		 PROCESS_INFORMATION piProcessInfo;
		 memset(&siStartupInfo, 0, sizeof(siStartupInfo));
		 memset(&piProcessInfo, 0, sizeof(piProcessInfo));
		 siStartupInfo.cb = sizeof(siStartupInfo);

		 int result = CreateProcess(const_cast<LPCWSTR>(FullPathToExe.c_str()),
									  pwszParam, 0, 0, false,
									  CREATE_DEFAULT_ERROR_MODE, 0, 0,
									  &siStartupInfo, &piProcessInfo);
		 if (result !=0)
		 {
			  /* Watch the process. */
			  dwExitCode = WaitForSingleObject(piProcessInfo.hProcess,(SecondsToWait * 1000));
			  dwProcessId = piProcessInfo.dwProcessId;
		 }
		 else
		 {
			  /* CreateProcess failed */
			  iReturnVal = GetLastError();
		 }

		 /* Free memory */
		 delete[]pwszParam;
		 pwszParam = 0;

		 /* Release handles */
		 CloseHandle(piProcessInfo.hProcess);
		 CloseHandle(piProcessInfo.hThread);

		 return iReturnVal;
	}	
Пример #29
0
library_loader::library_loader(const std::wstring& name)
    : h{LoadLibrary(name.c_str()), FreeLibrary} {
}
Пример #30
0
void Message::SetPriority(const std::wstring& priority)
{
    if(priority.empty())
    {
        LOG_WS_ERROR(L"Failed to set the 'Priority' of a notes message - value empty");
        return;
    }

	STATUS status = NSFItemSetText(m_noteHandle, MAIL_IMPORTANCE_ITEM, Workshare::Conversions::W22LMBCS(priority.c_str()).c_str(), (WORD)priority.size());
	if(LNNOERROR != status)
		LOG_WS_ERROR(L"Failed to set the 'Priority' of a notes message");
}