Ejemplo n.º 1
0
int APIENTRY WinMain(HINSTANCE p_instance,HINSTANCE p_prev_instance,LPSTR p_cmd_line,int p_show)
	{
	//In win32 the p_prev_instance is ignored
    NOP(p_prev_instance,p_cmd_line,p_show);

    if( SUCCEEDED(App.Create( p_instance) ))
	{		
        return App.Run();
	}
    return 0;
	}
Ejemplo n.º 2
0
INT CXBMC_PC::Run()
{
  g_application.Create(NULL);
  g_application.Run();
  return 0;
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
// Name: WinMain()
// Desc: The application's entry point
//-----------------------------------------------------------------------------
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR commandLine, INT )
{
#ifdef WIN32_MEMORY_LEAK_DETECT
	// Turn on the heap checking
    _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF       |
					_CRTDBG_DELAY_FREE_MEM_DF	|
                     _CRTDBG_LEAK_CHECK_DF       ) ;
	// Not adding the _CRTDBG_CHECK_ALWAYS_DF flag either - since it makes Boxee run VERY slow.

#endif

#ifdef USE_MINI_DUMPS
  g_MiniDumps.Install();
#endif

  CStdStringW strcl(commandLine);
  if (strcl.Find(L"-usf") >= 0)
  {        
    CUpdateSourceFile UpdateSourceFile;
    bool success = UpdateSourceFile.UpdateProfilesSourceFile();
    
    if(success)
    {
      printf("main - Successfully updated the profiles source files\n");
    }
    else
    {
      printf("main - Failed to update profiles source files\n");
    }

    success = UpdateSourceFile.UpgradeSettings();

    if(success)
    {
      printf("main - Successfully updated GUI Settings\n");
    }
    else
    {
      printf("main - Failed to update GUI Settings\n");
    }
    
    exit(0);
  }

  // Initializes CreateMiniDump to handle exceptions.
  SetUnhandledExceptionFilter( CreateMiniDump );

  // check if Boxee is already running
  bool AlreadyRunning;
  HANDLE hMutexOneInstance = ::CreateMutex( NULL, FALSE,
    _T("BOXEE-4B71588F-DDBB-40da-AD86-3187B70AA5A3"));

  AlreadyRunning = ( ::GetLastError() == ERROR_ALREADY_EXISTS || 
    ::GetLastError() == ERROR_ACCESS_DENIED);
  // The call fails with ERROR_ACCESS_DENIED if the Mutex was 
  // created in a different users session because of passing
  // NULL for the SECURITY_ATTRIBUTES on Mutex creation);
#ifndef _DEBUG
  if ( AlreadyRunning )
  {
    HWND m_hwnd = FindWindow("Boxee","Boxee");
    if(m_hwnd != NULL)
    {
      // switch to the running instance
      ShowWindow(m_hwnd,SW_RESTORE);
      SetForegroundWindow(m_hwnd);
    }
   
    return 0;
  }
#endif

  if(CWIN32Util::GetDesktopColorDepth() < 32)
  {
    //FIXME: replace it by a SDL window for all ports
    MessageBox(NULL, "Desktop Color Depth isn't 32Bit", "BOXEE: Fatal Error", MB_OK|MB_ICONERROR);
    return 0;
  }

  // parse the command line
  LPWSTR *szArglist;
  int nArgs;

  g_advancedSettings.m_startFullScreen = false;
  szArglist = CommandLineToArgvW(strcl.c_str(), &nArgs);
  if(szArglist != NULL)
  {
    for(int i=0;i<nArgs;i++)
    {
      CStdStringW strArgW(szArglist[i]);
      if(strArgW.Equals(L"-fs"))
        g_advancedSettings.m_startFullScreen = true;
      else if(strArgW.Equals(L"-p") || strArgW.Equals(L"--portable"))
        g_application.EnablePlatformDirectories(false);
      else if(strArgW.Equals(L"-d"))
      {
        if(++i < nArgs)
        {
          int iSleep = _wtoi(szArglist[i]);
          if(iSleep > 0 && iSleep < 360)
            Sleep(iSleep*1000);
          else
            --i;
}
      }
      // this flag indicate boxee was started from the registry on user login
      // We create a delay to make sure initialization succeed.
      else if (strArgW.Equals(L"-startup"))
      {
        Sleep(5000);
    }
    }
    LocalFree(szArglist);
  }

// we don't want to see the "no disc in drive" windows message box
  SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);

  // Create and run the app
  if (!SUCCEEDED(g_application.Create(NULL)))
  {
    return 1;
  }  

  g_application.Run();

  char *a = new char[50];
  return 0;
}
Ejemplo n.º 4
0
int main(int argc, const char* argv[])
{
	CApplication app;
	return app.Run();
}
Ejemplo n.º 5
0
int main()
{
	CApplication Application;
	Application.Run();
	return 0;
}
Ejemplo n.º 6
0
int SDL_MAIN_FUNC(int argc, char *argv[])
{
    CLogger logger; // single istance of logger

    // Workaround for character encoding in argv on Windows
    #if PLATFORM_WINDOWS
    int wargc;
    wchar_t** wargv = CommandLineToArgvW(GetCommandLineW(), &wargc);
    if(wargv == nullptr)
    {
        logger.Error("CommandLineToArgvW failed\n");
        return 1;
    }
    argv = new char*[wargc];
    for(int i = 0; i < wargc; i++) {
        std::wstring warg = wargv[i];
        std::string arg = CSystemUtilsWindows::UTF8_Encode(warg);
        argv[i] = new char[arg.length()+1];
        strcpy(argv[i], arg.c_str());
    }
    LocalFree(wargv);
    #endif

    CResourceManager manager(argv[0]);

    // Initialize static string arrays
    InitializeRestext();
    InitializeEventTypeTexts();

    logger.Info("%s starting\n", COLOBOT_FULLNAME);
    
    int code = 0;
    while(true) {
        CSystemUtils* systemUtils = CSystemUtils::Create(); // platform-specific utils
        systemUtils->Init();
        
        CApplication* app = new CApplication(); // single instance of the application

        ParseArgsStatus status = app->ParseArguments(argc, argv);
        if (status == PARSE_ARGS_FAIL)
        {
            systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", "Invalid commandline arguments!\n");
            return app->GetExitCode();
        }
        else if (status == PARSE_ARGS_HELP)
        {
            return app->GetExitCode();
        }


        if (! app->Create())
        {
            app->Destroy(); // ensure a clean exit
            code = app->GetExitCode();
            if ( code != 0 && !app->GetErrorMessage().empty() )
            {
                systemUtils->SystemDialog(SDT_ERROR, "COLOBOT - Fatal Error", app->GetErrorMessage());
            }
            logger.Info("Didn't run main loop. Exiting with code %d\n", code);
            return code;
        }

        code = app->Run();
        bool restarting = app->IsRestarting();

        delete app;
        delete systemUtils;
        if(!restarting) break;
    }

    logger.Info("Exiting with code %d\n", code);

    #if PLATFORM_WINDOWS
    // See the workaround above
    delete[] argv;
    #endif

    return code;
}