This commit is contained in:
Frank Skare
2019-03-23 15:42:57 +01:00
parent f2c526348d
commit e7d41ff626
6 changed files with 68 additions and 37 deletions

View File

@@ -1,4 +1,6 @@
using System;
using System.IO;
using System.Text;
namespace mpvnet
{
@@ -34,5 +36,25 @@ namespace mpvnet
{
Native.AdjustWindowRect(ref rc, (uint)Native.GetWindowLongPtrW(hwnd, -16 /* GWL_STYLE */), false);
}
public static string GetAssociatedApplication(string ext)
{
uint returnValue = 0U;
// ASSOCF_VERIFY, ASSOCSTR_EXECUTABLE
if (1 == Native.AssocQueryString(0x40, 2, ext, null, null, ref returnValue))
{
if (returnValue > 0)
{
StringBuilder sb = new StringBuilder(Convert.ToInt32(returnValue));
// ASSOCF_VERIFY, ASSOCSTR_EXECUTABLE
if (0 == Native.AssocQueryString(0x40, 2, ext, null, sb, ref returnValue))
{
var ret = sb.ToString();
if (File.Exists(ret)) return ret;
}
}
}
return "";
}
}
}