/// <summary>
        /// Loads the steam library.
        /// </summary>
        /// <returns>A value indicating if the load was successful.</returns>
        public static bool LoadSteam()
        {
            if (SteamHandle != IntPtr.Zero)
            {
                return(true);
            }

            string path = GetInstallPath();

            if (!string.IsNullOrEmpty(path))
            {
                Native.SetDllDirectory(path + ";" + Path.Combine(path, "bin"));
            }

            path = Path.Combine(path, "steam.dll");

            IntPtr module = Native.LoadLibraryEx(path, IntPtr.Zero, Native.LOAD_WITH_ALTERED_SEARCH_PATH);

            if (module == IntPtr.Zero)
            {
                return(false);
            }

            CallCreateSteamInterface = Native.GetExportFunction <Native._f>(module, "_f");

            if (CallCreateSteamInterface == null)
            {
                return(false);
            }

            SteamHandle = module;

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Loads the steam library.
        /// </summary>
        /// <returns>A value indicating if the load was successful.</returns>
        public static bool LoadSteam()
        {
            if (SteamHandle != IntPtr.Zero)
            {
                return(true);
            }

            string path = GetInstallPath();

            if (!string.IsNullOrEmpty(path))
            {
                Native.SetDllDirectory(path + ";" + Path.Combine(path, "bin"));
            }

            if (Is64Bit())
            {
                throw new InvalidOperationException("Cannot load Steam library in 64-bit mode. No such library exists");
            }

            path = Path.Combine(path, "steam.dll");

            IntPtr module = Native.LoadLibraryEx(path, IntPtr.Zero, Native.LOAD_WITH_ALTERED_SEARCH_PATH);

            if (module == IntPtr.Zero)
            {
                return(false);
            }

            CallCreateSteamInterface = Native.GetExportFunction <Native._f>(module, "_f");

            if (CallCreateSteamInterface == null)
            {
                return(false);
            }

            SteamHandle = module;

            return(true);
        }