private static void LoadDll() { if (!_dllInitialized) { _dllInitialized = true; _aviCreateLib = Kernel32.LoadLibrary("AviCreate.DLL"); if (_aviCreateLib == IntPtr.Zero) { Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error()); } _buildAccountRecords = (BuildAccountRecordsDelegate)Load <BuildAccountRecordsDelegate>("BuildAccountRecords"); _buildAnimalRecords = (BuildAnimalRecordsDelegate)Load <BuildAnimalRecordsDelegate>("BuildAnimalRecords"); _buildAppointRecords = (BuildAppointRecordsDelegate)Load <BuildAppointRecordsDelegate>("BuildAppointRecords"); _buildAttachRecords = (BuildAttachRecordsDelegate)Load <BuildAttachRecordsDelegate>("BuildAttachRecords"); _buildAuditRecords = (BuildAuditRecordsDelegate)Load <BuildAuditRecordsDelegate>("BuildAuditRecords"); _buildClientRecords = (BuildClientRecordsDelegate)Load <BuildClientRecordsDelegate>("BuildClientRecords"); _buildDiagnoseRecords = (BuildDiagnoseRecordsDelegate)Load <BuildDiagnoseRecordsDelegate>("BuildDiagnoseRecords"); _buildEntryRecords = (BuildEntryRecordsDelegate)Load <BuildEntryRecordsDelegate>("BuildEntryRecords"); _buildFollowRecords = (BuildFollowRecordsDelegate)Load <BuildFollowRecordsDelegate>("BuildFollowRecords"); _buildItemRecords = (BuildItemRecordsDelegate)Load <BuildItemRecordsDelegate>("BuildItemRecords"); _buildLabRecords = (BuildLabRecordsDelegate)Load <BuildLabRecordsDelegate>("BuildLabRecords"); _buildMedicalRecords = (BuildMedicalRecordsDelegate)Load <BuildMedicalRecordsDelegate>("BuildMedicalRecords"); _buildPoRecords = (BuildPoRecordsDelegate)Load <BuildPoRecordsDelegate>("BuildPoRecords"); _buildPrescripRecords = (BuildPrescripRecordsDelegate)Load <BuildPrescripRecordsDelegate>("BuildPrescripRecords"); _buildPriceRecords = (BuildPriceRecordsDelegate)Load <BuildPriceRecordsDelegate>("BuildPriceRecords"); _buildProblemRecords = (BuildProblemRecordsDelegate)Load <BuildProblemRecordsDelegate>("BuildProblemRecords"); _buildQuotailRecords = (BuildQuotailRecordsDelegate)Load <BuildQuotailRecordsDelegate>("BuildQuotailRecords"); _buildQuoteRecords = (BuildQuoteRecordsDelegate)Load <BuildQuoteRecordsDelegate>("BuildQuoteRecords"); _buildReminderRecords = (BuildReminderRecordsDelegate)Load <BuildReminderRecordsDelegate>("BuildReminderRecords"); _buildServiceRecords = (BuildServiceRecordsDelegate)Load <BuildServiceRecordsDelegate>("BuildServiceRecords"); _buildServMemoRecords = (BuildServMemoRecordsDelegate)Load <BuildServMemoRecordsDelegate>("BuildServMemoRecords"); _buildSplitRecords = (BuildSplitRecordsDelegate)Load <BuildSplitRecordsDelegate>("BuildSplitRecords"); _buildTableRecords = (BuildTableRecordsDelegate)Load <BuildTableRecordsDelegate>("BuildTableRecords"); _buildTestRecords = (BuildTestRecordsDelegate)Load <BuildTestRecordsDelegate>("BuildTestRecords"); _buildTreatmentRecords = (BuildTreatmentRecordsDelegate)Load <BuildTreatmentRecordsDelegate>("BuildTreatmentRecords"); _buildUserRecords = (BuildUserRecordsDelegate)Load <BuildUserRecordsDelegate>("BuildUserRecords"); _updateAnimalRecords = (UpdateAnimalRecordsDelegate)Load <UpdateAnimalRecordsDelegate>("UpdateAnimalRecords"); _updateAppointmentRecords = (UpdateAppointmentRecordsDelegate)Load <UpdateAppointmentRecordsDelegate>("UpdateAppointRecords"); _resetFiles = (ResetFilesDelegate)Load <ResetFilesDelegate>("ResetFiles"); _resetFiles(); } }
public static void UnloadDll() { if (_aviCreateLib != IntPtr.Zero) { if (!Kernel32.FreeLibrary(_aviCreateLib)) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } _aviCreateLib = IntPtr.Zero; _buildAccountRecords = null; _buildAnimalRecords = null; _buildAppointRecords = null; _buildAttachRecords = null; _buildAuditRecords = null; _buildClientRecords = null; _buildDiagnoseRecords = null; _buildEntryRecords = null; _buildFollowRecords = null; _buildItemRecords = null; _buildLabRecords = null; _buildMedicalRecords = null; _buildPoRecords = null; _buildPrescripRecords = null; _buildPriceRecords = null; _buildProblemRecords = null; _buildQuotailRecords = null; _buildQuoteRecords = null; _buildReminderRecords = null; _buildServiceRecords = null; _buildServMemoRecords = null; _buildSplitRecords = null; _buildTableRecords = null; _buildTestRecords = null; _buildTreatmentRecords = null; _buildUserRecords = null; _updateAnimalRecords = null; _updateAppointmentRecords = null; _resetFiles = null; _dllInitialized = false; } }