Пример #1
0
int Runner::NewCmd(LPCTSTR taskname, LPTSTR lpCmdLine)
{
	Params::Save(lpCmdLine);

	DWORD dwProcessId = ::GetCurrentProcessId();
    CHandle hEventRun( ::CreateEvent( NULL, FALSE, TRUE, c_szEventRun));
	if (::WaitForSingleObject(hEventRun, c_dwRunTimeout) != WAIT_OBJECT_0)
		return ecSimultanius;

	CString strEvent;
	strEvent.Format(c_szEventExit, dwProcessId);
	CHandle hEventExit( ::CreateEvent( NULL, TRUE, FALSE, strEvent));
	::ResetEvent( hEventExit);

    CAtlString sApp;
	sApp.Format(_T("schtasks /run /TN \"%s\""), taskname);

    STARTUPINFO startup_info = {0};
    startup_info.cb = sizeof( STARTUPINFO );
    PROCESS_INFORMATION process_info = {0};

    BOOL bStatus = ::CreateProcess( NULL, sApp.GetBuffer(MAX_PATH), NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &startup_info, &process_info );
    if ( bStatus == FALSE)
        return ecRunTask;
    ::CloseHandle( process_info.hProcess );
    ::CloseHandle( process_info.hThread );

	if (::WaitForSingleObject(hEventRun, c_dwRunTimeout) != WAIT_OBJECT_0)
		return ecUnknown;

    ::WaitForSingleObject(hEventExit, INFINITE);

    return ecNoError;
}
void CTedTransformDialog::PopulateCategory(DMOCategory& category) 
{
    TVINSERTSTRUCT treeInserter;
    treeInserter.hParent = TVI_ROOT;
    treeInserter.hInsertAfter = TVI_FIRST;

    CAtlString strName = LoadAtlString(category.m_nID);
    TVITEM item;
    item.mask = TVIF_TEXT;
    item.pszText = strName.GetBuffer();
    item.cchTextMax = strName.GetLength();

    treeInserter.item = item;
    HTREEITEM hBaseItem = (HTREEITEM) TreeView_InsertItem(m_hList, &treeInserter);

    assert(hBaseItem != NULL);

    treeInserter.hParent = hBaseItem;
    item.mask = TVIF_TEXT | TVIF_PARAM;

    DMO_PARTIAL_MEDIATYPE mediaType;
    CComPtr<IEnumDMO> spDMOList;

    mediaType.type = GUID_NULL;
    mediaType.subtype = GUID_NULL;
    
    IMFActivate** ppActivates = NULL;
    UINT32 cMFTs = 0;
    ::MFTEnumEx(category.m_GUID, MFT_ENUM_FLAG_ALL, NULL, NULL, &ppActivates, &cMFTs);

    for(DWORD i = 0; i < cMFTs; i++)
    {
        m_Activates.Add(ppActivates[i]);

        LPWSTR pszName = NULL;
        ppActivates[i]->GetAllocatedString(MFT_FRIENDLY_NAME_Attribute, &pszName, NULL);
        
        m_strNames.Add(CAtlStringW(pszName));
        item.pszText = m_strNames.GetAt(m_strNames.GetCount() - 1).GetBuffer();
        item.lParam = (LPARAM)  m_Activates.GetCount() - 1;

        treeInserter.item = item;

        TreeView_InsertItem(m_hList, &treeInserter);
        
        CoTaskMemFree(pszName);
    }

    CoTaskMemFree(ppActivates);
}
Пример #3
0
CAtlString RegValue::GetString(LPCTSTR lpValue)
{
	CheckReadPerissions();

	DWORD dLen;
	DWORD dwType;
	m_stResult = ::RegQueryValueEx( (HKEY)m_hKey.m_h, lpValue, 0, &dwType, NULL, &dLen);
    CheckError("Can't query registry value");

	if (dwType != REG_SZ)
		throw std::runtime_error("Incompatible types");

    CAtlString str;
	m_stResult = ::RegQueryValueEx( (HKEY)m_hKey.m_h, lpValue, 0, NULL,
		(LPBYTE)str.GetBuffer(dLen / sizeof(TCHAR) + 1), &dLen);
    CheckError("Can't query registry value");

    str.ReleaseBuffer(dLen / sizeof(TCHAR));
	str.ReleaseBuffer();
	return str;
}
Пример #4
0
int rho_sysimpl_get_property(char* szPropName, VALUE* resValue)
{
	if (strcasecmp("webview_framework",szPropName) == 0)
	{
#ifdef RHODES_EMULATOR
		*resValue = rho_ruby_create_string("WEBKIT/" QTWEBKIT_VERSION_STR);
#elif defined(APP_BUILD_CAPABILITY_WEBKIT_BROWSER)
		*resValue = rho_ruby_create_string("WEBKIT");
#else
		rho::String msieVer = "IE";
		get_msie_version(msieVer);
		*resValue = rho_ruby_create_string(msieVer.c_str());
#endif
		return 1;
	}

#ifdef RHODES_EMULATOR
    if (strcasecmp("main_window_closed",szPropName) == 0) 
        {*resValue = rho_ruby_create_boolean(CMainWindow::mainWindowClosed); return 1;}
#endif

	if (strcasecmp("has_camera",szPropName) == 0) 
        {*resValue = rho_ruby_create_boolean(has_camera()); return 1;}

	if (strcasecmp("phone_number",szPropName) == 0)
        {*resValue = phone_number();return 1;}

	if (strcasecmp("ppi_x",szPropName) == 0)
        {*resValue = rho_ruby_create_double(get_screen_ppi_x()); return 1;}

	if (strcasecmp("ppi_y",szPropName) == 0)
        {*resValue = rho_ruby_create_double(get_screen_ppi_y()); return 1; }

	if (strcasecmp("locale",szPropName) == 0)
		{*resValue = rho_sys_get_locale(); return 1;}

	if (strcasecmp("country",szPropName) == 0)
	{
		wchar_t szCountry[20];
		int nRes = GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SISO3166CTRYNAME , szCountry, sizeof(szCountry)/sizeof(szCountry[0]));
		szCountry[2] = 0;

		*resValue = rho_ruby_create_string(convertToStringA(szCountry).c_str());
		return 1;
	}

	if (strcasecmp("device_name",szPropName) == 0)
	{
#ifdef OS_WINDOWS
		*resValue = rho_ruby_create_string("Win32");
        return 1;
#else
		HKEY hKey;
        int nRes = 0;
		if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("Ident"),
			0, KEY_READ, &hKey ) != ERROR_SUCCESS)
			return nRes;

		DWORD dwType = REG_SZ;
		DWORD dwDataSize = 0;
		if ( RegQueryValueEx( hKey, _T("name"), 0, &dwType, (PBYTE)NULL, &dwDataSize ) == ERROR_SUCCESS)
        {
		    CAtlString deviceName;
		    RegQueryValueEx( hKey, _T("name"), 0, &dwType, 
                (PBYTE)deviceName.GetBuffer((dwDataSize/sizeof(TCHAR) + sizeof(TCHAR))), &dwDataSize );
            deviceName.ReleaseBuffer();

		    *resValue = rho_ruby_create_string( convertToStringA(deviceName.GetString()).c_str() );

            nRes = 1;
        }

		RegCloseKey(hKey);
		return nRes;
