-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNativeMethods.cs
More file actions
51 lines (39 loc) · 1.5 KB
/
NativeMethods.cs
File metadata and controls
51 lines (39 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// @(#) SafeNativeMethods.cs
//
// Project: usis.Data.LocalDb
// System: Microsoft Visual Studio 2022
// Author: Udo Schäfer
//
// Copyright (c) 2018-2023 usis GmbH. All rights reserved.
using System;
using System.Runtime.InteropServices;
namespace usis.Data.LocalDb
{
// -----------------------
// SafeNativeMethods class
// -----------------------
internal static class NativeMethods
{
#region constants
private const string KernelFileName = "kernel32.dll";
#endregion
// --------------------
// LoadLibraryEx method
// --------------------
[DllImport(KernelFileName, SetLastError = true, CharSet = CharSet.Unicode)]
internal static extern IntPtr LoadLibraryEx(string fileName, IntPtr reserved, uint flags);
// ------------------
// FreeLibrary method
// ------------------
[DllImport(KernelFileName, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool FreeLibrary(IntPtr module);
// ---------------------
// GetProcAddress method
// ---------------------
[DllImport(KernelFileName, SetLastError = true, BestFitMapping = false, ThrowOnUnmappableChar = true)]
internal static extern IntPtr GetProcAddress(NativeLibraryHandle handle, [MarshalAs(UnmanagedType.LPStr)] string procName);
}
}
// eof "SafeNativeMethods.cs"