示例#1
0
        internal NikonMd3(string md3File, string md3EntryPoint)
        {
            _handle = Kernel32.LoadLibrary(md3File);

            if (_handle == IntPtr.Zero)
            {
                throw new NikonException("LoadLibrary failed to load MD3 file: " + md3File + ". Download the MD3 file for your device on Nikons SDK website: https://sdk.nikonimaging.com/apply/");
            }

            IntPtr entryPointPointer = Kernel32.GetProcAddress(_handle, md3EntryPoint);

            if (entryPointPointer == IntPtr.Zero)
            {
                throw new NikonException("GetProcAddress failed to get the address for: " + md3EntryPoint);
            }

            _entryPoint = (MAIDEntryPointProcDelegate)Marshal.GetDelegateForFunctionPointer(entryPointPointer, typeof(MAIDEntryPointProcDelegate));
        }
示例#2
0
        internal NikonMd3(string md3File, string md3EntryPoint)
        {
            _handle = Kernel32.LoadLibrary(md3File);

            if (_handle == IntPtr.Zero)
            {
                const string message = "You can download MD3 files from Nikons website: https://sdk.nikonimaging.com/apply/";

                if (!File.Exists(md3File))
                {
                    throw new NikonException("Couldn't find MD3 file: " + md3File + ", " + message);
                }

                MachineType machineType = GetDllMachineType(md3File);
                switch (machineType)
                {
                case MachineType.x86:
                    if (IntPtr.Size == 8)
                    {
                        throw new NikonException("It looks like you're trying to use a 32-bit MD3 file (" + md3File + ") in your 64-bit application. Please use the 64-bit (x64) MD3 file instead. " + message);
                    }
                    break;

                case MachineType.x64:
                    if (IntPtr.Size == 4)
                    {
                        throw new NikonException("It looks like you're trying to use a 64-bit MD3 file (" + md3File + ") in your 32-bit application. Please use the 32-bit (x86) MD3 file instead. " + message);
                    }
                    break;
                }

                throw new NikonException("Failed to load MD3 file: " + md3File + ". The file might be corrupted or in use by another process. " + message);
            }

            IntPtr entryPointPointer = Kernel32.GetProcAddress(_handle, md3EntryPoint);

            if (entryPointPointer == IntPtr.Zero)
            {
                throw new NikonException("GetProcAddress failed to get the address for: " + md3EntryPoint);
            }

            _entryPoint = (MAIDEntryPointProcDelegate)Marshal.GetDelegateForFunctionPointer(entryPointPointer, typeof(MAIDEntryPointProcDelegate));
        }
示例#3
0
        internal NikonMd3(string md3File, string md3EntryPoint)
        {
            _handle = Kernel32.LoadLibrary(md3File);

            if (_handle == IntPtr.Zero)
            {
                throw new NikonException("LoadLibrary failed to load MD3 file: " + md3File + ". Download the MD3 file for your device on Nikons SDK website: https://sdk.nikonimaging.com/apply/");
            }

            IntPtr entryPointPointer = Kernel32.GetProcAddress(_handle, md3EntryPoint);

            if (entryPointPointer == IntPtr.Zero)
            {
                throw new NikonException("GetProcAddress failed to get the address for: " + md3EntryPoint);
            }

            _entryPoint = (MAIDEntryPointProcDelegate)Marshal.GetDelegateForFunctionPointer(entryPointPointer, typeof(MAIDEntryPointProcDelegate));
        }