Click here to Skip to main content
15,912,977 members
Home / Discussions / C#
   

C#

 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte9-Nov-11 9:57
KairuByte9-Nov-11 9:57 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
Richard Andrew x649-Nov-11 10:00
professionalRichard Andrew x649-Nov-11 10:00 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte9-Nov-11 10:02
KairuByte9-Nov-11 10:02 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
Richard Andrew x649-Nov-11 10:05
professionalRichard Andrew x649-Nov-11 10:05 
GeneralRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte9-Nov-11 15:22
KairuByte9-Nov-11 15:22 
QuestionRe: Removing Mutex and file lock using DLL injection (Guild Wars) in C# Pin
KairuByte9-Nov-11 15:59
KairuByte9-Nov-11 15:59 
QuestionHandling Own Non-Client Area -- Adjust Client Rectangle? Pin
Matt U.8-Nov-11 6:50
Matt U.8-Nov-11 6:50 
Questionunable to read from SerialPort Pin
Jassim Rahma8-Nov-11 5:59
Jassim Rahma8-Nov-11 5:59 
I am using this code from Microsoft website to simple way to read from Serial Port. I am not getting any error which means it's correct BUT I am not getting any data from the SerialPort but data are being read if I use a third party software so there is no doubt Serial is sending the data?

what can I do? Thanks..

C#
SerialPort serialPort1;
string RxString;

public frmMain()
{
    InitializeComponent();
}

private void btnStart_Click(object sender, EventArgs e)
{
    serialPort1 = new SerialPort() { PortName = txtPortName.Text, BaudRate = Convert.ToInt32(txtBaudRate.Text), DataBits = 8, Parity = Parity.None, StopBits = StopBits.One, Handshake = Handshake.None };

    if (!serialPort1.IsOpen)
    {
        serialPort1.Open();

        serialPort1.Write("SI\r\n");

        btnStart.Enabled = false;
        btnStop.Enabled = true;
        textBox1.ReadOnly = false;
    }
}

private void DisplayText(object sender, EventArgs e)
{
    textBox1.Text = "OK";
    textBox1.AppendText(RxString);
}

private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
    RxString = serialPort1.ReadExisting();
    this.Invoke(new EventHandler(DisplayText));
}

private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
    // If the port is closed, don't try to send a character.
    if (!serialPort1.IsOpen) return;

    // If the port is Open, declare a char[] array with one element.

    char[] buff = new char[1];

    // Load element 0 with the key character.
    buff[0] = e.KeyChar;

    // Send the one character buffer.
    serialPort1.Write(buff, 0, 1);

    // Set the KeyPress event as handled so the character won't
    // display locally. If you want it to display, omit the next line.

    e.Handled = true;
}

private void btnStop_Click(object sender, EventArgs e)
{
    if (serialPort1.IsOpen)
    {
        serialPort1.Close();
        btnStart.Enabled = true;
        btnStop.Enabled = false;
        textBox1.ReadOnly = true;
    }
}

private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
{
    if (serialPort1.IsOpen) serialPort1.Close();
}

AnswerRe: unable to read from SerialPort Pin
Dan Mos8-Nov-11 6:13
Dan Mos8-Nov-11 6:13 
GeneralRe: unable to read from SerialPort Pin
Jassim Rahma8-Nov-11 6:45
Jassim Rahma8-Nov-11 6:45 
GeneralRe: unable to read from SerialPort Pin
Dan Mos8-Nov-11 7:03
Dan Mos8-Nov-11 7:03 
AnswerRe: unable to read from SerialPort Pin
Luc Pattyn8-Nov-11 7:05
sitebuilderLuc Pattyn8-Nov-11 7:05 
QuestionHow to check if a window is open Pin
swapna chappidi8-Nov-11 4:16
swapna chappidi8-Nov-11 4:16 
AnswerRe: How to check if a window is open Pin
Rob Philpott8-Nov-11 4:36
Rob Philpott8-Nov-11 4:36 
GeneralRe: How to check if a window is open Pin
swapna chappidi8-Nov-11 4:47
swapna chappidi8-Nov-11 4:47 
GeneralRe: How to check if a window is open Pin
BobJanova8-Nov-11 5:23
BobJanova8-Nov-11 5:23 
AnswerRe: How to check if a window is open Pin
RaviRanjanKr13-Nov-11 4:36
professionalRaviRanjanKr13-Nov-11 4:36 
QuestionIn Windows 7 I can't get a window to be shown in foreground (Win32 API) Pin
Axonn Echysttas8-Nov-11 2:38
Axonn Echysttas8-Nov-11 2:38 
AnswerRe: In Windows 7 I can't get a window to be shown in foreground (Win32 API) Pin
Axonn Echysttas9-Nov-11 1:34
Axonn Echysttas9-Nov-11 1:34 
QuestionManipulating the order event handlers are executed Pin
Bernhard Hiller8-Nov-11 0:05
Bernhard Hiller8-Nov-11 0:05 
AnswerRe: Manipulating the order event handlers are executed Pin
Alan N8-Nov-11 0:47
Alan N8-Nov-11 0:47 
GeneralRe: Manipulating the order event handlers are executed Pin
BobJanova8-Nov-11 1:18
BobJanova8-Nov-11 1:18 
GeneralRe: Manipulating the order event handlers are executed Pin
Alan N8-Nov-11 2:47
Alan N8-Nov-11 2:47 
GeneralRe: Manipulating the order event handlers are executed Pin
Bernhard Hiller8-Nov-11 2:35
Bernhard Hiller8-Nov-11 2:35 
GeneralRe: Manipulating the order event handlers are executed Pin
Alan N8-Nov-11 5:37
Alan N8-Nov-11 5:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.