summaryrefslogtreecommitdiffstats
path: root/osdep/windows_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'osdep/windows_utils.c')
-rw-r--r--osdep/windows_utils.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/osdep/windows_utils.c b/osdep/windows_utils.c
index a647e9f00d..91eef62cb8 100644
--- a/osdep/windows_utils.c
+++ b/osdep/windows_utils.c
@@ -15,18 +15,21 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <stdio.h>
#include <inttypes.h>
+#include <stdatomic.h>
+#include <stdio.h>
#include <windows.h>
#include <errors.h>
#include <audioclient.h>
#include <d3d9.h>
#include <dxgi1_2.h>
+#include <ole2.h>
+#include <shobjidl.h>
#include "common/common.h"
-#include "osdep/atomic.h"
#include "windows_utils.h"
+#include "mpv_talloc.h"
char *mp_GUID_to_str_buf(char *buf, size_t buf_size, const GUID *guid)
{
@@ -164,7 +167,7 @@ char *mp_HRESULT_to_str_buf(char *buf, size_t buf_size, HRESULT hr)
bool mp_w32_create_anon_pipe(HANDLE *server, HANDLE *client,
struct w32_create_anon_pipe_opts *opts)
{
- static atomic_ulong counter = ATOMIC_VAR_INIT(0);
+ static atomic_ulong counter = 0;
// Generate pipe name
unsigned long id = atomic_fetch_add(&counter, 1);
@@ -227,3 +230,22 @@ error:
*server = *client = INVALID_HANDLE_VALUE;
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;
+}