forked from jdhitsolutions/MySQLite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mySQLite.psm1
27 lines (20 loc) · 902 Bytes
/
mySQLite.psm1
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
#borrowing some code from https://github.com/TobiasPSP/ReallySimpleDatabase/blob/main/Modules/ReallySimpleDatabase/loadbinaries.ps1
$code = @'
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string dllToLoad);
[DllImport("kernel32.dll")]
public static extern bool FreeLibrary(IntPtr hModule);
'@
Add-Type -MemberDefinition $code -Namespace Internal -Name Helper
# pre-load the platform specific DLL version
$Path = "$PSScriptRoot\assembly\SQLite.Interop.dll"
[void]([Internal.Helper]::LoadLibrary($Path))
# next, load the .NET assembly. Since the Interop DLL is already
# pre-loaded, all is good:
Add-Type -Path "$PSScriptRoot\assembly\System.Data.SQLite.dll"
Get-ChildItem -Path $PSScriptRoot\functions\*.ps1 |
ForEach-Object {
. $_.FullName
}
#define a regex pattern to match database file extensions
#[regex]$rxExtension = "\.((sqlite(3)?)|(db(3)?)|(sl3)|(s3db))$"