#endif
	}

	if (strcasecmp("os_version",szPropName) == 0)
	{
		OSVERSIONINFO osv;
		osv.dwOSVersionInfoSize = sizeof(osv);
		if (!GetVersionEx(&osv))
			return 0;
		char buf[50];
		buf[sizeof(buf) - 1] = '\0';
		snprintf(buf, sizeof(buf) - 1, "%u.%u.%u", (unsigned)osv.dwMajorVersion,
			(unsigned)osv.dwMinorVersion, (unsigned)osv.dwBuildNumber);
		*resValue = rho_ruby_create_string(&buf[0]);
		return 1;
	}

	if (strcasecmp("is_emulator",szPropName) == 0)
    {
        bool bEmulator = false;
#ifdef OS_WINDOWS
        bEmulator = true;
#else

#endif
        *resValue = rho_ruby_create_boolean(bEmulator?1:0);
        return 1;
    }

	if (strcasecmp("has_calendar",szPropName) == 0)
    {
        *resValue = rho_ruby_create_boolean(1);
        return 1;
    }

	if (strcasecmp("has_touchscreen",szPropName) == 0)
    {
        *resValue = rho_ruby_create_boolean( rho_wmsys_has_touchscreen() );
        return 1;
    }
	if (strcasecmp("screen_orientation",szPropName) == 0)
    {
        if (rho_sys_get_screen_width() <= rho_sys_get_screen_height()) 
        {
		    *resValue = rho_ruby_create_string("portrait");
	    }
	    else {
		    *resValue = rho_ruby_create_string("landscape");
	    }                                                          
        return 1;
    }

