+bool wxFileName::GetShortcutTarget(const wxString& shortcutPath, wxString& targetFilename, wxString* arguments)
+{
+ wxString path, file, ext;
+ wxSplitPath(shortcutPath, & path, & file, & ext);
+
+ HRESULT hres;
+ IShellLink* psl;
+ bool success = false;
+
+ // Assume it's not a shortcut if it doesn't end with lnk
+ if (ext.CmpNoCase(wxT("lnk"))!=0)
+ return false;
+
+ // create a ShellLink object
+ hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
+ IID_IShellLink, (LPVOID*) &psl);
+
+ if (SUCCEEDED(hres))
+ {
+ IPersistFile* ppf;
+ hres = psl->QueryInterface( IID_IPersistFile, (LPVOID *) &ppf);
+ if (SUCCEEDED(hres))
+ {
+ WCHAR wsz[MAX_PATH];
+
+ MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, shortcutPath.mb_str(), -1, wsz,
+ MAX_PATH);
+
+ hres = ppf->Load(wsz, 0);
+ if (SUCCEEDED(hres))
+ {
+ wxChar buf[2048];
+ // Wrong prototype in early versions
+#if defined(__MINGW32__) && !wxCHECK_W32API_VERSION(2, 2)
+ psl->GetPath((CHAR*) buf, 2048, NULL, SLGP_UNCPRIORITY);
+#else
+ psl->GetPath(buf, 2048, NULL, SLGP_UNCPRIORITY);
+#endif
+ targetFilename = wxString(buf);
+ success = (shortcutPath != targetFilename);
+
+ psl->GetArguments(buf, 2048);
+ wxString args(buf);
+ if (!args.empty() && arguments)
+ {
+ *arguments = args;
+ }
+ }
+ }
+ }
+ psl->Release();
+ return success;