Esempio 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());
        }
    }


}