1
0
mirror of https://github.com/DarthAffe/CUE.NET.git synced 2025-12-12 16:58:29 +00:00

Added two lists to modify the dative-dll-paths (#58)

This commit is contained in:
Darth Affe 2017-04-27 20:43:38 +02:00
parent 5cc1748461
commit 33bd76ef0a
2 changed files with 25 additions and 3 deletions

View File

@ -25,6 +25,18 @@ namespace CUE.NET
// ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable UnusedAutoPropertyAccessor.Global
/// <summary>
/// Gets a modifiable list of paths used to find the native SDK-dlls for x86 applications.
/// The first match will be used.
/// </summary>
public static List<string> PossibleX86NativePaths { get; } = new List<string> { "x86/CUESDK_2015.dll", "x86/CUESDK.dll" };
/// <summary>
/// Gets a modifiable list of paths used to find the native SDK-dlls for x64 applications.
/// The first match will be used.
/// </summary>
public static List<string> PossibleX64NativePaths { get; } = new List<string> { "x64/CUESDK_2015.dll", "x64/CUESDK.dll" };
/// <summary> /// <summary>
/// Indicates if the SDK is initialized and ready to use. /// Indicates if the SDK is initialized and ready to use.
/// </summary> /// </summary>

View File

@ -2,7 +2,9 @@
// ReSharper disable UnusedMember.Global // ReSharper disable UnusedMember.Global
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using CUE.NET.Devices.Generic.Enums; using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Exceptions; using CUE.NET.Exceptions;
@ -20,7 +22,7 @@ namespace CUE.NET.Native
/// Gets the loaded architecture (x64/x86). /// Gets the loaded architecture (x64/x86).
/// </summary> /// </summary>
internal static string LoadedArchitecture { get; private set; } internal static string LoadedArchitecture { get; private set; }
/// <summary> /// <summary>
/// Reloads the SDK. /// Reloads the SDK.
/// </summary> /// </summary>
@ -35,8 +37,16 @@ namespace CUE.NET.Native
if (_dllHandle != IntPtr.Zero) return; if (_dllHandle != IntPtr.Zero) return;
// HACK: Load library at runtime to support both, x86 and x64 with one managed dll // HACK: Load library at runtime to support both, x86 and x64 with one managed dll
string dllPath = (LoadedArchitecture = Environment.Is64BitProcess ? "x64" : "x86") + "/CUESDK_2015.dll"; List<string> possiblePathList = Environment.Is64BitProcess ? CueSDK.PossibleX64NativePaths : CueSDK.PossibleX86NativePaths;
if (!File.Exists(dllPath)) throw new WrapperException($"Can't find the CUE-SDK at the expected location '{Path.GetFullPath(dllPath)}'"); string dllPath = null;
foreach (string path in possiblePathList)
if (File.Exists(path))
{
dllPath = path;
break;
}
if (dllPath == null) throw new WrapperException($"Can't find the CUE-SDK at one of the expected locations:\r\n '{string.Join("\r\n", possiblePathList.Select(Path.GetFullPath))}'");
_dllHandle = LoadLibrary(dllPath); _dllHandle = LoadLibrary(dllPath);