STDMETHODIMP CVolumeControl::setVolume(SHORT* volume) { if (IsWindowsVista()) { } else { this->amdInitialize(); this->amdGetMasterVolumeControl(); DWORD setLevel = 0x00000000; //Don't set the volume to anything greater than the max level if (*volume > 100) *volume = 100; //Calculate a value based on the percentage input of one channel if (*volume) setLevel = (DWORD)(((double)*volume / 100.0) * (double)0xFFFF); //this->amdSetMasterVolumeValue( setLevel ); this->amdSetMasterVolumeValue( setLevel ); this->amdUninitialize(); return S_OK; } }
bool SessionImpl::UseLocalServer () { if (SessionImpl::runningAsLocalServer) { // already running as local server return (false); } #if defined(MIKTEX_WINDOWS) bool elevationRequired = (IsWindowsVista() && IsAdminMode() && ! SessionWrapper(true)->RunningAsAdministrator()); return (elevationRequired); #else return (false); #endif }
BOOL InstallPackageDialog::OnInitDialog () { BOOL ret = CDialog::OnInitDialog(); try { string repository; RepositoryType repositoryType (RepositoryType::Unknown); if (pManager->TryGetDefaultPackageRepository(repositoryType, repository)) { FormatControlText (IDC_EDIT_REPOSITORY_LOCATION, "%s", repository.c_str()); } else { FormatControlText (IDC_EDIT_REPOSITORY_LOCATION, "%s", T_("<Random package repository>")); } if (IsWindowsVista() && SessionWrapper(true)->IsAdminMode()) { HWND hwnd = ::GetDlgItem(m_hWnd, IDOK); if (hwnd == 0) { UNEXPECTED_CONDITION ("InstallPackageDialog::OnInitDialog"); } Button_SetElevationRequiredState (hwnd, TRUE); } } catch (const MiKTeXException & e) { ErrorDialog::DoModal (this, e); } catch (const exception & e) { ErrorDialog::DoModal (this, e); } return (ret); }
void CNdasDeviceMenu::CreateDeviceMenuItem( __in ndas::DevicePtr pDevice, __inout MENUITEMINFO& mii) { mii.fMask = MIIM_BITMAP | MIIM_DATA | MIIM_FTYPE | /* MIIM_ID | */ MIIM_STATE | MIIM_STRING | MIIM_SUBMENU; mii.fType = MFT_STRING; mii.fState = MFS_ENABLED; mii.dwItemData; /* see next */ mii.dwTypeData = const_cast<LPTSTR>(pDevice->GetName()); // // As we don't want to invert the color of the status indicator // we cannot simply create a bitmap here. We should draw it from the callback. // // Vista 5384 does not accept HBMMENU_CALLBACK // (Seems like a bug) // if (IsWindowsVista()) { CImageList imageList = pLoadStatusIndicatorImageList(); NDSI_DATA ndsiData; ATLVERIFY( mii.hSubMenu = CreateDeviceSubMenu(pDevice, &ndsiData) ); mii.hbmpItem = pCreateStatusIndicatorBitmap(m_wnd, imageList, &ndsiData); ATLVERIFY( imageList.Destroy() ); } else { mii.hbmpItem = HBMMENU_CALLBACK; ATLVERIFY(mii.hSubMenu = CreateDeviceSubMenu( pDevice, reinterpret_cast<PNDSI_DATA>(&mii.dwItemData))); } }
STDMETHODIMP CVolumeControl::getVolume(DWORD* volume) { if (IsWindowsVista()) { // MessageBox(0, "This gadget is not available for Windows Vista", "VolumeControl", 0); } else { this->amdInitialize(); this->amdGetMasterVolumeControl(); DWORD vol = 0; this->amdGetMasterVolumeValue(vol); vol = vol & 0xFFFF; //If the level is above 0, then calculate it's percentage (0-100%) if (vol) vol = (DWORD)((double)(vol / (double)0xFFFF) * 100.0); *volume = (SHORT)(vol); this->amdUninitialize(); } return S_OK; }
void SessionImpl::ConnectToServer () { const char * MSG_CANNOT_START_SERVER = T_("Cannot start MiKTeX session."); if (localServer.pSession == 0) { if (IsWindowsVista()) { WCHAR wszCLSID[50]; if (StringFromGUID2 (__uuidof(MiKTeXSessionLib::MAKE_CURVER_ID(MiKTeXSession)), wszCLSID, sizeof(wszCLSID) / sizeof(wszCLSID[0])) < 0) { FATAL_MIKTEX_ERROR ("ConnectToServer", MSG_CANNOT_START_SERVER, 0); } wstring monikerName; monikerName = L"Elevation:Administrator!new:"; monikerName += wszCLSID; BIND_OPTS3 bo; memset (&bo, 0, sizeof(bo)); bo.cbStruct = sizeof(bo); bo.hwnd = GetForegroundWindow(); bo.dwClassContext = CLSCTX_LOCAL_SERVER; HResult hr = CoGetObject(monikerName.c_str(), &bo, __uuidof(MiKTeXSessionLib::ISession), reinterpret_cast<void**>(&localServer.pSession)); if (hr == CO_E_NOTINITIALIZED) { MyCoInitialize (); hr = CoGetObject(monikerName.c_str(), &bo, __uuidof(MiKTeXSessionLib::ISession), reinterpret_cast<void**>(&localServer.pSession)); } if (hr.Failed()) { FATAL_MIKTEX_ERROR ("ConnectToServer", MSG_CANNOT_START_SERVER, hr.GetText()); } } else { HResult hr = localServer.pSession.CoCreateInstance (__uuidof(MiKTeXSessionLib::MAKE_CURVER_ID(MiKTeXSession)), 0, CLSCTX_LOCAL_SERVER); if (hr == CO_E_NOTINITIALIZED) { MyCoInitialize (); hr = localServer.pSession.CoCreateInstance (__uuidof(MiKTeXSessionLib::MAKE_CURVER_ID(MiKTeXSession)), 0, CLSCTX_LOCAL_SERVER); } if (hr.Failed()) { FATAL_MIKTEX_ERROR ("ConnectToServer", MSG_CANNOT_START_SERVER, hr.GetText()); } } } }
STDMETHODIMP CVolumeControl::isWinVista(BYTE* vista) { *vista = IsWindowsVista()?1:0; return S_OK; }
SetupWizard::SetupWizard (/*[in]*/ PackageManager * pManager) : pManager (pManager), error (false), cancelled (false), m_PackageSetDownload (true), m_PackageSetInstall (false) { NONCLIENTMETRICS ncm; memset (&ncm, 0, sizeof(ncm)); ncm.cbSize = sizeof(ncm); if (WINVER >= 0x0600 && ! IsWindowsVista()) { // work-around SDK bug ncm.cbSize -= sizeof(int/*NONCLIENTMETRICS::iPaddedBorderWidth*/); } if (! SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0)) { FATAL_WINDOWS_ERROR ("SystemParametersInfo", 0); } LOGFONT TitleLogFont = ncm.lfMessageFont; TitleLogFont.lfWeight = FW_BOLD; Utils::CopyString (TitleLogFont.lfFaceName, LF_FACESIZE, _T("Verdana Bold")); HDC hdc = ::GetDC(0); TitleLogFont.lfHeight = 0 - GetDeviceCaps(hdc, LOGPIXELSY) * 12 / 72; ::ReleaseDC (0, hdc); if (! fntWelcome.CreateFontIndirect(&TitleLogFont)) { FATAL_WINDOWS_ERROR ("CFont::CreateFontIndirect", 0); } if (! watermarkBitmap.LoadBitmap(IDB_WATERMARK)) { FATAL_WINDOWS_ERROR ("CBitmap::LoadBitmap", 0); } if (! headerBitmap.LoadBitmap(IDB_HEADER)) { FATAL_WINDOWS_ERROR ("CBitmap::LoadBitmap", 0); } Construct (IDS_SETUPWIZ, 0, 0, watermarkBitmap, 0, headerBitmap); if (! theApp.unattended) { AddPage (&m_Welcome); AddPage (&m_License); AddPage (&m_MDTask); AddPage (&m_Task); AddPage (&m_RemoteRepository); AddPage (&m_LocalRepository); AddPage (&m_PackageSetDownload); AddPage (&m_PackageSetInstall); AddPage (&m_Shared); AddPage (&m_InstallDir); #if SHOW_FOLDER_PAGE AddPage (&m_Folder); #endif AddPage (&m_Settings); #if ENABLE_ADDTEXMF AddPage (&m_AddTEXMF); AddPage (&m_EditTEXMF); #endif AddPage (&m_Info); } AddPage (&m_FileCopy); if (! theApp.unattended) { AddPage (&m_Finish); } m_psh.dwFlags |= PSH_WIZARD97; }