Exemplo n.º 1
0
int main(int argc, char *argv[]) {
    int result = 1;
    setlocale(LC_ALL, "en_US.utf8");
    void* library = NULL;
    
    {
        std::string programPath = GetProgramPath();
        std::string libraryName = dirname((char*)programPath.c_str());
        libraryName += "/libpackager.so";
        library = dlopen(libraryName.c_str(), RTLD_LAZY);
        
        if (library == NULL) {
            printf("%s not found.\n", libraryName.c_str());
        }
    }
    
    if (library != NULL) {
        start_launcher start = (start_launcher)dlsym(library, "start_launcher");
        stop_launcher stop = (stop_launcher)dlsym(library, "stop_launcher");
        
        if (start(argc, argv) == true) {
            result = 0;
            
            if (stop != NULL) {
                stop();
            }
        }
        
        dlclose(library);
    }
    
    
    return result;
}
Exemplo n.º 2
0
bool CFileAssoc::RegisterApp()
{
    bool success = false;

    if (!m_pAAR) {
        m_pAAR = CFileAssoc::CreateRegistrationManager();
    }

    if (m_pAAR) {
        CString appIcon = "\"" + GetProgramPath(true) + "\",0";

        // Register MPC for the windows "Default application" manager
        CRegKey key;

        if (ERROR_SUCCESS == key.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\RegisteredApplications"))) {
            key.SetStringValue(_T("Media Player Classic"), strRegisteredAppKey);

            if (ERROR_SUCCESS == key.Create(HKEY_LOCAL_MACHINE, strRegisteredAppKey)) {
                // ==>>  TODO icon !!!
                key.SetStringValue(_T("ApplicationDescription"), ResStr(IDS_APP_DESCRIPTION), REG_EXPAND_SZ);
                key.SetStringValue(_T("ApplicationIcon"), appIcon, REG_EXPAND_SZ);
                key.SetStringValue(_T("ApplicationName"), ResStr(IDR_MAINFRAME), REG_EXPAND_SZ);

                success = true;
            }
        }
    }

    return success;
}
Exemplo n.º 3
0
  void Load(mitk::ModuleContext* context)
  {
    // Handle messages from CppMicroServices
    mitk::installMsgHandler(HandleMicroServicesMessages);

    // Add the current application directory to the auto-load paths.
    // This is useful for third-party executables.
    std::string programPath = GetProgramPath();
    if (programPath.empty())
    {
      MITK_WARN << "Could not get the program path.";
    }
    else
    {
      AddMitkAutoLoadPaths(programPath);
    }

    //m_RenderingManager = mitk::RenderingManager::New();
    //context->RegisterService<mitk::RenderingManager>(renderingManager.GetPointer());
    m_PlanePositionManager = mitk::PlanePositionManagerService::New();
    context->RegisterService<mitk::PlanePositionManagerService>(m_PlanePositionManager);

    m_CoreDataNodeReader = mitk::CoreDataNodeReader::New();
    context->RegisterService<mitk::IDataNodeReader>(m_CoreDataNodeReader);
  }
