Home > Back-end >  C builder operation error
C builder operation error

Time:09-22

I don't have problems, compile run times wrong, this is the error report (RS232 serial port communication, open the serial port times wrong)
Project Project1. Exe raised exception class EAccessViolation with message 'Access violation at address 00401 c72 module' in the Project. The exe '. Read of address 00000218 '. Process stopped. Use Step or Run to continue.
A great god, o how to return a responsibility, show
This is the wrong sentence
Temp="COM" + IntToStr (rdCOM - & gt; ItemIndex + 1);

CodePudding user response:

ShowMessage (Temp) see Temp right?

CodePudding user response:

ShowMessage (Temp) what do you mean? I need to change is a function?

CodePudding user response:

refer to the second floor songshu_jun response:
ShowMessage (Temp) what do you mean? I need to change is a function?


Showing Temp strings to see if you want,

CodePudding user response:

reference u010165006 reply: 3/f
Quote: refer to the second floor songshu_jun response:

ShowMessage (Temp) what do you mean? I need to change is a function?


Showing Temp strings to see is what you want,

Pop up a interface is empty, then an error

CodePudding user response:

Temp="COM" + IntToStr (rdCOM - & gt; ItemIndex + 1);
ShowMessage (Temp);
Display is empty?
Temp is defined:
AnsiString Temp.

CodePudding user response:

reference 5 floor u010165006 reply:
Temp="COM" + IntToStr (rdCOM - & gt; ItemIndex + 1);
ShowMessage (Temp);
Display is empty?
Temp is defined:
AnsiString Temp.

Not ah, this is part of the source code
Char * ComNo;
DCB DCB.
String Temp;
//to open the communication port
Temp="COM" + IntToStr (rdCOM - & gt; ItemIndex + 1);
ShowMessage (Temp);
//transition to pointer type Char
ComNo=Temp. C_str ();
HComm=CreateFile (ComNo, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, 0);
If (hComm==INVALID_HANDLE_VALUE)
{
Error MessageBox (0, "open communication port!! Comm ", "Error", MB_OK);
return;
}
This is a function of the button, click is performed, click on the button but then directly address error popup Windows, is useless

CodePudding user response:

ShowMessage (Temp);
Display is empty?

What is your CB version?

If it is more than 2009 version, try:
String Temp;
To:
AnsiString Temp.

ComNo=Temp. C_str ();
This sentence is wrong, changed to
Char ComNo [20].
Strcpy (ComNo, Temp. C_str ());
To view a Help about AnsiString type c_str () member function with specifications,

CodePudding user response:

refer to 6th floor songshu_jun response:
char * ComNo;
.
String Temp;
//to open the communication port
Temp="COM" + IntToStr (rdCOM - & gt; ItemIndex + 1);
.
//transition to pointer type Char
ComNo=Temp. C_str ();
HComm=CreateFile (ComNo, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, 0, 0);
If (hComm==INVALID_HANDLE_VALUE)
{
Error MessageBox (0, "open communication port!! Comm ", "Error", MB_OK);
return;
}
This is a function of the button, click is executed, but after clicking the button pop-up directly address the wrong window, there is no use ah


I dare say nine times out of ten in which ComNo question! Location at the "ComNo=Temp. C_str ()" this sentence, in particular, the CreateFile function need ComNo parameters, is not you use the String type conversion can be turned into a serial number,
I suggest you do an enumeration array or other means, to deliver CreatFile function need the serial number of parameters,

CodePudding user response:

What is rdCOM controls the Name?

CodePudding user response:

The building Lord, it is recommended that you specify your serial number directly to try and remove ComNo assignment, the transformation process, such as a serial port is COM1, suggest you CreatFile function directly written:
CreateFile (COM1, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0).

If so write no problem, can tell me right,

CodePudding user response:

refer to 7th floor u010165006 response:
ShowMessage (Temp);
Display is empty?

What is your CB version?

If it is more than 2009 version, try:
String Temp;
To:
AnsiString Temp.

ComNo=Temp. C_str ();
This sentence is wrong, changed to
Char ComNo [20].
Strcpy (ComNo, Temp. C_str ());
To view a Help about AnsiString type c_str () member function with specifications,

I tried it on and useless, I step through the program execution to
Temp="COM" + IntToStr (rdCOM - & gt; ItemIndex + 1); This sentence is wrong, with data type conversion nothing behind, heck is wrong with this sentence

CodePudding user response:

RdCOM is what controls the Name, ListBox or ComboBox or?
What are the Items in the control?
Do you have a choice in the control one? Or specify a code?

CodePudding user response:

True not line, first try around in the past, such as your written in COM1 is:
Temp="COM1";
Written in COM2 is:
Temp="COM2";

In front of the other as I reply to try,

CodePudding user response:

The building Lord I also encountered similar problems, but from the start pop-up error messages,
  • Related