#if defined( OS_WINCE )&& !defined( OS_PLATFORM_MOTCE )
    if (strcasecmp("device_id",szPropName) == 0) 
    {
        rho::String strDeviceID = "";
        String strAppData = "RHODES_" + RHODESAPP().getAppName() + "_DEVICEID";

        BYTE rgDeviceId[20];
        DWORD cbDeviceId = sizeof(rgDeviceId);
        HRESULT hr = GetDeviceUniqueID( (PBYTE)(strAppData.c_str()),
           strAppData.length(),
           GETDEVICEUNIQUEID_V1,
           rgDeviceId,
           &cbDeviceId);

        if ( SUCCEEDED(hr) )
        {
            for(unsigned int i = 0; i < cbDeviceId; i++)
            {
                toHexString( rgDeviceId[i], strDeviceID, 16);
            }
        }

        *resValue = rho_ruby_create_string(strDeviceID.c_str());

        return 1;
    }
#endif

	if (strcasecmp("has_cell_network",szPropName) == 0) 
    {
        *resValue = rho_ruby_create_boolean( g_rho_has_cellnetwork != 0 );
        return 1;
    }

	if (strcasecmp("has_wifi_network",szPropName) == 0) 
    {
        *resValue = rho_ruby_create_boolean( g_rho_has_network != 0 );
        return 1;
    }

    return 0;
}
Пример #5
0
int rho_sysimpl_get_property(char* szPropName, VALUE* resValue)
{
	if (strcasecmp("has_camera",szPropName) == 0) 
        {*resValue = rho_ruby_create_boolean(has_camera()); return 1;}

	if (strcasecmp("phone_number",szPropName) == 0)
        {*resValue = phone_number();return 1;}

	if (strcasecmp("ppi_x",szPropName) == 0)
        {*resValue = rho_ruby_create_double(get_screen_ppi_x()); return 1;}

	if (strcasecmp("ppi_y",szPropName) == 0)
        {*resValue = rho_ruby_create_double(get_screen_ppi_y()); return 1; }

	if (strcasecmp("locale",szPropName) == 0)
		{*resValue = rho_sys_get_locale(); return 1;}

	if (strcasecmp("country",szPropName) == 0)
	{
		wchar_t szCountry[20];
		int nRes = GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SISO3166CTRYNAME , szCountry, sizeof(szCountry)/sizeof(szCountry[0]));
		szCountry[2] = 0;

		*resValue = rho_ruby_create_string(convertToStringA(szCountry).c_str());
		return 1;
	}

	if (strcasecmp("device_name",szPropName) == 0)
	{
#ifdef OS_WINDOWS
		*resValue = rho_ruby_create_string("Win32");
        return 1;
#else
		HKEY hKey;
        int nRes = 0;
		if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("Ident"),
			0, KEY_READ, &hKey ) != ERROR_SUCCESS)
			return nRes;

		DWORD dwType = REG_SZ;
		DWORD dwDataSize = 0;
		if ( RegQueryValueEx( hKey, _T("name"), 0, &dwType, (PBYTE)NULL, &dwDataSize ) == ERROR_SUCCESS)
        {
		    CAtlString deviceName;
		    RegQueryValueEx( hKey, _T("name"), 0, &dwType, 
                (PBYTE)deviceName.GetBuffer((dwDataSize/sizeof(TCHAR) + sizeof(TCHAR))), &dwDataSize );
            deviceName.ReleaseBuffer();

		    *resValue = rho_ruby_create_string( convertToStringA(deviceName.GetString()).c_str() );

            nRes = 1;
        }

		RegCloseKey(hKey);
		return nRes;
#endif
	}

	if (strcasecmp("os_version",szPropName) == 0)
	{
		OSVERSIONINFO osv;
		osv.dwOSVersionInfoSize = sizeof(osv);
		if (!GetVersionEx(&osv))
			return 0;
		char buf[50];
		buf[sizeof(buf) - 1] = '\0';
		snprintf(buf, sizeof(buf) - 1, "%u.%u.%u", (unsigned)osv.dwMajorVersion,
			(unsigned)osv.dwMinorVersion, (unsigned)osv.dwBuildNumber);
		*resValue = rho_ruby_create_string(&buf[0]);
		return 1;
	}

	if (strcasecmp("is_emulator",szPropName) == 0)
    {
        bool bEmulator = false;
#ifdef OS_WINDOWS
        bEmulator = true;
#else

#endif
        *resValue = rho_ruby_create_boolean(bEmulator?1:0);
        return 1;
    }

    return 0;
}