Exemplo n.º 4
0
Arquivo: path.c Projeto: cexer/wke
LPWSTR FixupHtmlFilePath(LPWSTR path)
{
    WCHAR fullPath[MAX_PATH + 1] = { 0 };
    LPWSTR fullUrl = NULL;
    
    do
    {
        if (path)
        {
            GetWorkingPath(fullPath, MAX_PATH, path);
            if (PathFileExistsW(fullPath))
                break;

            GetProgramPath(fullPath, MAX_PATH, path);
            if (PathFileExistsW(fullPath))
                break;   
        }

        GetWorkingPath(fullPath, MAX_PATH, L"main.html");
        if (PathFileExistsW(fullPath))
            break;

        GetWorkingPath(fullPath, MAX_PATH, L"wkexe.html");
        if (PathFileExistsW(fullPath))
            break;    

        GetProgramPath(fullPath, MAX_PATH, L"index.html");
        if (PathFileExistsW(fullPath))
            break;    

        GetProgramPath(fullPath, MAX_PATH, L"main.html");
        if (PathFileExistsW(fullPath))
            break;

        GetProgramPath(fullPath, MAX_PATH, L"wkexe.html");
        if (PathFileExistsW(fullPath))
            break;

        return path;
    }
    while (0);

    fullUrl = (WCHAR*)malloc(sizeof(WCHAR) * (MAX_PATH + 1 + 10));
    _snwprintf(fullUrl, MAX_PATH + 1 + 10, L"file:///%s", fullPath);
    return fullUrl;
}
Exemplo n.º 5
0
void CPPageMisc::OnResetSettings()
{
    if (MessageBox(ResStr(IDS_RESET_SETTINGS_WARNING), ResStr(IDS_RESET_SETTINGS), MB_ICONEXCLAMATION | MB_YESNO | MB_DEFBUTTON2) == IDYES) {
        ((CMainFrame*)AfxGetMyApp()->GetMainWnd())->SendMessage(WM_CLOSE);

        ShellExecute(nullptr, _T("open"), GetProgramPath(true), _T("/reset"), nullptr, SW_SHOWNORMAL);
    }
}
Exemplo n.º 6
0
void ProjectManager::SaveLastDir(const char *szLastDir)
{
	if (!szLastDir)
	{
		return;
	}
	SaveAttributeToInfoFile(GetProgramPath(), "directories", "lastProject", szLastDir);
}
Exemplo n.º 7
0
Arquivo: path.c Projeto: cexer/wke
LPCWSTR FormatProgramPath(LPWSTR buffer, size_t bufferSize, LPCWSTR fmt, ...)
{
    WCHAR relatedPath[MAX_PATH + 1] = { 0 };
    va_list args;
    va_start(args, fmt);
    _vsnwprintf(relatedPath, MAX_PATH, fmt, args);
    va_end(args);

    return GetProgramPath(buffer, bufferSize, relatedPath);
}
Exemplo n.º 8
0
CString CPPageWebServer::GetCurWebRoot()
{
    CString WebRoot;
    GetDlgItem(IDC_EDIT2)->GetWindowText(WebRoot);
    WebRoot.Replace('/', '\\');

    CPath path;
    path.Combine(GetProgramPath(), WebRoot);
    return path.IsDirectory() ? (LPCTSTR)path : _T("");
}
Exemplo n.º 9
0
CFileAssoc::CFileAssoc()
    : m_iconLibPath(GetProgramPath() + _T("mpciconlib.dll"))
    , m_strRegisteredAppName(_T("Media Player Classic"))
    , m_strOldAssocKey(_T("PreviousRegistration"))
    , m_strRegisteredAppKey(_T("Software\\Clients\\Media\\Media Player Classic\\Capabilities"))
    , m_strRegAppFileAssocKey(_T("Software\\Clients\\Media\\Media Player Classic\\Capabilities\\FileAssociations"))
    , m_strOpenCommand(_T("\"") + GetProgramPath(true) + _T("\" \"%1\""))
    , m_strEnqueueCommand(_T("\"") + GetProgramPath(true) + _T("\" /add \"%1\""))
    , m_bNoRecentDocs(false)
{
    // Default manager (requires at least Vista)
    VERIFY(CoCreateInstance(CLSID_ApplicationAssociationRegistration, nullptr,
                            CLSCTX_INPROC, IID_PPV_ARGS(&m_pAAR)) != CO_E_NOTINITIALIZED);

    m_handlers[0] = { _T("VideoFiles"), _T(" %1"), IDS_AUTOPLAY_PLAYVIDEO };
    m_handlers[1] = { _T("MusicFiles"), _T(" %1"), IDS_AUTOPLAY_PLAYMUSIC };
    m_handlers[2] = { _T("CDAudio"), _T(" %1 /cd"), IDS_AUTOPLAY_PLAYAUDIOCD };
    m_handlers[3] = { _T("DVDMovie"), _T(" %1 /dvd"), IDS_AUTOPLAY_PLAYDVDMOVIE };
}
Exemplo n.º 10
0
UINT CFileAssoc::RunCheckIconsAssocThread(LPVOID pParam)
{
    const CMediaFormats& mf = *(const CMediaFormats*)pParam;

    UINT nLastVersion = AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, IDS_RS_ICON_LIB_VERSION, 0);

    if (LoadIconLib()) {
        UINT nCurrentVersion = GetIconLibVersion();
        SaveIconLibVersion(); // Ensure we don't try to fix the icons more than once

        CAtlList<CString> registeredExts;

        if (nCurrentVersion != nLastVersion && GetAssociatedExtensions(mf, registeredExts)) {
            if (SysVersion::IsVistaOrLater() && !IsUserAnAdmin()) {
                TASKDIALOGCONFIG config = {0};
                config.cbSize = sizeof(config);
                config.hInstance = AfxGetInstanceHandle();
                config.hwndParent = AfxGetApp()->GetMainWnd()->GetSafeHwnd();
                config.dwCommonButtons = TDCBF_YES_BUTTON | TDCBF_NO_BUTTON;
                config.pszMainIcon = TD_SHIELD_ICON;
                config.pszWindowTitle = MAKEINTRESOURCE(IDS_ICONS_REASSOC_DLG_TITLE);
                config.pszMainInstruction = MAKEINTRESOURCE(IDS_ICONS_REASSOC_DLG_INSTR);
                config.pszContent = MAKEINTRESOURCE(IDS_ICONS_REASSOC_DLG_CONTENT);
                config.pfCallback = TaskDialogCallbackProc;

                typedef HRESULT(_stdcall * pfTaskDialogIndirect)(const TASKDIALOGCONFIG*, int*, int*, BOOL*);

                HMODULE hModule = ::LoadLibrary(_T("comctl32.dll"));
                if (hModule) {
                    pfTaskDialogIndirect TaskDialogIndirect = (pfTaskDialogIndirect)(::GetProcAddress(hModule, "TaskDialogIndirect"));

                    if (TaskDialogIndirect) {
                        int nButtonPressed = 0;
                        TaskDialogIndirect(&config, &nButtonPressed, NULL, NULL);

                        if (IDYES == nButtonPressed) {
                            AfxGetMyApp()->RunAsAdministrator(GetProgramPath(true), _T("/iconsassoc"), true);
                        }
                    }

                    ::FreeLibrary(hModule);
                }
            } else {
                ReAssocIcons(registeredExts);

                SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
            }
        }

        FreeIconLib();
    }

    return 0;
}
Exemplo n.º 11
0
bool CFileAssoc::RegisterAutoPlay(autoplay_t ap, bool bRegister)
{
    CString exe = GetProgramPath(true);

    int i = (int)ap;
    if (i < 0 || i >= _countof(handlers)) {
        return false;
    }

    CRegKey key;

    if (bRegister) {
        if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, _T("MediaPlayerClassic.Autorun"))) {
            return false;
        }
        key.Close();

        if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT,
                                        _T("MediaPlayerClassic.Autorun\\Shell\\Play") + handlers[i].verb + _T("\\Command"))) {
            return false;
        }
        key.SetStringValue(NULL, _T("\"") + exe + _T("\"") + handlers[i].cmd);
        key.Close();

        if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
                                        _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\Handlers\\MPCPlay") + handlers[i].verb + _T("OnArrival"))) {
            return false;
        }
        key.SetStringValue(_T("Action"), ResStr(handlers[i].action));
        key.SetStringValue(_T("Provider"), _T("Media Player Classic"));
        key.SetStringValue(_T("InvokeProgID"), _T("MediaPlayerClassic.Autorun"));
        key.SetStringValue(_T("InvokeVerb"), _T("Play") + handlers[i].verb);
        key.SetStringValue(_T("DefaultIcon"), exe + _T(",0"));
        key.Close();

        if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
                                        _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + _T("OnArrival"))) {
            return false;
        }
        key.SetStringValue(CString("MPCPlay") + handlers[i].verb + _T("OnArrival"), _T(""));
        key.Close();
    } else {
        if (ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
                                        _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + _T("OnArrival"))) {
            return false;
        }
        key.DeleteValue(_T("MPCPlay") + handlers[i].verb + _T("OnArrival"));
        key.Close();
    }

    return true;
}
Exemplo n.º 12
0
BOOL CDlgOptionsLanguage::OnInitDialog() 
{
	CSAPrefsSubDlg::OnInitDialog();

// Language stuff
	CString szTemp;
	szTemp.Format (_T(" %s "), CTranslate::ReadString (50, _T("Language")));
	((CStatic *)GetDlgItem (IDC_STATIC1))->SetWindowText (szTemp);
	((CStatic *)GetDlgItem (IDC_STATIC2))->SetWindowText (CTranslate::ReadString (51, _T("Select language")));
	((CButton *)GetDlgItem (IDC_EDITLANGUAGE))->SetWindowText (CTranslate::ReadString (52, _T("Edit language...")));
	((CButton *)GetDlgItem (IDC_ADDLANGUAGE))->SetWindowText (CTranslate::ReadString (53, _T("Add language...")));


// Fill the combobox with languages
	HANDLE hSearch;
	WIN32_FIND_DATA FileData; 
	bool bDone;
	CString szPath;
	szPath = GetProgramPath ();
	hSearch = FindFirstFile(szPath + _T("\\Language\\*.ini"), &FileData);
	if (hSearch == INVALID_HANDLE_VALUE) 
		bDone = TRUE;
	else 
		bDone = FALSE;

	while (bDone == FALSE)	{
		m_pLanguage.AddString (FileData.cFileName);		
		

		if (!FindNextFile(hSearch, &FileData)) 
			bDone = TRUE; 
	}

	FindClose (hSearch);
	m_pLanguage.SetItemHeight (0, 17);

// Select the language we are using (by default, English.ini)
	m_pLanguage.SelectString (0, m_szLanguageIni);

// Change the font
	LOGFONT lf;                        
	memset(&lf, 0, sizeof(LOGFONT));   
	lf.lfHeight = 15;                  
	lf.lfWeight = FW_EXTRALIGHT; 
	_tcscpy(lf.lfFaceName, _T("Microsoft Sans Serif"));
	m_font.CreateFontIndirect(&lf);    
	m_pLanguage.SetFont (&m_font);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Exemplo n.º 13
0
CLIB_API const boost::filesystem::path & GetIniPath(boost::filesystem::path & path)
{
    boost::filesystem::path programPath;
    std::string leaf = pathToString(GetProgramPath(programPath).leaf());
    TCHAR szFileName[_MAX_FNAME];
    TCHAR szExt[_MAX_FNAME];
    _tsplitpath(CA2T(leaf.c_str()), NULL, NULL, szFileName, szExt);
    std::_tstring iniName = szFileName;
    iniName += _T(".");
    iniName += INI;
    boost::filesystem::path appFolder;
    path = GetApplicationFolder(appFolder) / stringToPath(iniName);
    return path;
}
Exemplo n.º 14
0
void CPPageWebServer::OnBnClickedButton1()
{
    CString dir = GetCurWebRoot();
    if (PickDir(dir)) {
        CPath path;
        if (path.RelativePathTo(GetProgramPath(), FILE_ATTRIBUTE_DIRECTORY, dir, FILE_ATTRIBUTE_DIRECTORY)) {
            dir = (LPCTSTR)path;
        }
        m_WebRoot = dir;

        UpdateData(FALSE);
        SetModified();
    }
}
Exemplo n.º 15
0
bool CPlayerToolBar::LoadExternalToolBar(CImage* image)
{
    bool success = true;
    CString path = GetProgramPath();

    // Try to load an external PNG toolbar first
    if (FAILED(image->Load(path + _T("toolbar.png")))) {
        // If it fails, try to load an external BMP toolbar
        if (FAILED(image->Load(path + _T("toolbar.bmp")))) {
            success = false;
        }
    }

    return success;
}
Exemplo n.º 16
0
bool CFileAssoc::ReAssocIcons(const CAtlList<CString>& exts)
{
    if (!LoadIconLib()) {
        return false;
    }
    SaveIconLibVersion();

    const CString progPath = GetProgramPath(true);

    CRegKey key;

    POSITION pos = exts.GetHeadPosition();
    while (pos) {
        const CString ext = exts.GetNext(pos);
        const CString strProgID = PROGID + ext;
        CString appIcon;

        int iconIndex = GetIconIndex(ext);

        /* icon_index value -1 means no icon was found in the iconlib for the file extension */
        if (iconIndex >= 0 && ExtractIcon(AfxGetApp()->m_hInstance, m_iconLibPath, iconIndex)) {
            appIcon.Format(_T("\"%s\",%d"), m_iconLibPath, iconIndex);
        }

        /* no icon was found for the file extension, so use MPC's icon */
        if (appIcon.IsEmpty()) {
            appIcon = "\"" + progPath + "\",0";
        }

        if (ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\DefaultIcon"))
                || ERROR_SUCCESS != key.SetStringValue(NULL, appIcon)) {
            return false;
        }

        key.Close();
    }

    FreeIconLib();

    return true;
}
Exemplo n.º 17
0
bool CFileAssoc::LoadIconLib()
{
    bool loaded = false;

    FreeIconLib();

    m_iconLibPath = GetProgramPath() + _T("mpciconlib.dll");
    m_hIconLib = LoadLibrary(m_iconLibPath);
    if (m_hIconLib) {
        GetIconIndex = (GetIconIndexFunc)GetProcAddress(m_hIconLib, "GetIconIndex");
        GetIconLibVersion = (GetIconLibVersionFunc)GetProcAddress(m_hIconLib, "GetIconLibVersion");

        if (GetIconIndex && GetIconLibVersion) {
            loaded = true;
        } else {
            FreeIconLib();
        }
    }

    return loaded;
}
Exemplo n.º 18
0
CLIB_API const boost::filesystem::path & GetApplicationFolder(boost::filesystem::path & path)
{
    CCmdLineParser parser(::GetCommandLine());
    if (parser.HasKey(_T("WF")))
    {
        std::_tstring workspace = parser.GetVal(_T("WF"));
        path = stringToPath(workspace);
    }
    else
    {
        boost::filesystem::path programPath;
        std::string leaf = pathToString(GetProgramPath(programPath).leaf());
        TCHAR szFileName[_MAX_FNAME];
        TCHAR szExt[_MAX_FNAME];
        _tsplitpath(CA2T(leaf.c_str()), NULL, NULL, szFileName, szExt);		
        boost::filesystem::path companyFolder;
        path = GetCompanyFolder(companyFolder) / stringToPath(szFileName);
    }
    boost::filesystem::create_directories(path);
    return path;
}
Exemplo n.º 19
0
bool CFileAssoc::IsAutoPlayRegistered(autoplay_t ap)
{
    ULONG len;
    TCHAR buff[_MAX_PATH];
    CString exe = GetProgramPath(true);

    int i = (int)ap;
    if (i < 0 || i >= _countof(handlers)) {
        return false;
    }

    CRegKey key;

    if (ERROR_SUCCESS != key.Open(HKEY_LOCAL_MACHINE,
                                  _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + _T("OnArrival"),
                                  KEY_READ)) {
        return false;
    }
    len = _countof(buff);
    if (ERROR_SUCCESS != key.QueryStringValue(_T("MPCPlay") + handlers[i].verb + _T("OnArrival"), buff, &len)) {
        return false;
    }
    key.Close();

    if (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT,
                                  _T("MediaPlayerClassic.Autorun\\Shell\\Play") + handlers[i].verb + _T("\\Command"),
                                  KEY_READ)) {
        return false;
    }
    len = _countof(buff);
    if (ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len)) {
        return false;
    }
    if (_tcsnicmp(_T("\"") + exe, buff, exe.GetLength() + 1)) {
        return false;
    }
    key.Close();

    return true;
}
Exemplo n.º 20
0
bool CFileAssoc::RegisterFolderContextMenuEntries(bool bRegister)
{
    CRegKey key;
    bool success;

    if (bRegister) {
        success = false;

        CString appIcon = "\"" + GetProgramPath(true) + "\",0";

        if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".enqueue"))) {
            key.SetStringValue(nullptr, ResStr(IDS_ADD_TO_PLAYLIST));
            key.SetStringValue(_T("Icon"), appIcon);

            if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".enqueue\\command"))) {
                key.SetStringValue(nullptr, m_strEnqueueCommand);
                success = true;
            }
        }

        if (success && ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".play"))) {
            success = false;

            key.SetStringValue(nullptr, ResStr(IDS_OPEN_WITH_MPC));
            key.SetStringValue(_T("Icon"), appIcon);

            if (ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\") PROGID _T(".play\\command"))) {
                key.SetStringValue(nullptr, m_strOpenCommand);
                success = true;
            }
        }

    } else {
        key.Attach(HKEY_CLASSES_ROOT);
        success  = (ERROR_SUCCESS == key.RecurseDeleteKey(_T("Directory\\shell\\") PROGID _T(".enqueue")));
        success &= (ERROR_SUCCESS == key.RecurseDeleteKey(_T("Directory\\shell\\") PROGID _T(".play")));
    }

    return success;
}
Exemplo n.º 21
0
CString CFGFilterLAV::GetFilterPath(LAVFILTER_TYPE filterType)
{
    // Default path
    CString filterPath = GetProgramPath() + LAVFILTERS_DIR;
    CLSID filterCLSID;

    switch (filterType) {
        case SPLITTER:
        case SPLITTER_SOURCE:
            filterPath += CFGFilterLAVSplitterBase::filename;
            filterCLSID = GUID_LAVSplitter;
            break;
        case VIDEO_DECODER:
            filterPath += CFGFilterLAVVideo::filename;
            filterCLSID = GUID_LAVVideo;
            break;
        case AUDIO_DECODER:
            filterPath += CFGFilterLAVAudio::filename;
            filterCLSID = GUID_LAVAudio;
            break;
        default:
            ASSERT(FALSE); // This should never happen
            break;
    }

#if ENABLE_LOAD_EXTERNAL_LAVF_AS_INTERNAL
    // Check that the filter's version is correct
    if (!CheckVersion(filterPath)) {
        // If not, check if a registered version of the filter is available.
        filterPath = ::GetFilterPath(filterCLSID);
        // and if it can be used
        if (!CheckVersion(filterPath)) {
            filterPath = _T("");
        }
    }
#endif

    return filterPath;
}
Exemplo n.º 22
0
CWebServer::CWebServer(CMainFrame* pMainFrame, int nPort)
    : m_pMainFrame(pMainFrame)
    , m_nPort(nPort)
{
    m_webroot = CPath(GetProgramPath());
    const CAppSettings& s = AfxGetAppSettings();

    CString WebRoot = s.strWebRoot;
    WebRoot.Replace('/', '\\');
    WebRoot.Trim();
    CPath p(WebRoot);
    if (WebRoot.Find(_T(":\\")) < 0 && WebRoot.Find(_T("\\\\")) < 0) {
        m_webroot.Append(WebRoot);
    } else {
        m_webroot = p;
    }
    m_webroot.Canonicalize();
    m_webroot.MakePretty();
    if (!m_webroot.IsDirectory()) {
        m_webroot = CPath();
    }

    CAtlList<CString> sl;
    Explode(s.strWebServerCGI, sl, ';');
    POSITION pos = sl.GetHeadPosition();
    while (pos) {
        CAtlList<CString> sl2;
        CString ext = Explode(sl.GetNext(pos), sl2, '=', 2);
        if (sl2.GetCount() < 2) {
            continue;
        }
        m_cgi[ext] = sl2.GetTail();
    }

    m_ThreadId = 0;
    m_hThread = ::CreateThread(nullptr, 0, StaticThreadProc, (LPVOID)this, 0, &m_ThreadId);
}
Exemplo n.º 23
0
bool CPlayerToolBar::LoadExternalToolBar(CImage* image)
{
    bool success = true;
    CString path = GetProgramPath();

    // Try to load an external PNG toolbar first
    if (FAILED(image->Load(path + _T("toolbar.png")))) {
        // If it fails, try to load an external BMP toolbar
        if (FAILED(image->Load(path + _T("toolbar.bmp")))) {
            if (AfxGetMyApp()->GetAppDataPath(path)) {
                // Try to load logo from AppData path
                if (FAILED(image->Load(path + _T("\\toolbar.png")))) {
                    if (FAILED(image->Load(path + _T("\\toolbar.bmp")))) {
                        success = false;
                    }
                }
            } else {
                success = false;
            }
        }
    }

    return success;
}
Exemplo n.º 24
0
//---------------------------------------------------------------------------
void TAlmas3ProbSetGlobal::Init(void)
{//инициализация набора вероятностей
	if(m_bInit == false)
	{
		EnterCriticalSection(&m_InitCS);
		if(m_bInit == false)
		{
		 TProbKeyVec vPK;
		 int nType;
		 //Application->HideHint()
		 //
		 Screen->Cursor = crHourGlass;


		 AnsiString strAll, str1;
		 AnsiString szFilename;
		 szFilename = GetProgramPath()+INTERFACE_ID;
		 szFilename += ".cfg";

		 TProbKey nKey, nKey2;

		 int i=0;
		 if(FileExists(szFilename) == true)
		 {
		  FILE *pFile = fopen(_c_str(szFilename),"r");
		  if(pFile != NULL)
		  {
		   char szVal[256];
		   int Key;
		   while(fgets(szVal, sizeof(szVal), pFile))
		   {
			str1 = szVal;
			str1 = str1.Trim();
			Key = StrToInt(str1);
			nKey = Key;
			vPK.push_back(nKey);
		   }
		   fclose(pFile);
		   bool bChk = true;
		   bool bChk2 = true;
		   m_Key2ToKeyMap.clear();
		   int nPkSize = vPK.size();
		   //int nKey2ToKeyMapSize = m_Key2ToKeyMap.size();
		   for(i = 0; (i < nPkSize) && bChk; i++)
		   {
			nKey = vPK[i];
			bChk2 = false;
			nKey2 = RemoveLeftFromKey2( nKey );
			if(nKey2 == nKey)
			{//нет избыточности
			 nKey2 = CanonateKey2(nKey);
			 if(nKey2 == nKey)
			 {//правильно отсортирован
			  bChk2 = true;
			 }
			}
			if(bChk2 != true)
			{
			 bChk = false;
			}
			//nKey2ToKeyMapSize = m_Key2ToKeyMap.size();
		   }
		   if(bChk == false)
		   {
			vPK.clear();
		   }
		  }
		 }

		 if(vPK.size()==0)
		 {
		  m_Key2ToKeyMap.clear();
		  TProbKey nMaxKey = Adg2Base(2,2)*Adg2State;
		  TProbKey nKey, nKey2;

		  for(nKey = 0; nKey < nMaxKey; nKey++)
		  {
		   nKey2 = RemoveLeftFromKey2( nKey );
		   if(nKey2 == nKey)
		   {//нет избыточности
			nKey2 = CanonateKey2(nKey);
			if(nKey2 == nKey)
			{//правильно отсортирован
			 vPK.push_back(nKey);//добавляем в мап
			}
		   }
		  }

		  //сохранить конфигурацию в файл
		  FILE *pFile = fopen(_c_str(szFilename),"w+");
		  if(pFile != NULL)
		  {
		   for(UINT i = 0; i < vPK.size(); i++)
		   {
			str1=IntToStr((int)(vPK[i]))+"\n";
			fputs(_c_str(str1), pFile);
		   }
		   fclose(pFile);
		  }
		 }

		 TAlmas3ProbSetKey k1,k2;
		 //k1.fill(2468447);
		 //k2.fill(2468495);
		 //k1.fill(189012);//22. (s1, v0; s0, v0)x1 - 189012
		 k1.fill(14);//22. (s1, v0; s0, v0)x1 - 189012

		 TKey2ToKeyMap::iterator itr;
		 vPK.clear();
		 bool bTest = false;
		 //bTest = true;
		 //AnsiString strAll, str1;
		 //int i=0;
		 i=0;
		 for(itr = m_Key2ToKeyMap.begin(); itr != m_Key2ToKeyMap.end(); itr++)
		 {
		  vPK.push_back(itr->second);
		  if(bTest)
		  {
		   k1.fill2(itr->second);
		   GetProbNameFromKey2(itr->second, nType, i, str1);//имя вероятности
		   if(bTest)
		   {
			strAll += str1 + " k2:" +IntToStr((int)itr->first)+"\r\n";
		   }
		  }
		  i++;
		 }

		 if(bTest)
		 {
		  str1 = INTERFACE_ID;
		  str1 += ".txt";

		  FILE *pFile = fopen(_c_str(str1),"w+b");
		  if(pFile != NULL)
		  {
		   fwrite(_c_str(strAll), strAll.Length(),1,pFile);
		   fclose(pFile);
		  }
		 }

		 m_nAllNumProbality = vPK.size();
		 m_pstrProbName = new AnsiString[m_nAllNumProbality];
		 m_pdDefaultProbArr = new double[m_nAllNumProbality];

		 double TypeProb[3];
		 TypeProb[0] = pow(10, -(0)*3);
		 TypeProb[1] = pow(10, -(1)*3);
		 TypeProb[2] = pow(10, -(2)*3);
		 m_PiKeyMap.clear();
		 for(i=0; i < m_nAllNumProbality; i++)
		 {
		  nKey = vPK[i];
		  m_PiKeyMap[nKey] = (TProbIndex)i;
		  //nType = GetTypeFromKey2(nKey);
		  GetProbNameFromKey2(nKey, nType, i, m_pstrProbName[i]);//имя вероятности
		  if(nType> 0 && nType < 4)
		   m_pdDefaultProbArr[i] = TypeProb[nType-1];//значение вероятности по умолчанию
		  else
		   nType /= 0;
		 }
		 Screen->Cursor = crDefault;

		 m_bInit = true;
		}
		LeaveCriticalSection(&m_InitCS);
	}
}
str_type::string ETHScriptWrapper::GetAbsolutePath(const str_type::string &fileName)
{
	return GetProgramPath() + fileName;
}
Exemplo n.º 26
0
BOOL CAboutDlg::OnInitDialog()
{
    // Get the default text before it is overwritten by the call to __super::OnInitDialog()
    GetDlgItem(IDC_AUTHORS_LINK)->GetWindowText(m_credits);
#ifndef MPCHC_LITE
    GetDlgItem(IDC_LAVFILTERS_VERSION)->GetWindowText(m_LAVFiltersVersion);
#endif

    __super::OnInitDialog();

    // Because we set LR_SHARED, there is no need to explicitly destroy the icon
    m_icon.SetIcon((HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 48, 48, LR_SHARED));

    m_appname = _T("MPC-HC");
    if (VersionInfo::IsNightly() || VersionInfo::Is64Bit()) {
        m_appname += _T(" (");
    }
    if (VersionInfo::IsNightly()) {
        m_appname += VersionInfo::GetNightlyWord();
    }
    if (VersionInfo::IsNightly() && VersionInfo::Is64Bit()) {
        m_appname += _T(", ");
    }
    if (VersionInfo::Is64Bit()) {
        m_appname += _T("64-bit");
    }
    if (VersionInfo::IsNightly() || VersionInfo::Is64Bit()) {
        m_appname += _T(")");
    }

#ifdef MPCHC_LITE
    m_appname += _T(" Lite");
#endif

    // Build the path to Authors.txt
    m_AuthorsPath = GetProgramPath() + _T("Authors.txt");
    // Check if the file exists
    if (FileExists(m_AuthorsPath)) {
        // If it does, we make the filename clickable
        m_credits.Replace(_T("Authors.txt"), _T("<a>Authors.txt</a>"));
    }

    m_homepage.Format(_T("<a>%s</a>"), WEBSITE_URL);

    m_strBuildNumber = VersionInfo::GetFullVersionString();

#if defined(__INTEL_COMPILER)
#if (__INTEL_COMPILER >= 1210)
    m_MPCCompiler = _T("ICL ") MAKE_STR(__INTEL_COMPILER) _T(" Build ") MAKE_STR(__INTEL_COMPILER_BUILD_DATE);
#else
#error Compiler is not supported!
#endif
#elif defined(_MSC_VER)
#if (_MSC_VER == 1800)              // 2013
#if (_MSC_FULL_VER == 180021005)
    m_MPCCompiler = _T("MSVC 2013");
#elif (_MSC_FULL_VER < 180021005)
    m_MPCCompiler = _T("MSVC 2013 Preview/Beta/RC");
#endif
#elif (_MSC_VER <= 1700)
#error Compiler is not supported!
#endif
#else
#error Please add support for your compiler
#endif

#if (__AVX__)
    m_MPCCompiler += _T(" (AVX)");
#elif (__SSSE3__)
    m_MPCCompiler += _T(" (SSSE3)");
#elif (__SSE3__)
    m_MPCCompiler += _T(" (SSE3)");
#elif !defined(_M_X64) && defined(_M_IX86_FP)
#if (_M_IX86_FP == 2)   // /arch:SSE2 was used
    m_MPCCompiler += _T(" (SSE2)");
#elif (_M_IX86_FP == 1) // /arch:SSE was used
    m_MPCCompiler += _T(" (SSE)");
#endif
#endif

#ifdef _DEBUG
    m_MPCCompiler += _T(" Debug");
#endif

    m_LAVFilters.Format(IDS_STRING_COLON, _T("LAV Filters"));
#ifndef MPCHC_LITE
    CString LAVFiltersVersion = CFGFilterLAV::GetVersion();
    if (!LAVFiltersVersion.IsEmpty()) {
        m_LAVFiltersVersion = LAVFiltersVersion;
    }
#endif

    m_buildDate = VersionInfo::GetBuildDateString();

    OSVERSIONINFOEX osVersion = SysVersion::GetFullVersion();
    m_OSName.Format(_T("Windows NT %1u.%1u (build %u"),
                    osVersion.dwMajorVersion, osVersion.dwMinorVersion, osVersion.dwBuildNumber);
    if (osVersion.szCSDVersion[0]) {
        m_OSName.AppendFormat(_T(", %s)"), osVersion.szCSDVersion);
    } else {
        m_OSName += _T(")");
    }
    m_OSVersion.Format(_T("%1u.%1u"), osVersion.dwMajorVersion, osVersion.dwMinorVersion);
    if (SysVersion::Is64Bit()) {
        m_OSVersion += _T(" (64-bit)");
    }

    UpdateData(FALSE);

    GetDlgItem(IDOK)->SetFocus();

    return FALSE;
}
Exemplo n.º 27
0
BOOL CAboutDlg::OnInitDialog()
{
    // Get the default text before it is overwritten by the call to __super::OnInitDialog()
    GetDlgItem(IDC_STATIC1)->GetWindowText(m_appname);
    GetDlgItem(IDC_AUTHORS_LINK)->GetWindowText(m_credits);
#ifndef MPCHC_LITE
    GetDlgItem(IDC_LAVFILTERS_VERSION)->GetWindowText(m_LAVFiltersVersion);
#endif

    __super::OnInitDialog();

    // Because we set LR_SHARED, there is no need to explicitly destroy the icon
    m_icon.SetIcon((HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 48, 48, LR_SHARED));

#if MPC_BETA_RELEASE || _WIN64
    m_appname += _T(" (");
#endif

#if MPC_BETA_RELEASE
    m_appname += MPC_VERSION_BETA;
#endif

#if MPC_BETA_RELEASE && _WIN64
    m_appname += _T(", ");
#endif

#ifdef _WIN64
    m_appname += _T("64-bit");
#endif

#if MPC_BETA_RELEASE || _WIN64
    m_appname += _T(")");
#endif

#ifdef MPCHC_LITE
    m_appname += _T(" Lite");
#endif

    // Build the path to Authors.txt
    m_AuthorsPath = GetProgramPath() + _T("Authors.txt");
    // Check if the file exists
    if (FileExists(m_AuthorsPath)) {
        // If it does, we make the filename clickable
        m_credits.Replace(_T("Authors.txt"), _T("<a>Authors.txt</a>"));
    }

    m_homepage.Format(_T("<a>%s</a>"), WEBSITE_URL);

    m_strBuildNumber = MPC_VERSION_STR_FULL;

#if defined(__INTEL_COMPILER)
#if (__INTEL_COMPILER >= 1210)
    m_MPCCompiler = _T("ICL ") MAKE_STR(__INTEL_COMPILER) _T(" Build ") MAKE_STR(__INTEL_COMPILER_BUILD_DATE);
#else
#error Compiler is not supported!
#endif
#elif defined(_MSC_VER)
#if (_MSC_VER == 1700) // 2012
#if (_MSC_FULL_VER == 170060610)
    m_MPCCompiler = _T("MSVC 2012 Update 3");
#elif (_MSC_FULL_VER == 170060315)  // MSVC 2012 Update 2
#error VS2012 Update 2 is not supported because the binaries will not run on XP. Install Update 3 instead.
#elif (_MSC_FULL_VER == 170051106)
    m_MPCCompiler = _T("MSVC 2012 Update 1");
#elif (_MSC_FULL_VER < 170050727)   // MSVC 2012
#error Please install the latest Update for VS2012.
#else
    m_MPCCompiler = _T("MSVC 2012");
#endif
#elif (_MSC_VER == 1600) // 2010
#if (_MSC_FULL_VER >= 160040219)
    m_MPCCompiler = _T("MSVC 2010 SP1");
#else
    m_MPCCompiler = _T("MSVC 2010");
#endif
#elif (_MSC_VER < 1600)
#error Compiler is not supported!
#endif
#else
#error Please add support for your compiler
#endif

#if (__AVX__)
    m_MPCCompiler += _T(" (AVX)");
#elif (__SSSE3__)
    m_MPCCompiler += _T(" (SSSE3)");
#elif (__SSE3__)
    m_MPCCompiler += _T(" (SSE3)");
#elif !defined(_M_X64) && defined(_M_IX86_FP)
#if (_M_IX86_FP == 2)   // /arch:SSE2 was used
    m_MPCCompiler += _T(" (SSE2)");
#elif (_M_IX86_FP == 1) // /arch:SSE was used
    m_MPCCompiler += _T(" (SSE)");
#endif
#endif

#ifdef _DEBUG
    m_MPCCompiler += _T(" Debug");
#endif

#ifndef MPCHC_LITE
    CString LAVFiltersVersion = CFGFilterLAV::GetVersion();
    if (!LAVFiltersVersion.IsEmpty()) {
        m_LAVFiltersVersion = LAVFiltersVersion;
    }
#endif

    m_buildDate = _T(__DATE__) _T(" ") _T(__TIME__);

    OSVERSIONINFOEX osVersion = SysVersion::GetFullVersion();
    m_OSName.Format(_T("Windows NT %1u.%1u (build %u"),
                    osVersion.dwMajorVersion, osVersion.dwMinorVersion, osVersion.dwBuildNumber);
    if (osVersion.szCSDVersion[0]) {
        m_OSName.AppendFormat(_T(", %s)"), osVersion.szCSDVersion);
    } else {
        m_OSName += _T(")");
    }
    m_OSVersion.Format(_T("%1u.%1u"), osVersion.dwMajorVersion, osVersion.dwMinorVersion);
    if (SysVersion::Is64Bit()) {
        m_OSVersion += _T(" (64-bit)");
    }

    UpdateData(FALSE);

    GetDlgItem(IDOK)->SetFocus();

    return FALSE;
}
Exemplo n.º 28
0
string ProjectManager::ReadLastDir()
{
	return GetAttributeFromInfoFile(GetProgramPath(), "directories", "lastProject");
}
Exemplo n.º 29
0
void ProjectManager::LoadEditor()
{
	CreateFileMenu();
	// get current program path
	m_curve = m_provider->GetVideo()->CreateSprite(utf8::c(GetProgramPath() + "data/curve_right.png").wc_str());
}
Exemplo n.º 30
0
CLIB_API const boost::filesystem::path & GetProgramFolder(boost::filesystem::path & path)
{
    boost::filesystem::path p;
    path = GetProgramPath(p).branch_path();
    return path;
}