mirror of
https://github.com/mpv-player/mpv
synced 2025-04-01 14:50:07 +00:00
win32: implement shell link target resolving
Adds a function to resolve the target of a shell link (Windows shortcut) for use by other parts of mpv.
This commit is contained in:
parent
3e7d36c295
commit
d2bbd7a531
@ -24,9 +24,12 @@
|
|||||||
#include <audioclient.h>
|
#include <audioclient.h>
|
||||||
#include <d3d9.h>
|
#include <d3d9.h>
|
||||||
#include <dxgi1_2.h>
|
#include <dxgi1_2.h>
|
||||||
|
#include <ole2.h>
|
||||||
|
#include <shobjidl.h>
|
||||||
|
|
||||||
#include "common/common.h"
|
#include "common/common.h"
|
||||||
#include "windows_utils.h"
|
#include "windows_utils.h"
|
||||||
|
#include "mpv_talloc.h"
|
||||||
|
|
||||||
char *mp_GUID_to_str_buf(char *buf, size_t buf_size, const GUID *guid)
|
char *mp_GUID_to_str_buf(char *buf, size_t buf_size, const GUID *guid)
|
||||||
{
|
{
|
||||||
@ -227,3 +230,22 @@ error:
|
|||||||
*server = *client = INVALID_HANDLE_VALUE;
|
*server = *client = INVALID_HANDLE_VALUE;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wchar_t *mp_w32_get_shell_link_target(wchar_t *path)
|
||||||
|
{
|
||||||
|
IShellLink *psl = NULL;
|
||||||
|
IPersistFile *ppf = NULL;
|
||||||
|
wchar_t *buf = talloc_array(NULL, wchar_t, MAX_PATH + 1);
|
||||||
|
|
||||||
|
if (FAILED(CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLinkW, (void**)&psl)) ||
|
||||||
|
FAILED(IShellLinkW_QueryInterface(psl, &IID_IPersistFile, (void**)&ppf)) ||
|
||||||
|
FAILED(IPersistFile_Load(ppf, path, STGM_READ)) ||
|
||||||
|
FAILED(IShellLinkW_GetPath(psl, buf, MAX_PATH, NULL, 0)))
|
||||||
|
{
|
||||||
|
TA_FREEP(&buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
SAFE_RELEASE(psl);
|
||||||
|
SAFE_RELEASE(ppf);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
@ -46,4 +46,8 @@ struct w32_create_anon_pipe_opts {
|
|||||||
bool mp_w32_create_anon_pipe(HANDLE *server, HANDLE *client,
|
bool mp_w32_create_anon_pipe(HANDLE *server, HANDLE *client,
|
||||||
struct w32_create_anon_pipe_opts *opts);
|
struct w32_create_anon_pipe_opts *opts);
|
||||||
|
|
||||||
|
// Returns the target of the shell link in talloc memory if the path is a
|
||||||
|
// resolvable shell link, otherwise returns NULL.
|
||||||
|
wchar_t *mp_w32_get_shell_link_target(wchar_t *path);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user