58 lines
2.0 KiB
C#
58 lines
2.0 KiB
C#
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.IO;
|
|
|
|
namespace Vav1Player
|
|
{
|
|
public static class DllChecker
|
|
{
|
|
[DllImport("kernel32.dll", SetLastError = true)]
|
|
private static extern IntPtr LoadLibrary(string dllToLoad);
|
|
|
|
[DllImport("kernel32.dll", SetLastError = true)]
|
|
private static extern bool FreeLibrary(IntPtr hModule);
|
|
|
|
public static bool CheckDav1dDll()
|
|
{
|
|
string dllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dav1d.dll");
|
|
|
|
if (!File.Exists(dllPath))
|
|
{
|
|
System.Diagnostics.Debug.WriteLine($"dav1d.dll not found at: {dllPath}");
|
|
return false;
|
|
}
|
|
|
|
IntPtr handle = LoadLibrary(dllPath);
|
|
if (handle == IntPtr.Zero)
|
|
{
|
|
int error = Marshal.GetLastWin32Error();
|
|
System.Diagnostics.Debug.WriteLine($"Failed to load dav1d.dll. Win32 error: {error}");
|
|
return false;
|
|
}
|
|
|
|
FreeLibrary(handle);
|
|
System.Diagnostics.Debug.WriteLine("dav1d.dll loaded successfully");
|
|
return true;
|
|
}
|
|
|
|
public static string GetDiagnosticInfo()
|
|
{
|
|
string info = $"Application Base Directory: {AppDomain.CurrentDomain.BaseDirectory}\n";
|
|
string dllPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "dav1d.dll");
|
|
info += $"Expected DLL Path: {dllPath}\n";
|
|
info += $"DLL Exists: {File.Exists(dllPath)}\n";
|
|
|
|
if (File.Exists(dllPath))
|
|
{
|
|
var fileInfo = new FileInfo(dllPath);
|
|
info += $"DLL Size: {fileInfo.Length} bytes\n";
|
|
info += $"DLL Modified: {fileInfo.LastWriteTime}\n";
|
|
}
|
|
|
|
info += $"Process Architecture: {(Environment.Is64BitProcess ? "x64" : "x86")}\n";
|
|
info += $"OS Architecture: {(Environment.Is64BitOperatingSystem ? "x64" : "x86")}\n";
|
|
|
|
return info;
|
|
}
|
|
}
|
|
} |