コード例 #1
0
        // Initializes the DetectDisplays library.
        public static void Initialize()
        {
            displayInfo = new DisplayInfo();
            IntPtr pointer = IntPtr.Zero;

            try
            {
                pointer = Marshal.AllocHGlobal(Marshal.SizeOf(displayInfo));
                int returnValue = DD.Initialize(pointer);

                displayInfo = (DisplayInfo)Marshal.PtrToStructure(pointer, typeof(DisplayInfo));

                // Detection failed
                if (returnValue == 0)
                {
                    InitializeNoDetectDisplays();
                }
            }
            catch
            {
                //// (Exception e)
                //// MessageBox.Show(string.Format("Exception: {0}\n\nStack Trace:\n{1}", e.Message, e.StackTrace));
                InitializeNoDetectDisplays();

                throw;
            }
            finally
            {
                Marshal.FreeHGlobal(pointer);
            }
        }