summaryrefslogtreecommitdiffstats
path: root/win/tkWinDialog.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-01-08 16:44:26 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-01-08 16:44:26 (GMT)
commit2b441609377c94239f63346bf28b92db53c36a42 (patch)
treef89210a6d43fbef8a40a75b052f6486e9bd8ab40 /win/tkWinDialog.c
parent21608e25015bc36738583d973e82ac02b61765ed (diff)
downloadtk-2b441609377c94239f63346bf28b92db53c36a42.zip
tk-2b441609377c94239f63346bf28b92db53c36a42.tar.gz
tk-2b441609377c94239f63346bf28b92db53c36a42.tar.bz2
TIP #592 implementation: Stop support for Windows XP, Server 2003, Vista, Server 2008
Diffstat (limited to 'win/tkWinDialog.c')
-rw-r--r--win/tkWinDialog.c104
1 files changed, 22 insertions, 82 deletions
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c
index 331a7d6..7ff69a3 100644
--- a/win/tkWinDialog.c
+++ b/win/tkWinDialog.c
@@ -590,63 +590,7 @@ static UINT APIENTRY OFNHookProc(HWND hdlg, UINT uMsg, WPARAM wParam,
static LRESULT CALLBACK MsgBoxCBTProc(int nCode, WPARAM wParam, LPARAM lParam);
static void SetTkDialog(ClientData clientData);
static const char *ConvertExternalFilename(LPCWSTR, Tcl_DString *);
-static void LoadShellProcs(void);
-
-/* Definitions of dynamically loaded Win32 calls */
-typedef HRESULT (STDAPICALLTYPE SHCreateItemFromParsingNameProc)(
- PCWSTR pszPath, IBindCtx *pbc, REFIID riid, void **ppv);
-struct ShellProcPointers {
- SHCreateItemFromParsingNameProc *SHCreateItemFromParsingName;
-} ShellProcs;
-
-
-/*
- *-------------------------------------------------------------------------
- *
- * LoadShellProcs --
- *
- * Some shell functions are not available on older versions of
- * Windows. This function dynamically loads them and stores pointers
- * to them in ShellProcs. Any function that is not available has
- * the corresponding pointer set to NULL.
- *
- * Note this call never fails. Unavailability of a function is not
- * a reason for failure. Caller should check whether a particular
- * function pointer is NULL or not. Once loaded a function stays
- * forever loaded.
- *
- * XXX - we load the function pointers into global memory. This implies
- * there is a potential (however small) for race conditions between
- * threads. However, Tk is in any case meant to be loaded in exactly
- * one thread so this should not be an issue and saves us from
- * unnecessary bookkeeping.
- *
- * Return value:
- * None.
- *
- * Side effects:
- * ShellProcs is populated.
- *-------------------------------------------------------------------------
- */
-static void LoadShellProcs(void)
-{
- static HMODULE shell32_handle = NULL;
-
- if (shell32_handle != NULL) {
- return; /* We have already been through here. */
- }
-
- shell32_handle = GetModuleHandleW(L"shell32.dll");
- if (shell32_handle == NULL) { /* Should never happen but check anyways. */
- return;
- }
-
- ShellProcs.SHCreateItemFromParsingName = (SHCreateItemFromParsingNameProc*)
- (void *)GetProcAddress(shell32_handle, "SHCreateItemFromParsingName");
-}
-
-
/*
*-------------------------------------------------------------------------
*
@@ -1071,7 +1015,7 @@ ParseOFNOptions(
};
static const struct Options dirOptions[] = {
{"-initialdir", FILE_INITDIR},
- {"-mustexist", FILE_MUSTEXIST},
+ {"-mustexist", FILE_MUSTEXIST},
{"-parent", FILE_PARENT},
{"-title", FILE_TITLE},
{NULL, FILE_DEFAULT/*ignored*/ }
@@ -1211,30 +1155,26 @@ static int VistaFileDialogsAvailable(void)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (tsdPtr->newFileDialogsState == FDLG_STATE_INIT) {
- tsdPtr->newFileDialogsState = FDLG_STATE_USE_OLD;
- LoadShellProcs();
- if (ShellProcs.SHCreateItemFromParsingName != NULL) {
- hr = CoInitialize(0);
- /* XXX - need we schedule CoUninitialize at thread shutdown ? */
-
- /* Ensure all COM interfaces we use are available */
- if (SUCCEEDED(hr)) {
- hr = CoCreateInstance(&ClsidFileOpenDialog, NULL,
- CLSCTX_INPROC_SERVER, &IIDIFileOpenDialog, (void **) &fdlgPtr);
- if (SUCCEEDED(hr)) {
- fdlgPtr->lpVtbl->Release(fdlgPtr);
- hr = CoCreateInstance(&ClsidFileSaveDialog, NULL,
- CLSCTX_INPROC_SERVER, &IIDIFileSaveDialog,
- (void **) &fdlgPtr);
- if (SUCCEEDED(hr)) {
- fdlgPtr->lpVtbl->Release(fdlgPtr);
-
- /* Looks like we have all we need */
- tsdPtr->newFileDialogsState = FDLG_STATE_USE_NEW;
- }
- }
- }
- }
+ tsdPtr->newFileDialogsState = FDLG_STATE_USE_OLD;
+ hr = CoInitialize(0);
+ /* XXX - need we schedule CoUninitialize at thread shutdown ? */
+
+ /* Ensure all COM interfaces we use are available */
+ if (SUCCEEDED(hr)) {
+ hr = CoCreateInstance(&ClsidFileOpenDialog, NULL,
+ CLSCTX_INPROC_SERVER, &IIDIFileOpenDialog, (void **) &fdlgPtr);
+ if (SUCCEEDED(hr)) {
+ fdlgPtr->lpVtbl->Release(fdlgPtr);
+ hr = CoCreateInstance(&ClsidFileSaveDialog, NULL,
+ CLSCTX_INPROC_SERVER, &IIDIFileSaveDialog, (void **) &fdlgPtr);
+ if (SUCCEEDED(hr)) {
+ fdlgPtr->lpVtbl->Release(fdlgPtr);
+
+ /* Looks like we have all we need */
+ tsdPtr->newFileDialogsState = FDLG_STATE_USE_NEW;
+ }
+ }
+ }
}
return (tsdPtr->newFileDialogsState == FDLG_STATE_USE_NEW);
@@ -1413,7 +1353,7 @@ static int GetFileNameVista(Tcl_Interp *interp, OFNOpts *optsPtr,
Tcl_IncrRefCount(normPath);
nativePath = (LPCWSTR)Tcl_FSGetNativePath(normPath); /* Points INTO normPath*/
if (nativePath) {
- hr = ShellProcs.SHCreateItemFromParsingName(
+ hr = SHCreateItemFromParsingName(
nativePath, NULL,
&IIDIShellItem, (void **) &dirIf);
if (SUCCEEDED(hr)) {