// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
//
//
// Provides access to unmanaged native methods.
//
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.Configuration
{
using System;
using System.Runtime.InteropServices;
///
/// Provides access to unmanaged native methods.
///
internal class NativeMethods
{
///
/// Loads the specified module into the address space of the calling process.
/// The specified module may cause other modules to be loaded.
///
///
/// The name of the module. This can be either a library module or
/// an executable module.
///
/// If the function succeeds, the return value is a handle to the module; otherwise null.
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr LoadLibrary(string libname);
///
/// Frees the loaded dynamic-link library (DLL) module and, if necessary, decrements its reference count.
/// When the reference count reaches zero, the module is unloaded from the address space of the calling
/// process and the handle is no longer valid.
///
/// A handle to the loaded library module.
/// The LoadLibrary, LoadLibraryEx, GetModuleHandle, or GetModuleHandleEx function returns this handle.
/// If the function succeeds, the return value is nonzero; otherwise zero.
[DllImport("kernel32", SetLastError = true)]
public static extern bool FreeLibrary(IntPtr hModule);
///
/// Loads the specified module into the address space of the calling process.
/// The specified module may cause other modules to be loaded.
///
///
/// The name of the module. This can be either a library module or
/// an executable module.
///
///
/// The flag indicating whether to load the library immediately or lazily.
///
///
/// If the function succeeds, the return value is a handle to the module; otherwise null.
///
[System.Runtime.InteropServices.DllImport("libdl")]
public static extern IntPtr dlopen(string libname, int flags);
///
/// Frees the loaded dynamic-link library (DLL) module and, if necessary, decrements its reference count.
/// When the reference count reaches zero, the module is unloaded from the address space of the calling
/// process and the handle is no longer valid.
///
/// A handle to the loaded library module.
/// The LoadLibrary, LoadLibraryEx, GetModuleHandle, or GetModuleHandleEx function returns this handle.
/// If the function succeeds, the return value is nonzero; otherwise zero.
[System.Runtime.InteropServices.DllImport("libdl")]
public static extern int dlclose(IntPtr hModule);
}
}