using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows; using cspl = LSWLib.CLog; namespace eDosStation { /// /// Interaction logic for App.xaml /// public partial class App : Application { [DllImport("kernel32.dll",CharSet =CharSet.Auto, EntryPoint = "LoadLibraryEx")] private static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hFile, uint dwFlags); public System.IntPtr moduleHandle; public bool TestOrCreateFolder(string fn) { bool rv = true; try { if (!System.IO.Directory.Exists(fn)) { if (System.IO.File.Exists(fn)) System.IO.File.Delete(fn); System.IO.Directory.CreateDirectory(fn); } } catch (System.Exception ex) { splunkLog.WriteException("App", "TestOrCreateFolder", ex); rv = false; } return rv; } public string eDosPort; public string elatecPort, elatecFirmware; public string RFIDReader; public cspl splunkLog; private void Application_Startup(object sender, StartupEventArgs e) { //var pth1 = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EpdBaseClr.dll"); //var pth2 = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Reader2.dll"); //moduleHandle = LoadLibraryEx(pth2, IntPtr.Zero, 0); //moduleHandle = LoadLibraryEx(pth1, IntPtr.Zero, 0); splunkLog = new cspl(Environment.MachineName, hourlyLog: true); using (var h = new LSWDevices.LSWDevicesHelper()) { eDosPort = h.eDosPort; elatecPort = h.ElatecPort; elatecFirmware = h.ElatecFirmware; RFIDReader = h.RFIDReader; } TestOrCreateFolder("c:/temp"); TestOrCreateFolder("c:/Logs"); } private void Application_Exit(object sender, ExitEventArgs e) { splunkLog.KvClear(); splunkLog?.CloseSplunkLog(); Application.Current.Shutdown(); //try //{ // Environment.Exit(0); //} //catch //{ //} } } }