void* CResourceCompilerHelper::CallEditor( void* pParent, const TCHAR * pWndName, const TCHAR * pFlag )
{
	HWND hWnd = ::FindWindow(NULL, pWndName);
	if(hWnd)
		return hWnd;
	else
	{
		tstring editorExecutable = GetEditorExecutable();

		if (editorExecutable!=_T(""))		
		{
			INT_PTR hIns = (INT_PTR)ShellExecute(NULL, _T("open"), editorExecutable.c_str(), pFlag, NULL, SW_SHOWNORMAL);
			if(hIns<=32)
			{
				MessageBox(0,_T("Editor.exe was not found.\n\nPlease verify CryENGINE root path."),_T("Error"),MB_ICONERROR|MB_OK);
				ResourceCompilerUI(pParent);
				editorExecutable = GetEditorExecutable();
				ShellExecute(NULL, _T("open"), editorExecutable.c_str(), pFlag, NULL, SW_SHOWNORMAL);
			}
		}
	}
	return 0;
}
bool CResourceCompilerHelper::CallEditor(void** pEditorWindow, void* hParent, const char* pWindowName, const char* pFlag)
{
	HWND window = ::FindWindowA(NULL, pWindowName);
	if (window)
	{
		*pEditorWindow = window;
		return true;
	}
	else
	{
		*pEditorWindow = 0;

		wchar_t buffer[512] = { L'\0' };
		GetEditorExecutable(SettingsManagerHelpers::CWCharBuffer(buffer, sizeof(buffer)));

		SettingsManagerHelpers::CFixedString<wchar_t, 256> wFlags;
		SettingsManagerHelpers::ConvertUtf8ToUtf16(pFlag, wFlags.getBuffer());
		wFlags.setLength(wcslen(wFlags.c_str()));

		if (buffer[0] != '\0')		
		{
			INT_PTR hIns = (INT_PTR)ShellExecuteW(NULL, L"open", buffer, wFlags.c_str(), NULL, SW_SHOWNORMAL);
			if(hIns > 32)
			{
				return true;
			}
			else
			{
				MessageBoxA(0,"Editor.exe was not found.\n\nPlease verify CryENGINE root path.","Error",MB_ICONERROR|MB_OK);
				ResourceCompilerUI(hParent);
				GetEditorExecutable(SettingsManagerHelpers::CWCharBuffer(buffer, sizeof(buffer)));
				ShellExecuteW(NULL, L"open", buffer, wFlags.c_str(), NULL, SW_SHOWNORMAL);
			}
		}
	}
	return false;
}