Ejemplo n.º 1
0
void rho_sys_run_app(const char *appname, VALUE params)
{
    CFilePath oPath(appname);
    String strAppName = oPath.getFolderName();

    StringW strKeyPath = L"Software\\Apps\\";
    strKeyPath += convertToStringW(strAppName);

    StringW strParamsW;
    if ( params && !rho_ruby_is_NIL(params) )
    {
        convertToStringW(getStringFromValue(params), strParamsW);

	/*
        int nPos = strParamsW.find(L"rhogallery_app");
        if ( nPos >= 0 )
        {
            if ( nPos == 0 || (nPos > 0 && strParamsW.at(nPos-1)!= '-' ) )
                strParamsW.insert(nPos, L"-");
        }
	*/
	strParamsW.insert(0, L"-RhoStartParams:");        
    }

    CRegKey oKey;
    LONG res = oKey.Open(HKEY_LOCAL_MACHINE, strKeyPath.c_str(), KEY_READ);
    if ( res != ERROR_SUCCESS )
    {
        LOG(ERROR) + "Cannot open registry key: " + strKeyPath + "; Code:" + res;
    }else
    {
        TCHAR szBuf[256];
        ULONG nChars = 255;

        res = oKey.QueryStringValue(L"InstallDir", szBuf, &nChars );
        if ( res != ERROR_SUCCESS )
            LOG(ERROR) + "Cannot read registry key: InstallDir; Code:" + res;
        else
        {
            StringW strFullPath = szBuf;
            if ( strFullPath[strFullPath.length()-1] != '/' && strFullPath[strFullPath.length()-1] != '\\' )
                strFullPath += L"\\";

            StringW strBaseName;
            convertToStringW(oPath.getBaseName(), strBaseName);
            strFullPath += strBaseName;

            rho_wmsys_run_appW(strFullPath.c_str(), strParamsW.c_str());
        }
    }


}
Ejemplo n.º 2
0
void rho_wmsys_run_appW(const wchar_t* szPath, const wchar_t* szParams )
{
    SHELLEXECUTEINFO se = {0};
    se.cbSize = sizeof(SHELLEXECUTEINFO);
    se.fMask = SEE_MASK_NOCLOSEPROCESS;
    se.lpVerb = L"Open";
    se.nShow = SW_SHOWNORMAL;

    StringW strAppNameW = szPath;
    for(int i = 0; i<(int)strAppNameW.length();i++)
    {
        if ( strAppNameW.at(i) == '/' )
            strAppNameW.at(i) = '\\';
    }
    se.lpFile = strAppNameW.c_str();

    if ( szParams && *szParams )
        se.lpParameters = szParams;

    if ( !ShellExecuteEx(&se) )
        LOG(ERROR) + "Cannot execute: " + strAppNameW + ";Error: " + GetLastError();

    if(se.hProcess)
        CloseHandle(se.hProcess); 
}
Ejemplo n.º 3
0
void rho_wmsys_run_app(const char* szPath, const char* szParams )
{
    SHELLEXECUTEINFO se = {0};
    se.cbSize = sizeof(SHELLEXECUTEINFO);
    se.fMask = SEE_MASK_NOCLOSEPROCESS;
    se.lpVerb = L"Open";

    StringW strAppNameW;
    convertToStringW(szPath, strAppNameW);
    for(int i = 0; i<(int)strAppNameW.length();i++)
    {
        if ( strAppNameW.at(i) == '/' )
            strAppNameW.at(i) = '\\';
    }
    se.lpFile = strAppNameW.c_str();

    StringW strParamsW;
    if ( szParams && *szParams )
    {
        convertToStringW(szParams, strParamsW);
        se.lpParameters = strParamsW.c_str();
    }

    ShellExecuteEx(&se);
}
Ejemplo n.º 4
0
HRESULT Camera::selectPicture(HWND hwndOwner,LPTSTR pszFilename) 
{
	RHO_ASSERT(pszFilename);
#if defined( _WIN32_WCE ) && !defined( OS_PLATFORM_MOTCE )
	OPENFILENAMEEX ofn = {0};
#else
    OPENFILENAME ofn = {0};
#endif
    pszFilename[0] = 0;

	ofn.lStructSize     = sizeof(ofn);
	ofn.lpstrFilter     = NULL;
	ofn.lpstrFile       = pszFilename;
	ofn.nMaxFile        = MAX_PATH;
	ofn.lpstrInitialDir = NULL;
	ofn.lpstrTitle      = _T("Select an image");
#if defined( _WIN32_WCE ) && !defined( OS_PLATFORM_MOTCE )
	ofn.ExFlags         = OFN_EXFLAG_THUMBNAILVIEW|OFN_EXFLAG_NOFILECREATE|OFN_EXFLAG_LOCKDIRECTORY;
    if (GetOpenFileNameEx(&ofn))
#else
    if (GetOpenFileName(&ofn))
#endif

    {
		HRESULT hResult = S_OK;

        /*
		TCHAR rhoroot[MAX_PATH];
		wchar_t* root  = wce_mbtowc(rho_rhodesapp_getblobsdirpath());
		wsprintf(rhoroot,L"%s",root);
		free(root);

		create_folder(rhoroot);*/

        StringW strBlobRoot = convertToStringW( RHODESAPP().getBlobsDirPath() );

        LPCTSTR szExt = wcsrchr(pszFilename, '.');
		TCHAR filename[256];
		generate_filename(filename, szExt);
		
		int len = strBlobRoot.length() + wcslen(L"\\") + wcslen(filename);
		wchar_t* full_name = (wchar_t*) malloc((len+2)*sizeof(wchar_t));
		wsprintf(full_name,L"%s\\%s",strBlobRoot.c_str(),filename);

		if (copy_file(pszFilename,full_name)) 
        {
			wcscpy( pszFilename, filename );
		} else {
			hResult = E_INVALIDARG;
		}

		free(full_name);

		return hResult;
	} else if (GetLastError()==ERROR_SUCCESS) {
		return S_FALSE; //user cancel op
	}
	return E_INVALIDARG;
}
Ejemplo n.º 5
0
void rho_sys_run_app(const char *appname, VALUE params)
{
    CRegKey oKey;
    StringW strKeyPath;
    LONG res = openRegAppPath(appname, oKey, strKeyPath);

    if ( res != ERROR_SUCCESS )
    {
        LOG(ERROR) + "Cannot open registry key: " + strKeyPath + "; Code:" + res;
    } else
    {
        TCHAR szBuf[MAX_PATH+1];
        ULONG nChars = MAX_PATH;

        res = oKey.QueryStringValue(L"InstallDir", szBuf, &nChars);
        if ( res != ERROR_SUCCESS )
            LOG(ERROR) + "Cannot read registry key: InstallDir; Code:" + res;
        else
        {
            StringW strFullPath = szBuf;

            if ( strFullPath[strFullPath.length()-1] != '/' && strFullPath[strFullPath.length()-1] != '\\' )
                strFullPath += L"\\";

			StringW strBaseName;
            CFilePath oPath(appname);
            convertToStringW(oPath.getBaseName(), strBaseName);
            strFullPath += strBaseName;

            StringW strParamsW;
            if ( params && !rho_ruby_is_NIL(params) )
            {
                convertToStringW(getStringFromValue(params), strParamsW);
            }

            rho_wmsys_run_appW(strFullPath.c_str(), strParamsW.c_str());
        }
    }
}
Ejemplo n.º 6
0
/*static*/ unsigned int CRhoFile::deleteFolder(const char* szFolderPath) 
{
#if defined(WINDOWS_PLATFORM) && !defined(OS_WP8)

	StringW  swPath;
    convertToStringW(szFolderPath, swPath);
	wchar_t* name = new wchar_t[ swPath.length() + 2];
    swprintf(name, L"%s%c", swPath.c_str(), '\0');
    translate_wchar(name, L'/', L'\\');

    SHFILEOPSTRUCTW fop = {0};

	fop.hwnd = NULL;
	fop.wFunc = FO_DELETE;		
        fop.pFrom = name;
	fop.pTo = NULL;
	fop.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR 
#if defined(OS_WINDOWS_DESKTOP) || defined(OS_PLATFORM_MOTCE)
                 | FOF_NOERRORUI
#endif        
        ;
        int result = SHFileOperationW(&fop);

    delete name;

    return result == 0 ? 0 : (unsigned int)-1;
#elif defined(OS_WP8)
	StringW  swPath;
    convertToStringW(szFolderPath, swPath);
	recursiveDeleteDirectory(swPath);
	return 0;
#elif defined (OS_ANDROID)
    
    RemoveFileFunctor funct(szFolderPath);
    return funct("");

#else
    rho_file_impl_delete_folder(szFolderPath);
    return 0;
#endif
}
Ejemplo n.º 7
0
void rho_sys_run_app(const char *appname, VALUE params)
{
#ifdef RHODES_WIN32
    StringW strAppName;
    rho::common::convertToStringW(appname, strAppName);

	StringW strKeyPath = L"Software\\Rhomobile\\RhoGallery\\";
    strKeyPath += strAppName;
#else
    CFilePath oPath(appname);
    String strAppName = oPath.getFolderName();

    StringW strKeyPath = L"Software\\Apps\\";
    strKeyPath += convertToStringW(strAppName);
#endif

    StringW strParamsW;
    if ( params && !rho_ruby_is_NIL(params) )
    {
        convertToStringW(getStringFromValue(params), strParamsW);
    }

    CRegKey oKey;
    LONG res = oKey.Open(HKEY_LOCAL_MACHINE, strKeyPath.c_str(), KEY_READ);
    if ( res != ERROR_SUCCESS )
    {
        LOG(ERROR) + "Cannot open registry key: " + strKeyPath + "; Code:" + res;
    } else
    {
        TCHAR szBuf[MAX_PATH+1];
        ULONG nChars = MAX_PATH;

        res = oKey.QueryStringValue(L"InstallDir", szBuf, &nChars);
        if ( res != ERROR_SUCCESS )
            LOG(ERROR) + "Cannot read registry key: InstallDir; Code:" + res;
        else
        {
            StringW strFullPath = szBuf;

#ifdef RHODES_WIN32
			nChars = MAX_PATH;
	        res = oKey.QueryStringValue(L"Executable", szBuf, &nChars);
			if (res != ERROR_SUCCESS) {
			    LOG(ERROR) + "Cannot read registry key: Executable; Code:" + res;
				return;
			}
            StringW strExecutable = szBuf;

			rho_win32sys_run_appW(strExecutable.c_str(), strParamsW.c_str(), strFullPath.c_str());
#else
            if ( strFullPath[strFullPath.length()-1] != '/' && strFullPath[strFullPath.length()-1] != '\\' )
                strFullPath += L"\\";

			StringW strBaseName;
            convertToStringW(oPath.getBaseName(), strBaseName);
            strFullPath += strBaseName;

            rho_wmsys_run_appW(strFullPath.c_str(), strParamsW.c_str());
#endif
        }
    }
}