void Sys_SetHighDPIMode(void) { /* For Vista, Win7 and Win8 */ BOOL(WINAPI * SetProcessDPIAware)(void) = NULL; /* Win8.1 and later */ HRESULT(WINAPI * SetProcessDpiAwareness) (YQ2_PROCESS_DPI_AWARENESS dpiAwareness) = NULL; HINSTANCE userDLL = LoadLibrary("USER32.DLL"); if (userDLL) { SetProcessDPIAware = (BOOL(WINAPI *)(void)) GetProcAddress(userDLL, "SetProcessDPIAware"); } HINSTANCE shcoreDLL = LoadLibrary("SHCORE.DLL"); if (shcoreDLL) { SetProcessDpiAwareness = (HRESULT(WINAPI *)(YQ2_PROCESS_DPI_AWARENESS)) GetProcAddress(shcoreDLL, "SetProcessDpiAwareness"); } if (SetProcessDpiAwareness) { SetProcessDpiAwareness(YQ2_PROCESS_PER_MONITOR_DPI_AWARE); } else if (SetProcessDPIAware) { SetProcessDPIAware(); } }
bool WinSevenTaskbar::setTaskbarState(QWidget *window, WinSevenTaskbarState state) { bool result = false; if(m_ptbl && window) { HRESULT hr = HRESULT(-1); switch(state) { case WinSevenTaskbarNoState: hr = m_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_NOPROGRESS); break; case WinSevenTaskbarNormalState: hr = m_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_NORMAL); break; case WinSevenTaskbarIndeterminateState: hr = m_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_INDETERMINATE); break; case WinSevenTaskbarErrorState: hr = m_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_ERROR); break; case WinSevenTaskbarPausedState: hr = m_ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_PAUSED); break; } result = SUCCEEDED(hr); } return result; }
bool Taskbar::setTaskbarState(QWidget *window, TaskbarState state) { QMutexLocker lock(&s_lock); if(s_data && s_data->ptbl && window) { HRESULT hr = HRESULT(-1); switch(state) { case TaskbarNoState: hr = s_data->ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_NOPROGRESS); break; case TaskbarNormalState: hr = s_data->ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_NORMAL); break; case TaskbarIndeterminateState: hr = s_data->ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_INDETERMINATE); break; case TaskbarErrorState: hr = s_data->ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_ERROR); break; case TaskbarPausedState: hr = s_data->ptbl->SetProgressState(reinterpret_cast<HWND>(window->winId()), TBPF_PAUSED); break; } return SUCCEEDED(hr); } return false; }
BOOL CCoolInterface::EnableTheme(CWnd* pWnd, BOOL bEnable) { HINSTANCE hTheme = LoadLibrary( _T("UxTheme.dll") ); if ( ! hTheme ) return FALSE; HRESULT (WINAPI *pfnSetWindowTheme)(HWND, LPCWSTR, LPCWSTR); (FARPROC&)pfnSetWindowTheme = GetProcAddress( hTheme, "SetWindowTheme" ); BOOL bResult = FALSE; if ( pfnSetWindowTheme ) { if ( bEnable ) { bResult = SUCCEEDED( (*pfnSetWindowTheme)( pWnd->GetSafeHwnd(), NULL, NULL ) ); } else { bResult = SUCCEEDED( (*pfnSetWindowTheme)( pWnd->GetSafeHwnd(), L" ", L" " ) ); } } FreeLibrary( hTheme ); return bResult; }
//laddar heightmap från en rawfil. void HeigthMap::Load(std::string filename, int Width, int Height) { m_Width = Width; m_Height = Height; m_Map = new float*[Height]; for (int z = 0; z < Height; z++) m_Map[z] = new float[Width]; std::vector<unsigned char> vertexHeights(Width * Height); //läser in data från raw filen. std::ifstream fin; fin.open(filename, std::ios_base::binary); if (!fin) HRESULT(E_FAIL); fin.read((char *)&vertexHeights[0], (std::streamsize)vertexHeights.size()); fin.close(); //sparar den inladdade informationen i heigtmappen. for (int z = 0; z < Height; z++) { //Inverterar data i Z axeln. int Z = Height - 1 - z; for (int x = 0; x < Width; x++) { m_Map[Z][x] = (float) vertexHeights[z*Width + x]; } } //filtrerar höjdmappen 20 gånger. //Filter(20); }
CComPtr<IHTMLElement> CWtlHtmlView::GetElement(CComPtr<IWebBrowser2> pWebBrowser, const TCHAR *id) { CComPtr<IHTMLElement> ret(NULL); if (id==0) return 0; CComPtr<IHTMLDocument2> doc = this->GetDocument(pWebBrowser); if (doc==0) throw std::exception("CMainDlg::GetElement() pHTMLDocument NULL\n"); CComPtr<IHTMLElementCollection> doc_all; HRESULT hr = doc->get_all(&doc_all); // this is like doing document.all if (hr==S_OK) { VARIANT v0; VariantInit(&v0); CComPtr<IDispatch> disp; _variant_t vid((BSTR) _bstr_t(id)); hr = doc_all->item(vid,v0,&disp); // this is like doing document.all["messages"] if (hr==S_OK && disp!=0) { hr = disp->QueryInterface(IID_IHTMLElement,(void **)&ret); // it's the caller's responsibility to release ret if(FAILED(hr)) throw HRESULT(hr); } } return ret; }
static void gfx_set_dwm(void) { HRESULT ret; HRESULT (WINAPI *composition_enable)(UINT); settings_t *settings = config_get_ptr(); if (!gfx_init_dwm()) return; if (settings->bools.video_disable_composition == dwm_composition_disabled) return; #ifdef HAVE_DYNAMIC composition_enable = (HRESULT (WINAPI*)(UINT))dylib_proc(dwmlib, "DwmEnableComposition"); #endif if (!composition_enable) { RARCH_ERR("Did not find DwmEnableComposition ...\n"); return; } ret = composition_enable(!settings->bools.video_disable_composition); if (FAILED(ret)) RARCH_ERR("Failed to set composition state ...\n"); dwm_composition_disabled = settings->bools.video_disable_composition; }
static int FindDevicesCallback(vlc_object_t *object, const char *name, char ***values, char ***descs) { enum_context_t ctx; ctx.values = xmalloc(sizeof(char *)); ctx.descs = xmalloc(sizeof(char *)); ctx.values[0] = strdup(""); ctx.descs[0] = strdup(_("Default")); ctx.count = 1; /* Load direct draw DLL */ HINSTANCE hddraw_dll = LoadLibrary(_T("DDRAW.DLL")); if (hddraw_dll != NULL) { /* Enumerate displays */ HRESULT (WINAPI *OurDirectDrawEnumerateEx)(LPDDENUMCALLBACKEXA, LPVOID, DWORD) = (void *)GetProcAddress(hddraw_dll, DIRECTDRAWENUMERATEEX_NAME); if (OurDirectDrawEnumerateEx != NULL) OurDirectDrawEnumerateEx(DirectXEnumCallback2, &ctx, DDENUM_ATTACHEDSECONDARYDEVICES); FreeLibrary(hddraw_dll); } VLC_UNUSED(object); VLC_UNUSED(name); *values = ctx.values; *descs = ctx.descs; return ctx.count; }
static bool gfx_init_dwm(void) { static bool inited = false; if (inited) return true; dwmlib = dylib_load("dwmapi.dll"); if (!dwmlib) { RARCH_LOG("Did not find dwmapi.dll.\n"); return false; } atexit(gfx_dwm_shutdown); HRESULT (WINAPI *mmcss)(BOOL) = (HRESULT (WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS"); if (mmcss) { RARCH_LOG("Setting multimedia scheduling for DWM.\n"); mmcss(TRUE); } inited = true; return true; }
//-------------------------------------------------------------------------------------------- // 関数名 : dsPause // 作成者 : 植山沙欧 // 作成日 : 2014.01.20 // 機能 : 再生中のバッファを一時停止させます // 機能効果 : 「numBuffer」バッファのサウンドを一時停止します // 引数 : <入力> numBuffer 一時停止させたいバッファ番号 // 使用変数 : ありません // 使用関数 : IDirectSoundBuffer8::Stop // 戻り値 : IDirectSoundBuffer8::Stopの戻り値が返ります // バッファが生成されていない場合は0が返ります // 更新履歴 : 2014.01.20 Ver1.00 植山沙欧 機能の実現 //-------------------------------------------------------------------------------------------- HRESULT dsPause(int numBuffer) { if(!g_ds.sec_ptr[numBuffer]) { return HRESULT(0); } return g_ds.sec_ptr[numBuffer]->Stop(); }
// ステータスメッセージ処理 BOOL CALLBACK StatusProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: bCancel = false; libarcdll_CenterWindow((HWND)lParam,hWnd); SendMessage(hWnd,WM_SETICON,ICON_BIG,(LPARAM)LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_MAIN))); SendMessage(hWnd,WM_SETICON,ICON_SMALL,(LPARAM)LoadIcon(g_hInst,MAKEINTRESOURCE(IDI_MAIN))); if (libarcdll_GetCursorMode() == TRUE) { SetClassLong(hWnd,GCL_HCURSOR,(LONG)LoadCursor((HINSTANCE)GetWindowLong(hWnd,GWL_HINSTANCE),MAKEINTRESOURCE(IDC_MAIN))); SetClassLong(GetDlgItem(hWnd,IDC_PROGRESS),GCL_HCURSOR,(LONG)LoadCursor((HINSTANCE)GetWindowLong(hWnd,GWL_HINSTANCE),MAKEINTRESOURCE(IDC_MAIN))); SetClassLong(GetDlgItem(hWnd,IDC_CANCEL),GCL_HCURSOR,(LONG)LoadCursor((HINSTANCE)GetWindowLong(hWnd,GWL_HINSTANCE),MAKEINTRESOURCE(IDC_MAIN))); } if (libarcdll_GetOSType() >= OS_WINNT_XP) { HMODULE hDll; HRESULT (WINAPI *SetWindowTheme)(HWND,LPCWSTR,LPCWSTR); if ((hDll = LoadLibrary("UxTheme.dll")) != NULL) { SetWindowTheme = (HRESULT(WINAPI*)(HWND,LPCWSTR,LPCWSTR))GetProcAddress(hDll,"SetWindowTheme"); if (SetWindowTheme != NULL) { SetWindowTheme(GetDlgItem(hWnd,IDC_CANCEL),L"",L""); SetWindowTheme(GetDlgItem(hWnd,IDC_INTASK),L"",L""); SetWindowTheme(GetDlgItem(hWnd,IDC_PROGRESS),L"",L""); } FreeLibrary(hDll); } } return TRUE; case WM_DESTROY: return TRUE; case WM_SYSCOMMAND: switch (wParam) { case SC_CLOSE: if (MessageBox(hWnd,"展開を中止しますか?","UnImp32.dll",MB_YESNO) == IDYES) { bCancel = true; } return TRUE; } return FALSE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CANCEL: SendMessage(hWnd,WM_SYSCOMMAND,SC_CLOSE,0); return TRUE; } return FALSE; case WM_TASKCALLBACK: return TRUE; } return FALSE; }
bool _DwmIsCompositionEnabled() { HMODULE library = LoadLibrary(L"dwmapi.dll"); bool result = false; if (library) { BOOL enabled = false; HRESULT (WINAPI *pFn)(BOOL *enabled) = (HRESULT (WINAPI *)(BOOL *enabled))(GetProcAddress(library, "DwmIsCompositionEnabled")); result = SUCCEEDED(pFn(&enabled)) && enabled; FreeLibrary(library); } return result; }
/** Given an audio file, this method kicks off the SAPI 5.1 DICTATION grammar on it. This is Microsoft's Speaker Independent Speech Recognition. @see ::run_sapi_textless_lipsync for an example Results are handled in the sapi_textless_lipsync::callback. @param strAudioFile - [in] the source audio file @retval true if lipsync got started @retval false if it failed to start **/ bool sapi_textless_lipsync::lipsync(const std::wstring& strAudioFile) { HRESULT hr; try { if (!this->initializeObjects()) throw (HRESULT(E_FAIL)); if (!this->loadAudio(strAudioFile)) throw (HRESULT(E_FAIL)); // initialize the grammar hr = m_grammar->LoadDictation(NULL, SPLO_STATIC); if (hr != S_OK) { m_err = L"Error: Cannot load SAPI Dictation Grammar"; } hr = m_grammar->SetDictationState(SPRS_ACTIVE); if (hr != S_OK) { m_err = L"Cannot activate the SAPI Dictation Grammar"; throw (hr); } m_recog->SetRecoState(SPRST_ACTIVE); // now we should be running! } catch (HRESULT _hr) { hr = _hr; } return (hr == S_OK); }
CDateTimeCtrlEx::~CDateTimeCtrlEx() { if (m_hUxTheme!=NULL) { HRESULT(STDAPICALLTYPE *pCloseThemeData)(HTHEME)=(HRESULT(STDAPICALLTYPE *)(HTHEME))GetProcAddress(m_hUxTheme,"CloseThemeData"); if (pCloseThemeData!=NULL) { if (m_hTheme!=NULL) pCloseThemeData(m_hTheme); } FreeLibrary(m_hUxTheme); } }
void DDrawInitialize(int width, int height) { if ( !ghMainWnd || wmode ) return; // Initialize module ShowWindow(ghMainWnd, SW_NORMAL); if ( !ddLib ) { ddLib = LoadLibrary("ddraw.dll"); DDCHECK(ddLib); } // Obtain function DirectDrawCreate HRESULT (WINAPI *_DirectDrawCreate)(GUID FAR* lpGUID, LPDIRECTDRAW FAR* lplpDD, IUnknown FAR* pUnkOuter); *(FARPROC*)&_DirectDrawCreate = GetProcAddress(ddLib, "DirectDrawCreate"); DDCHECK(_DirectDrawCreate); // Create and initialize DirectDrawInterface DDCHECK( _DirectDrawCreate(NULL, BW::BWDATA_DDInterface, NULL) == DD_OK ); DDCHECK( (*BW::BWDATA_DDInterface)->SetCooperativeLevel(ghMainWnd, DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT | DDSCL_EXCLUSIVE) == DD_OK ); if ( (*BW::BWDATA_DDInterface)->SetDisplayMode(width, height, 8) != DD_OK ) DDCHECK( (*BW::BWDATA_DDInterface)->SetDisplayMode(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), 8) == DD_OK ); // Create DirectDrawPalette DDCHECK( (*BW::BWDATA_DDInterface)->CreatePalette(DDPCAPS_8BIT | DDPCAPS_ALLOW256, BW::BWDATA_GamePalette, BW::BWDATA_PrimaryPalette, NULL) == DD_OK ); DDSURFACEDESC surfaceDesc = { 0 }; surfaceDesc.dwSize = sizeof(DDSURFACEDESC); surfaceDesc.dwFlags = DDSD_CAPS; surfaceDesc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; DDCHECK( (*BW::BWDATA_DDInterface)->CreateSurface(&surfaceDesc, BW::BWDATA_PrimarySurface, NULL) == DD_OK ); DDCHECK( (*BW::BWDATA_PrimarySurface)->SetPalette(*BW::BWDATA_PrimaryPalette) == DD_OK ); if ( (*BW::BWDATA_PrimarySurface)->Lock(NULL, &surfaceDesc, DDLOCK_WAIT, NULL) != DD_OK ) { memset(&surfaceDesc, 0, sizeof(DDSURFACEDESC)); surfaceDesc.dwSize = sizeof(DDSURFACEDESC); surfaceDesc.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS; surfaceDesc.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY | DDSCAPS_OFFSCREENPLAIN; surfaceDesc.dwWidth = width; surfaceDesc.dwHeight = height; DDCHECK( (*BW::BWDATA_DDInterface)->CreateSurface(&surfaceDesc, BW::BWDATA_BackSurface, NULL) == DD_OK ); } else { (*BW::BWDATA_PrimarySurface)->Unlock(&surfaceDesc); } SDrawManualInitialize(ghMainWnd, *BW::BWDATA_DDInterface, *BW::BWDATA_PrimarySurface, NULL, NULL, *BW::BWDATA_BackSurface, *BW::BWDATA_PrimaryPalette, NULL); }
static void register_fake_dll( const WCHAR *name, const void *data, size_t size ) { static const WCHAR atlW[] = {'a','t','l','.','d','l','l',0}; static const WCHAR moduleW[] = {'M','O','D','U','L','E',0}; static const WCHAR regtypeW[] = {'W','I','N','E','_','R','E','G','I','S','T','R','Y',0}; static const WCHAR manifestW[] = {'W','I','N','E','_','M','A','N','I','F','E','S','T',0}; const IMAGE_RESOURCE_DIRECTORY *resdir; LDR_RESOURCE_INFO info; HRESULT hr = S_OK; HMODULE module = (HMODULE)((ULONG_PTR)data | 1); HRSRC rsrc; if ((rsrc = FindResourceW( module, manifestW, MAKEINTRESOURCEW(RT_MANIFEST) ))) { char *manifest = LoadResource( module, rsrc ); register_manifest( name, manifest, SizeofResource( module, rsrc ), data, size ); } info.Type = (ULONG_PTR)regtypeW; if (LdrFindResourceDirectory_U( module, &info, 1, &resdir )) return; if (!registrar) { /* create the object by hand since we can't guarantee that atl and ole32 are registered */ IClassFactory *cf; HRESULT (WINAPI *pDllGetClassObject)( REFCLSID clsid, REFIID iid, LPVOID *ppv ); HMODULE atl = LoadLibraryW( atlW ); if ((pDllGetClassObject = (void *)GetProcAddress( atl, "DllGetClassObject" ))) { hr = pDllGetClassObject( &CLSID_Registrar, &IID_IClassFactory, (void **)&cf ); if (SUCCEEDED( hr )) { hr = IClassFactory_CreateInstance( cf, NULL, &IID_IRegistrar, (void **)®istrar ); IClassFactory_Release( cf ); } } if (!registrar) { ERR( "failed to create IRegistrar: %x\n", hr ); return; } } TRACE( "registering %s\n", debugstr_w(name) ); IRegistrar_ClearReplacements( registrar ); IRegistrar_AddReplacement( registrar, moduleW, name ); EnumResourceNamesW( module, regtypeW, register_resource, (LONG_PTR)&hr ); if (FAILED(hr)) ERR( "failed to register %s: %x\n", debugstr_w(name), hr ); }
static void set_app_id(LPWSTR app_id) { HMODULE shell32; HRESULT (*set_app_id)(LPWSTR app_id); shell32 = LoadLibrary(L"shell32.dll"); if (!shell32) return; set_app_id = (void *) GetProcAddress(shell32, "SetCurrentProcessExplicitAppUserModelID"); if (!set_app_id) return; if (!SUCCEEDED(set_app_id(app_id))) print_error(L"warning: could not set app ID", GetLastError()); }
void gfx_set_dwm(void) { static bool inited = false; if (inited) return; inited = true; dwmlib = dylib_load("dwmapi.dll"); if (!dwmlib) { RARCH_LOG("Did not find dwmapi.dll.\n"); return; } atexit(gfx_dwm_shutdown); HRESULT (WINAPI *mmcss)(BOOL) = (HRESULT (WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS"); if (mmcss) { RARCH_LOG("Setting multimedia scheduling for DWM.\n"); mmcss(TRUE); } if (!g_settings.video.disable_composition) return; HRESULT (WINAPI *composition_enable)(UINT) = (HRESULT (WINAPI*)(UINT))dylib_proc(dwmlib, "DwmEnableComposition"); if (!composition_enable) { RARCH_ERR("Did not find DwmEnableComposition ...\n"); return; } HRESULT ret = composition_enable(0); if (FAILED(ret)) RARCH_ERR("Failed to set composition state ...\n"); }
static BOOL install_cab(LPCWSTR file_name) { HMODULE advpack; char install_dir[MAX_PATH]; HRESULT (WINAPI *pExtractFilesA)(LPCSTR,LPCSTR,DWORD,LPCSTR,LPVOID,DWORD); LPSTR file_name_a; DWORD res; HRESULT hres; static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0}; TRACE("(%s)\n", debugstr_w(file_name)); GetWindowsDirectoryA(install_dir, sizeof(install_dir)); strcat(install_dir, "\\gecko\\"); res = CreateDirectoryA(install_dir, NULL); if(!res && GetLastError() != ERROR_ALREADY_EXISTS) { ERR("Could not create directory: %08u\n", GetLastError()); return FALSE; } strcat(install_dir, GECKO_VERSION); res = CreateDirectoryA(install_dir, NULL); if(!res && GetLastError() != ERROR_ALREADY_EXISTS) { ERR("Could not create directory: %08u\n", GetLastError()); return FALSE; } advpack = LoadLibraryW(wszAdvpack); pExtractFilesA = (void *)GetProcAddress(advpack, "ExtractFiles"); /* FIXME: Use unicode version (not yet implemented) */ file_name_a = heap_strdupWtoA(file_name); hres = pExtractFilesA(file_name_a, install_dir, 0, NULL, NULL, 0); FreeLibrary(advpack); heap_free(file_name_a); if(FAILED(hres)) { ERR("Could not extract package: %08x\n", hres); clean_up(); return FALSE; } set_registry(install_dir); clean_up(); return TRUE; }
static bool gfx_init_dwm(void) { HRESULT (WINAPI *mmcss)(BOOL); static bool inited = false; if (inited) return true; atexit(gfx_dwm_shutdown); #ifdef HAVE_DYNAMIC shell32lib = dylib_load("shell32.dll"); if (!shell32lib) { RARCH_WARN("Did not find shell32.dll.\n"); } dwmlib = dylib_load("dwmapi.dll"); if (!dwmlib) { RARCH_WARN("Did not find dwmapi.dll.\n"); return false; } DragAcceptFiles_func = (VOID (WINAPI*)(HWND, BOOL))dylib_proc(shell32lib, "DragAcceptFiles"); mmcss = (HRESULT(WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS"); #else DragAcceptFiles_func = DragAcceptFiles; #if 0 mmcss = DwmEnableMMCSS; #endif #endif if (mmcss) { RARCH_LOG("Setting multimedia scheduling for DWM.\n"); mmcss(TRUE); } inited = true; return true; }
static int FindDevicesCallback(vlc_object_t *object, char const *name, vlc_value_t newval, vlc_value_t oldval, void *data) { VLC_UNUSED(newval); VLC_UNUSED(oldval); VLC_UNUSED(data); module_config_t *item = config_FindConfig(object, name); if (!item) return VLC_SUCCESS; /* Clear-up the current list */ if (item->i_list > 0) { int i; /* Keep the first entry */ for (i = 1; i < item->i_list; i++) { free(item->ppsz_list[i]); free(item->ppsz_list_text[i]); } /* TODO: Remove when no more needed */ item->ppsz_list[i] = NULL; item->ppsz_list_text[i] = NULL; } item->i_list = 1; /* Load direct draw DLL */ HINSTANCE hddraw_dll = LoadLibrary(_T("DDRAW.DLL")); if (!hddraw_dll) return VLC_SUCCESS; /* Enumerate displays */ HRESULT (WINAPI *OurDirectDrawEnumerateEx)(LPDDENUMCALLBACKEXA, LPVOID, DWORD) = (void *)GetProcAddress(hddraw_dll, _T("DirectDrawEnumerateExA")); if (OurDirectDrawEnumerateEx) OurDirectDrawEnumerateEx(DirectXEnumCallback2, item, DDENUM_ATTACHEDSECONDARYDEVICES); FreeLibrary(hddraw_dll); /* Signal change to the interface */ item->b_dirty = true; return VLC_SUCCESS; }
//-------------------------------------------------------------------------------------------- // 関数名 : dsStop // 作成者 : 植山沙欧 // 作成日 : 2002.06.24 // 機能 : 再生中のバッファを停止します // 機能効果 : 「numBuffer」バッファのサウンドを停止します // 引数 : <入力> numBuffer 停止させたいバッファ番号 // 使用変数 : ありません // 使用関数 : IDirectSoundBuffer8::Stop // 戻り値 : IDirectSoundBuffer8::Stopの戻り値が返ります // 更新履歴 : 2002.06.24 Ver1.00 植山沙欧 機能の実現 //-------------------------------------------------------------------------------------------- HRESULT dsStop(int numBuffer) { if(!g_ds.sec_ptr[numBuffer]) { return HRESULT(0); } // g_sinfo[numBuffer].bStream = false; if (g_sinfo[numBuffer].bStream) { dsWriteMute(numBuffer, g_ds.dwBufferSize); g_sinfo[numBuffer].dwReadPosition = g_sinfo[numBuffer].dwHeaderSize; // 読みこんでいるファイルポジション g_sinfo[numBuffer].iStreamPos = 0; #ifdef DS_OGG_ENABLED dsoggSeekBegin(&g_sinfo[numBuffer].ovf); #endif } return g_ds.sec_ptr[numBuffer]->Stop(); }
HRESULT AFX_COM::GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { *ppv = NULL; HINSTANCE hInst = NULL; CString strCLSID = AfxStringFromCLSID(rclsid); CString strServer; if (!AfxGetInProcServer(strCLSID, strServer)) return REGDB_E_CLASSNOTREG; hInst = LoadLibrary(strServer); if (hInst == NULL) return REGDB_E_CLASSNOTREG; HRESULT (STDAPICALLTYPE* pfn)(REFCLSID rclsid, REFIID riid, LPVOID* ppv); pfn = (HRESULT (STDAPICALLTYPE*)(REFCLSID rclsid, REFIID riid, LPVOID* ppv)) GetProcAddress(hInst, "DllGetClassObject"); if (pfn != NULL) return pfn(rclsid, riid, ppv); return CO_E_ERRORINDLL; }
int D3D9_Create(vlc_object_t *o, d3d9_handle_t *hd3d) { hd3d->hdll = LoadLibrary(TEXT("D3D9.DLL")); if (!hd3d->hdll) { msg_Warn(o, "cannot load d3d9.dll, aborting"); return VLC_EGENERIC; } IDirect3D9 *(WINAPI *OurDirect3DCreate9)(UINT SDKVersion); OurDirect3DCreate9 = (void *)GetProcAddress(hd3d->hdll, "Direct3DCreate9"); if (!OurDirect3DCreate9) { msg_Err(o, "Cannot locate reference to Direct3DCreate9 ABI in DLL"); goto error; } HRESULT (WINAPI *OurDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex **ppD3D); OurDirect3DCreate9Ex = (void *)GetProcAddress(hd3d->hdll, "Direct3DCreate9Ex"); /* Create the D3D object. */ hd3d->use_ex = false; if (OurDirect3DCreate9Ex) { HRESULT hr = OurDirect3DCreate9Ex(D3D_SDK_VERSION, &hd3d->objex); if(!FAILED(hr)) { msg_Dbg(o, "Using Direct3D9 Extended API!"); hd3d->use_ex = true; } } if (!hd3d->obj) { hd3d->obj = OurDirect3DCreate9(D3D_SDK_VERSION); if (!hd3d->obj) { msg_Err(o, "Could not create Direct3D9 instance."); goto error; } } return VLC_SUCCESS; error: D3D9_Destroy( hd3d ); return VLC_EGENERIC; }
//Laddar BlendMap från RAW-fil void BlendMap::Load(std::string filename, int Width, int Height) { m_Width = Width; m_Height = Height; m_Map = new XMFLOAT4*[Height]; for (int z = 0; z < Height; z++) m_Map[z] = new XMFLOAT4[Width]; std::vector<unsigned char> vertexHeights(4 * Width * Height); //Läser in data från fil. std::ifstream fin; fin.open(filename, std::ios_base::binary); if (!fin) HRESULT(E_FAIL); fin.read((char *)&vertexHeights[0], (std::streamsize)vertexHeights.size()); fin.close(); int k = 0; for (int z = 0; z < Height; z++) { //Inverterar data i Z axeln. int Z = Height - 1 - z; for (int x = 0; x < Width; x++) { float r = (float) vertexHeights[k]; //Rött värde för pixeln. float g = (float) vertexHeights[k + 1]; //Grönt värde för pixeln. float b = (float) vertexHeights[k + 2]; //Blått värde för pixeln. float a = (float) vertexHeights[k + 3]; //Alpha värde för pixeln. float sum = r + g + b + a; //Summan av färgkomponenterna för pixeln. r = r / sum; //Andel rött i pixeln. g = g / sum; //Andel grönt i pixeln. b = b / sum; //Andel blått i pixeln. a = a / sum; //Andel alpha i pixeln. m_Map[Z][x] = XMFLOAT4(r,g,b, a); //Sparar värderna. k += 4; //Räknar fram. } } }
BOOL IsCompositionEnabled() { // check Composition is Enabled BOOL bCompositionEnabled = false; if (IsWinVistaOrLater()) { HRESULT (__stdcall * pDwmIsCompositionEnabled)(__out BOOL* pfEnabled); pDwmIsCompositionEnabled = NULL; HMODULE hDWMAPI = LoadLibrary(L"dwmapi.dll"); if (hDWMAPI) { (FARPROC &)pDwmIsCompositionEnabled = GetProcAddress(hDWMAPI, "DwmIsCompositionEnabled"); if (pDwmIsCompositionEnabled) { pDwmIsCompositionEnabled(&bCompositionEnabled); } FreeLibrary(hDWMAPI); } } return bCompositionEnabled; }
static void test_CLSIDFromProgIDWrap(void) { HRESULT (WINAPI *pCLSIDFromProgIDWrap)(LPCOLESTR,LPCLSID); CLSID clsid = IID_NULL; HRESULT hres; static const WCHAR wszStdPicture[] = {'S','t','d','P','i','c','t','u','r','e',0}; pCLSIDFromProgIDWrap = (void*)GetProcAddress(hShlwapi,(char*)435); hres = pCLSIDFromProgIDWrap(wszStdPicture, &clsid); ok(hres == S_OK, "CLSIDFromProgIDWrap failed: %08x\n", hres); ok(IsEqualGUID(&CLSID_StdPicture, &clsid), "wrong clsid\n"); hres = pCLSIDFromProgIDWrap(NULL, &clsid); ok(hres == E_INVALIDARG, "CLSIDFromProgIDWrap failed: %08x, expected E_INVALIDARG\n", hres); hres = pCLSIDFromProgIDWrap(wszStdPicture, NULL); ok(hres == E_INVALIDARG, "CLSIDFromProgIDWrap failed: %08x, expected E_INVALIDARG\n", hres); }
int InitDirectDraw(void) { HRESULT result; HRESULT (WINAPI *aDirectDrawCreate)(GUID *, LPDIRECTDRAW *, IUnknown *); HRESULT (WINAPI *aDirectDrawEnumerate)(LPDDENUMCALLBACK, LPVOID); DDCAPS ddcaps; hDDrawDLL = LoadLibrary("DDRAW.DLL"); if (!hDDrawDLL) { fprintf(output, "Failed loading DDRAW.DLL\n"); return -1; } aDirectDrawEnumerate = (void *)GetProcAddress(hDDrawDLL, "DirectDrawEnumerateA"); if (!aDirectDrawEnumerate) { fprintf(output, "Error fetching DirectDrawEnumerate\n"); return -1; } aDirectDrawCreate = (void *)GetProcAddress(hDDrawDLL, "DirectDrawCreate"); if (!aDirectDrawCreate) { fprintf(output, "Error fetching DirectDrawCreate\n"); return -1; } result = aDirectDrawCreate(NULL, &lpDD, NULL); if (result != DD_OK) { fprintf(output, "DirectDrawCreate() failed (%d)\n", result); return -1; } return 0; }
//---------------------------------------------------------------------- HRESULT __stdcall CoCreateInstanceNoReg( LPCTSTR szDllName, IN REFCLSID rclsid, IUnknown* pUnkOuter, IN REFIID riid, OUT LPVOID FAR* ppv, OUT HMODULE *phMod) { // http://lallousx86.wordpress.com/2007/01/29/emulating-cocreateinstance/ HRESULT hr = REGDB_E_CLASSNOTREG; HMODULE hDll; do { hDll = LoadLibrary(szDllName); if ( hDll == NULL ) break; HRESULT (__stdcall *GetClassObject)(REFCLSID rclsid, REFIID riid, LPVOID FAR* ppv); *(FARPROC*)&GetClassObject = GetProcAddress(hDll, "DllGetClassObject"); if ( GetClassObject == NULL ) break; IClassFactory *pIFactory; hr = GetClassObject(rclsid, IID_IClassFactory, (LPVOID *)&pIFactory); if ( FAILED(hr) ) break; hr = pIFactory->CreateInstance(pUnkOuter, riid, ppv); pIFactory->Release(); } while (false); if ( FAILED(hr) && hDll != NULL ) FreeLibrary(hDll); else *phMod = hDll; return hr; }
/** * Get the shield icon for UAC. * * This method returns the small shield icon for UAC * on Vista and above. To be able to run this app also on * previous Windows versions, the function pointer to * SHGetStockIconInfo is obtained via GetProcAddress * (i.e. no link-time dependency). */ bool Win32Utils::getShieldIcon(wxBitmap &shieldBM) { HMODULE hShellDLL; HRESULT hr; bool isOK = true; HRESULT (CALLBACK* pfnSHGetStockIconInfo)(SHSTOCKICONID siid, UINT uFlags, SHSTOCKICONINFO *psii); hShellDLL = ::LoadLibraryW(L"shell32.dll"); if(hShellDLL == NULL) return false; (*(FARPROC*)&pfnSHGetStockIconInfo) = ::GetProcAddress(hShellDLL, "SHGetStockIconInfo"); if(pfnSHGetStockIconInfo) { SHSTOCKICONINFO stockInfo; stockInfo.cbSize = sizeof(SHSTOCKICONINFO); hr = pfnSHGetStockIconInfo(SIID_SHIELD, SHGSI_ICON | SHGSI_SMALLICON, &stockInfo); if(hr == S_OK) { wxIcon uacShieldIcon; #if wxCHECK_VERSION(2, 9, 0) uacShieldIcon.CreateFromHICON(stockInfo.hIcon); #endif shieldBM.CopyFromIcon(uacShieldIcon); ::DestroyIcon(stockInfo.hIcon); } else isOK = false; } else isOK = false; ::FreeLibrary(hShellDLL); return isOK; }