From 1c3d31828c5596e5980832dd3c1b8dc9caa71035 Mon Sep 17 00:00:00 2001 From: OV2 Date: Sat, 13 Nov 2010 20:38:33 +0100 Subject: [PATCH] Dynamically bind to SHCreateItemFromParsingName SHCreateItemFromParsingName requires a windows version >= vista. It's only needed for the jumplist, so we'll look for it dynamically. --- win32/rsrc/snes9x.rc | 2 +- win32/wsnes9x.cpp | 25 +++++++++++++++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/win32/rsrc/snes9x.rc b/win32/rsrc/snes9x.rc index 7c42fbd0..d94b2924 100644 --- a/win32/rsrc/snes9x.rc +++ b/win32/rsrc/snes9x.rc @@ -180,7 +180,7 @@ FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN DEFPUSHBUTTON "OK",IDOK,239,237,50,14 PUSHBUTTON "Cancel",IDCANCEL,296,237,50,14 - COMBOBOX IDC_OUTPUTMETHOD,68,17,101,38,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_OUTPUTMETHOD,68,17,101,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Fullscreen",IDC_FULLSCREEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,36,48,10 CONTROL "Emulate Fullscreen",IDC_EMUFULLSCREEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,47,75,10 CONTROL "Stretch Image",IDC_STRETCH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,58,60,10 diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp index 205bf2f6..5b230563 100644 --- a/win32/wsnes9x.cpp +++ b/win32/wsnes9x.cpp @@ -4032,10 +4032,23 @@ void S9xRemoveFromRecentGames (int i) } #ifdef UNICODE + +/* OV2: We need dynamic binding to this function as it is not present in + windows versions < vista. Since the jumplist is a win7 feature this + is not a problem. +*/ +typedef HRESULT (STDAPICALLTYPE *SHCIFPN) (__in PCWSTR pszPath, __in_opt IBindCtx *pbc, __in REFIID riid, __deref_out void **ppv); + HRESULT Win7_JLSetRecentGames(ICustomDestinationList *pcdl, IObjectArray *poaRemoved, UINT maxSlots) { IObjectCollection *poc; - HRESULT hr = CoCreateInstance + + HMODULE S32dll = GetModuleHandle(TEXT("shell32.dll")); + SHCIFPN SHCreateIFPN = (SHCIFPN)GetProcAddress(S32dll,"SHCreateItemFromParsingName"); + if(!SHCreateIFPN) { + return S_FALSE; + } + HRESULT hr = CoCreateInstance (CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC_SERVER, @@ -4044,7 +4057,7 @@ HRESULT Win7_JLSetRecentGames(ICustomDestinationList *pcdl, IObjectArray *poaRem UINT max_list = MIN(maxSlots,GUI.MaxRecentGames); for (UINT i = 0; i < max_list && *GUI.RecentGames[i]; i++) { IShellItem *psi; - if(SUCCEEDED(SHCreateItemFromParsingName(GUI.RecentGames[i],NULL,IID_PPV_ARGS(&psi)))) { + if(SUCCEEDED(SHCreateIFPN(GUI.RecentGames[i],NULL,IID_PPV_ARGS(&psi)))) { hr = poc->AddObject(psi); psi->Release(); } @@ -7209,10 +7222,10 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hDlg; - ofn.lpstrFilter = TEXT("Effect Files\0*.fx\0All Files\0*.*\0\0"); + ofn.lpstrFilter = TEXT("Shader Files\0*.shader\0All Files\0*.*\0\0"); ofn.lpstrFile = openFileName; ofn.lpstrTitle = TEXT("Select Shader"); - ofn.lpstrDefExt = TEXT("fx"); + ofn.lpstrDefExt = TEXT("shader"); ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; if(GetOpenFileName(&ofn)) { @@ -7228,10 +7241,10 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hDlg; - ofn.lpstrFilter = TEXT("All Files\0*.*\0\0"); + ofn.lpstrFilter = TEXT("Shader Files\0*.shader\0All Files\0*.*\0\0"); ofn.lpstrFile = openFileName; ofn.lpstrTitle = TEXT("Select Shader"); - ofn.lpstrDefExt = TEXT("*.*"); + ofn.lpstrDefExt = TEXT("shader"); ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; if(GetOpenFileName(&ofn)) {