Пример #1
0
        public static bool Import()

        /*
         * - Import() retreives the X-Tensions API function pointers
         * - it should be called once upon startup (in XT_Init)
         * - returns true upon success, false upon failure
         */
        {
            try
            {
                var moduleHandle = NativeMethods.GetModuleHandle(IntPtr.Zero);

                XWFOutputMessage = GetMethodDelegate <XWFOutputMessageDelegate>(
                    moduleHandle, "XWF_OutputMessage");

                _XWFGetVolumeName = GetMethodDelegate <XWFGetVolumeNameDelegate>(
                    moduleHandle, "XWF_GetVolumeName");

                XWFCreateFile = GetMethodDelegate <XWFCreateFileDelegate>(
                    moduleHandle, "XWF_CreateFile");

                XWFGetSize = GetMethodDelegate <XWFGetSizeDelegate>(
                    moduleHandle, "XWF_GetSize");

                XWFRead = GetMethodDelegate <XWFReadDelegate>(
                    moduleHandle, "XWF_Read");

                _XWFGetVolumeInformation = GetMethodDelegate <XWFGetVolumeInformationDelegate>(
                    moduleHandle, "XWF_GetVolumeInformation");

                _XWFGetSectorContents = GetMethodDelegate <XWFGetSectorContentsDelegate>(
                    moduleHandle, "XWF_GetSectorContents");

                XWFSelectVolumeSnapshot = GetMethodDelegate <XWFSelectVolumeSnapshotDelegate>(
                    moduleHandle, "XWF_SelectVolumeSnapshot");

                XWFGetItemCount = GetMethodDelegate <XWFGetItemCountDelegate>(
                    moduleHandle, "XWF_GetItemCount");

                XWFCreateItem = GetMethodDelegate <XWFCreateItemDelegate>(
                    moduleHandle, "XWF_CreateItem");

                XWFGetItemName = GetMethodDelegate <XWFGetItemNameDelegate>(
                    moduleHandle, "XWF_GetItemName");

                XWFGetItemSize = GetMethodDelegate <XWFGetItemSizeDelegate>(
                    moduleHandle, "XWF_GetItemSize");

                XWFSetItemSize = GetMethodDelegate <XWFSetItemSizeDelegate>(
                    moduleHandle, "XWF_SetItemSize");

                XWFGetItemOfs = GetMethodDelegate <XWFGetItemOfsDelegate>(
                    moduleHandle, "XWF_GetItemOfs");

                XWFSetItemOfs = GetMethodDelegate <XWFSetItemOfsDelegate>(
                    moduleHandle, "XWF_SetItemOfs");

                XWFGetItemInformation = GetMethodDelegate <XWFGetItemInformationDelegate>(
                    moduleHandle, "XWF_GetItemInformation");

                XWFSetItemInformation = GetMethodDelegate <XWFSetItemInformationDelegate>(
                    moduleHandle, "XWF_SetItemInformation");

                _XWFGetItemType = GetMethodDelegate <XWFGetItemTypeDelegate>(
                    moduleHandle, "XWF_GetItemType");

                XWFSetItemType = GetMethodDelegate <XWFSetItemTypeDelegate>(
                    moduleHandle, "XWF_SetItemType");

                XWFGetItemParent = GetMethodDelegate <XWFGetItemParentDelegate>(
                    moduleHandle, "XWF_GetItemParent");

                XWFSetItemParent = GetMethodDelegate <XWFSetItemParentDelegate>(
                    moduleHandle, "XWF_SetItemParent");

                _XWFGetReportTableAssocs = GetMethodDelegate <XWFGetReportTableAssocsDelegate>(
                    moduleHandle, "XWF_GetReportTableAssocs");

                XWFAddToReportTable = GetMethodDelegate <XWFAddToReportTableDelegate>(
                    moduleHandle, "XWF_AddToReportTable");

                XWFGetComment = GetMethodDelegate <XWFGetCommentDelegate>(
                    moduleHandle, "XWF_GetComment");

                XWFAddComment = GetMethodDelegate <XWFAddCommentDelegate>(
                    moduleHandle, "XWF_AddComment");

                XWFGetHashValue = GetMethodDelegate <XWFGetHashValueDelegate>(
                    moduleHandle, "XWF_GetHashValue");

                XWFShowProgress = GetMethodDelegate <XWFShowProgressDelegate>(
                    moduleHandle, "XWF_ShowProgress");

                XWFSetProgressPercentage = GetMethodDelegate <XWFSetProgressPercentageDelegate>(
                    moduleHandle, "XWF_SetProgressPercentage");

                XWFSetProgressDescription = GetMethodDelegate <XWFSetProgressDescriptionDelegate>(
                    moduleHandle, "XWF_SetProgressDescription");

                XWFShouldStop = GetMethodDelegate <XWFShouldStopDelegate>(
                    moduleHandle, "XWF_ShouldStop");

                XWFHideProgress = GetMethodDelegate <XWFHideProgressDelegate>(
                    moduleHandle, "XWF_HideProgress");

                XWFOpenItem = GetMethodDelegate <XWFOpenItemDelegate>(
                    moduleHandle, "XWF_OpenItem");

                XWFClose = GetMethodDelegate <XWFCloseDelegate>(
                    moduleHandle, "XWF_Close");

                XWFCreateEvObj = GetMethodDelegate <XWFCreateEvObjDelegate>(
                    moduleHandle, "XWF_CreateEvObj");

                XWFSearch = GetMethodDelegate <XWFSearchDelegate>(
                    moduleHandle, "XWF_Search");

                _XWFSearchWithPtrToPages = GetMethodDelegate <XWFSearchWithPtrToPagesDelegate>(
                    moduleHandle, "XWF_Search");

                XWFCreateContainer = GetMethodDelegate <XWFCreateContainerDelegate>(
                    moduleHandle, "XWF_CreateContainer");

                XWFCopyToContainer = GetMethodDelegate <XWFCopyToContainerDelegate>(
                    moduleHandle, "XWF_CopyToContainer");

                XWFCloseContainer = GetMethodDelegate <XWFCloseContainerDelegate>(
                    moduleHandle, "XWF_CloseContainer");
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Retrieves the X-Tensions API function pointers. Should be called once at
        /// startup (in XT_Init).
        /// </summary>
        /// <returns>Returns true on success, false on failure.</returns>
        public static bool Import()
        {
            try
            {
                // Get a handle for the XWF API.
                IntPtr moduleHandle = NativeMethods.GetModuleHandle(IntPtr.Zero);

                XWF_OutputMessage = GetMethodDelegate <XWFOutputMessageDelegate>(
                    moduleHandle, "XWF_OutputMessage");

                XWF_GetSize = GetMethodDelegate <XWFGetSizeDelegate>(
                    moduleHandle, "XWF_GetSize");

                XWF_GetVolumeName = GetMethodDelegate <XWFGetVolumeNameDelegate>(
                    moduleHandle, "XWF_GetVolumeName");

                XWF_GetVolumeInformation
                    = GetMethodDelegate <XWFGetVolumeInformationDelegate>(
                          moduleHandle, "XWF_GetVolumeInformation");

                XWF_GetBlock = GetMethodDelegate <XWFGetBlockDelegate>(
                    moduleHandle, "XWF_GetBlock");

                XWF_SetBlock = GetMethodDelegate <XWFSetBlockDelegate>(
                    moduleHandle, "XWF_SetBlock");

                XWF_GetSectorContents = GetMethodDelegate <XWFGetSectorContentsDelegate>(
                    moduleHandle, "XWF_GetSectorContents");

                /*
                 * XWFOpenVolume = GetMethodDelegate<XWFOpenVolumeDelegate>(
                 *  moduleHandle, "XWF_OpenVolume");
                 */

                XWF_OpenItem = GetMethodDelegate <XWFOpenItemDelegate>(
                    moduleHandle, "XWF_OpenItem");

                XWF_Close = GetMethodDelegate <XWFCloseDelegate>(
                    moduleHandle, "XWF_Close");

                XWF_Read = GetMethodDelegate <XWFReadDelegate>(
                    moduleHandle, "XWF_Read");

                /*
                 * XWFWrite = GetMethodDelegate<XWFWriteDelegate>(
                 *  moduleHandle, "XWF_Write");
                 */

                XWF_SectorIO = GetMethodDelegate <XWFSectorIODelegate>(
                    moduleHandle, "XWF_SectorIO");

                XWF_GetCaseProp = GetMethodDelegate <XWFGetCasePropDelegate>(
                    moduleHandle, "XWF_GetCaseProp");

                XWF_GetFirstEvObj = GetMethodDelegate <XWFGetFirstEvObjDelegate>(
                    moduleHandle, "XWF_GetFirstEvObj");

                XWF_GetNextEvObj = GetMethodDelegate <XWFGetNextEvObjDelegate>(
                    moduleHandle, "XWF_GetNextEvObj");

                /*
                 * XWFDeleteEvObj = GetMethodDelegate<XWFDeleteEvObjDelegate>(
                 *  moduleHandle, "XWF_DeleteEvObj");
                 */

                XWF_CreateEvObj = GetMethodDelegate <XWFCreateEvObjDelegate>(
                    moduleHandle, "XWF_CreateEvObj");

                XWF_OpenEvObj = GetMethodDelegate <XWFOpenEvObjDelegate>(
                    moduleHandle, "XWF_OpenEvObj");

                XWF_CloseEvObj = GetMethodDelegate <XWFCloseEvObjDelegate>(
                    moduleHandle, "XWF_CloseEvObj");

                XWF_GetEvObjProp = GetMethodDelegate <XWFGetEvObjPropDelegate>(
                    moduleHandle, "XWF_GetEvObjProp");

                /*
                 * XWFSetEvObjProp = GetMethodDelegate<XWFSetEvObjPropDelegate>(
                 *  moduleHandle, "XWF_SetEvObjProp");
                 */

                XWF_GetEvObj = GetMethodDelegate <XWFGetEvObjDelegate>(
                    moduleHandle, "XWF_GetEvObj");

                XWF_GetReportTableInfo
                    = GetMethodDelegate <XWFGetReportTableInfoDelegate>(
                          moduleHandle, "XWF_GetReportTableInfo");

                XWF_GetEvObjReportTableAssocs
                    = GetMethodDelegate <XWFGetEvObjReportTableAssocsDelegate>(
                          moduleHandle, "XWF_GetEvObjReportTableAssocs");

                XWF_SelectVolumeSnapshot
                    = GetMethodDelegate <XWFSelectVolumeSnapshotDelegate>(
                          moduleHandle, "XWF_SelectVolumeSnapshot");

                XWF_GetVSProp = GetMethodDelegate <XWFGetVSPropDelegate>(
                    moduleHandle, "XWF_GetVSProp");

                XWF_GetItemCount = GetMethodDelegate <XWFGetItemCountDelegate>(
                    moduleHandle, "XWF_GetItemCount");

                XWF_GetFileCount = GetMethodDelegate <XWFGetFileCountDelegate>(
                    moduleHandle, "XWF_GetFileCount");

                /*
                 * XWFGetSpecialItemID = GetMethodDelegate<XWFGetSpecialItemIDDelegate>(
                 *  moduleHandle, "XWF_GetSpecialItemID");
                 */

                XWF_CreateItem = GetMethodDelegate <XWFCreateItemDelegate>(
                    moduleHandle, "XWF_CreateItem");

                XWF_CreateFile = GetMethodDelegate <XWFCreateFileDelegate>(
                    moduleHandle, "XWF_CreateFile");

                XWF_GetItemName = GetMethodDelegate <XWFGetItemNameDelegate>(
                    moduleHandle, "XWF_GetItemName");

                /*
                 * XWFSetItemName = GetMethodDelegate<XWFSetItemNameDelegate>(
                 *  moduleHandle, "XWF_SetItemName");
                 */

                XWF_FindItem1 = GetMethodDelegate <XWFFindItem1Delegate>(
                    moduleHandle, "XWF_FindItem1");

                XWF_GetItemSize = GetMethodDelegate <XWFGetItemSizeDelegate>(
                    moduleHandle, "XWF_GetItemSize");

                XWF_SetItemSize = GetMethodDelegate <XWFSetItemSizeDelegate>(
                    moduleHandle, "XWF_SetItemSize");

                XWF_GetItemOfs = GetMethodDelegate <XWFGetItemOfsDelegate>(
                    moduleHandle, "XWF_GetItemOfs");

                XWF_SetItemOfs = GetMethodDelegate <XWFSetItemOfsDelegate>(
                    moduleHandle, "XWF_SetItemOfs");

                XWF_GetItemInformation
                    = GetMethodDelegate <XWFGetItemInformationDelegate>(
                          moduleHandle, "XWF_GetItemInformation");

                XWF_SetItemInformation
                    = GetMethodDelegate <XWFSetItemInformationDelegate>(
                          moduleHandle, "XWF_SetItemInformation");

                XWF_GetItemType = GetMethodDelegate <XWFGetItemTypeDelegate>(
                    moduleHandle, "XWF_GetItemType");

                XWF_SetItemType = GetMethodDelegate <XWFSetItemTypeDelegate>(
                    moduleHandle, "XWF_SetItemType");

                XWF_GetItemParent = GetMethodDelegate <XWFGetItemParentDelegate>(
                    moduleHandle, "XWF_GetItemParent");

                XWF_SetItemParent = GetMethodDelegate <XWFSetItemParentDelegate>(
                    moduleHandle, "XWF_SetItemParent");

                XWF_GetReportTableAssocs
                    = GetMethodDelegate <XWFGetReportTableAssocsDelegate>(
                          moduleHandle, "XWF_GetReportTableAssocs");

                XWF_AddToReportTable = GetMethodDelegate <XWFAddToReportTableDelegate>(
                    moduleHandle, "XWF_AddToReportTable");

                XWF_GetComment = GetMethodDelegate <XWFGetCommentDelegate>(
                    moduleHandle, "XWF_GetComment");

                XWF_AddComment = GetMethodDelegate <XWFAddCommentDelegate>(
                    moduleHandle, "XWF_AddComment");

                XWF_GetExtractedMetadata
                    = GetMethodDelegate <XWFGetExtractedMetadataDelegate>(
                          moduleHandle, "XWF_GetExtractedMetadata");

                XWF_AddExtractedMetadata
                    = GetMethodDelegate <XWFAddExtractedMetadataDelegate>(
                          moduleHandle, "XWF_AddExtractedMetadata");

                XWF_GetHashValue = GetMethodDelegate <XWFGetHashValueDelegate>(
                    moduleHandle, "XWF_GetHashValue");

                /*
                 * XWFSetHashValue = GetMethodDelegate<XWFSetHashValueDelegate>(
                 *  moduleHandle, "XWF_SetHashValue");
                 */

                /*
                 * XWFSetItemDataRuns = GetMethodDelegate<XWFSetItemDataRunsDelegate>(
                 *  moduleHandle, "XWF_SetItemDataRuns");
                 */

                /*
                 * // DEPRECIATED IN V18.9
                 * XWF_GetMetadata = GetMethodDelegate<XWFGetMetadataDelegate>(
                 *  moduleHandle, "XWF_GetMetadata");
                 */

                XWF_GetMetadataEx = GetMethodDelegate <XWFGetMetadataExDelegate>(
                    moduleHandle, "XWF_GetMetadataEx");

                XWF_GetRasterImage = GetMethodDelegate <XWFGetRasterImageDelegate>(
                    moduleHandle, "XWF_GetRasterImage");

                XWF_Search = GetMethodDelegate <XWFSearchDelegate>(
                    moduleHandle, "XWF_Search");

                XWF_SearchWithPtrToPages
                    = GetMethodDelegate <XWFSearchWithPtrToPagesDelegate>(
                          moduleHandle, "XWF_Search");

                /*
                 * XWFGetSearchHitCount = GetMethodDelegate<XWFGetSearchHitCountDelegate>(
                 *  moduleHandle, "XWF_GetSearchHitCount");
                 */

                /*
                 * XWFGetSearchHitInfo = GetMethodDelegate<XWFGetSearchHitInfoDelegate>(
                 *  moduleHandle, "XWF_GetSearchHitInfo");
                 */

                /*
                 * XWFAddSearchTerm = GetMethodDelegate<XWFAddSearchTermDelegate>(
                 *  moduleHandle, "XWF_AddSearchTerm");
                 */

                XWF_GetSearchTerm = GetMethodDelegate <XWFGetSearchTermDelegate>(
                    moduleHandle, "XWF_GetSearchTerm");

                /* Todo Fix this
                 * XWF_GetSearchTermCount
                 *  = GetMethodDelegate<XWFGetSearchTermCountDelegate>(moduleHandle,
                 *  "XWF_GetSearchTerm");
                 */

                /*
                 * XWFAddSearchHit = GetMethodDelegate<XWFAddSearchHitDelegate>(
                 *  moduleHandle, "XWF_AddSearchHit");
                 */

                XWF_AddEvent = GetMethodDelegate <XWFAddEventDelegate>(
                    moduleHandle, "XWF_AddEvent");

                XWF_GetEvent = GetMethodDelegate <XWFGetEventDelegate>(
                    moduleHandle, "XWF_GetEvent");

                XWF_CreateContainer = GetMethodDelegate <XWFCreateContainerDelegate>(
                    moduleHandle, "XWF_CreateContainer");

                XWF_CopyToContainer = GetMethodDelegate <XWFCopyToContainerDelegate>(
                    moduleHandle, "XWF_CopyToContainer");

                XWF_CloseContainer = GetMethodDelegate <XWFCloseContainerDelegate>(
                    moduleHandle, "XWF_CloseContainer");

                /*
                 * OutputMessage = GetMethodDelegate<XWFOutputMessageDelegate>(
                 *  moduleHandle, "OutputMessage");
                 */

                XWF_GetUserInput = GetMethodDelegate <XWFGetUserInputDelegate>(
                    moduleHandle, "XWF_GetUserInput");

                XWF_ShowProgress = GetMethodDelegate <XWFShowProgressDelegate>(
                    moduleHandle, "XWF_ShowProgress");

                XWF_SetProgressPercentage
                    = GetMethodDelegate <XWFSetProgressPercentageDelegate>(
                          moduleHandle, "XWF_SetProgressPercentage");

                XWF_SetProgressDescription
                    = GetMethodDelegate <XWFSetProgressDescriptionDelegate>(
                          moduleHandle, "XWF_SetProgressDescription");

                XWF_ShouldStop = GetMethodDelegate <XWFShouldStopDelegate>(
                    moduleHandle, "XWF_ShouldStop");

                XWF_HideProgress = GetMethodDelegate <XWFHideProgressDelegate>(
                    moduleHandle, "XWF_HideProgress");

                XWF_ReleaseMem = GetMethodDelegate <XWFReleaseMemDelegate>(
                    moduleHandle, "XWF_ReleaseMem");
            }
            catch (Exception e)
            {
                HelperMethods.OutputMessage("Exception: " + e);
                return(false);
            }

            return(true);
        }