Esempio n. 1
0
 public unsafe void GetCommConfig()
 {
     using (SafeFileHandle handle = CommunicationsMethods.CreateComFileHandle(@"\\.\COM4"))
     {
         COMMCONFIG config = CommunicationsMethods.GetCommConfig(handle);
     }
 }
        /// <summary>
        /// Pops the COM port configuration dialog and returns the selected settings.
        /// </summary>
        /// <exception cref="OperationCanceledException">Thrown if the dialog is cancelled.</exception>
        public unsafe static COMMCONFIG CommConfigDialog(string port, WindowHandle parent)
        {
            COMMCONFIG config = GetDefaultCommConfig(port);

            if (!Imports.CommConfigDialogW(port, parent, ref config))
            {
                throw Errors.GetIoExceptionForLastError();
            }

            return(config);
        }
        /// <summary>
        /// Get the default config values for the given com port.
        /// </summary>
        /// <param name="port">Simple name only (COM1, not \\.\COM1)</param>
        public unsafe static COMMCONFIG GetDefaultCommConfig(string port)
        {
            COMMCONFIG config = new COMMCONFIG();
            uint       size   = (uint)sizeof(COMMCONFIG);

            if (!Imports.GetDefaultCommConfigW(port, ref config, ref size))
            {
                throw Errors.GetIoExceptionForLastError();
            }

            return(config);
        }
        public unsafe static COMMCONFIG GetCommConfig(SafeFileHandle fileHandle)
        {
            COMMCONFIG config = new COMMCONFIG();
            uint       size   = (uint)sizeof(COMMCONFIG);

            if (!Imports.GetCommConfig(fileHandle, ref config, ref size))
            {
                throw Errors.GetIoExceptionForLastError();
            }

            return(config);
        }
Esempio n. 5
0
 public static extern Boolean SetCommConfig([In()] CreateFileWHandle hCommDev, [In()] ref COMMCONFIG lpCC, Int32 dwSize);
Esempio n. 6
0
 public unsafe void CommConfigDialog()
 {
     COMMCONFIG config = CommunicationsMethods.CommConfigDialog(
         @"COM4",
         WindowMethods.GetForegroundWindow());
 }
Esempio n. 7
0
 public unsafe void GetDefaultCommConfig()
 {
     COMMCONFIG config = CommunicationsMethods.GetDefaultCommConfig(@"COM4");
 }
 public static extern bool CommConfigDialogW(
     string lpszName,
     WindowHandle hWnd,
     ref COMMCONFIG lpCC);
 public static extern bool GetCommConfig(
     SafeFileHandle hCommDev,
     ref COMMCONFIG lpCC,
     ref uint lpdwSize);
 public static extern bool GetDefaultCommConfigW(
     string lpszName,
     ref COMMCONFIG lpCC,
     ref uint lpdwSize);
Esempio n. 11
0
 public static extern bool GetCommConfig(IntPtr hCommDev, ref COMMCONFIG lpCC, ref uint lpdwSize);
Esempio n. 12
0
 public static extern bool CommConfigDialog(string lpszName, IntPtr hWnd,
    ref COMMCONFIG lpCC);