Click here to Skip to main content
15,889,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to show a value in an Edit Textbox Pin
David Crow10-Nov-08 9:16
David Crow10-Nov-08 9:16 
GeneralRe: How to show a value in an Edit Textbox Pin
J_E_D_I10-Nov-08 9:51
J_E_D_I10-Nov-08 9:51 
AnswerRe: How to show a value in an Edit Textbox Pin
CPallini10-Nov-08 9:27
mveCPallini10-Nov-08 9:27 
Questionpragma comment for resource files Pin
Jim Crafton10-Nov-08 5:44
Jim Crafton10-Nov-08 5:44 
AnswerRe: pragma comment for resource files Pin
cmk10-Nov-08 8:07
cmk10-Nov-08 8:07 
GeneralRe: pragma comment for resource files Pin
Jim Crafton10-Nov-08 8:15
Jim Crafton10-Nov-08 8:15 
GeneralRe: pragma comment for resource files Pin
cmk10-Nov-08 11:05
cmk10-Nov-08 11:05 
QuestionUnhandled Exception on CreateFile Pin
jimjim73310-Nov-08 4:25
jimjim73310-Nov-08 4:25 
Hi there,

I am trying to populate a combo box of available com ports.
I call my openSerialport function from my init dialog function but as soon as CreateFile is executed I get an Unhandled Exception error which has the info 0xC0000005 : Access Violation.
Can anyone help???????

Code Below

InitDialog call
BOOL CPTZControlDlg::OnInitDialog()
{
	int i, j, hr;
	char portStr[7];

	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// construct a list of available COM ports and put into combo box
	j=0;
	for (i=0 ; i<PORTNUM ; i++) 
	{
		hr = m_serialCtrl->OpenSerialPort(i,0);
		if (hr == 0) 
		{
			g_exists[i] = 1;
			g_nComPortInd[j] = i;
			g_comport[i] = j;
			j++;
			sprintf(portStr,"COM%d",i+1);
			m_comPort.AddString(portStr);

		} 
		else 
			g_exists[i] = 0;
	}
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}


Open Serial port function

int CSerialControl::OpenSerialPort(int pcCommPortInd,int radd) 
{
	DCB dcb;
	BOOL fSuccess;
	char pcCommPort[14];
	int m_nComPort;

  m_nComPort = pcCommPortInd;

  sprintf(pcCommPort,"COM1",pcCommPortInd+1);

  m_hCom = CreateFile( "COM1",
				  GENERIC_READ | GENERIC_WRITE,
				  0,    
				  NULL, 
				  CREATE_ALWAYS,
				  FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED,    
				  NULL  
				  );

  if (m_hCom == INVALID_HANDLE_VALUE) 
  {
	m_hCom = NULL;
	return COMMSERROR;
  }

  if (radd==0) 
  {
	CloseSerialPort();
	return COMMSGOOD;
  }


Cheers

Jim Confused | :confused:
QuestionRe: Unhandled Exception on CreateFile Pin
David Crow10-Nov-08 5:54
David Crow10-Nov-08 5:54 
QuestionRe: Unhandled Exception on CreateFile Pin
CPallini10-Nov-08 6:07
mveCPallini10-Nov-08 6:07 
AnswerRe: Unhandled Exception on CreateFile Pin
Mark Salsbery10-Nov-08 6:49
Mark Salsbery10-Nov-08 6:49 
GeneralRe: Unhandled Exception on CreateFile Pin
CPallini10-Nov-08 7:24
mveCPallini10-Nov-08 7:24 
GeneralRe: Unhandled Exception on CreateFile Pin
Mark Salsbery10-Nov-08 7:37
Mark Salsbery10-Nov-08 7:37 
JokeRe: Unhandled Exception on CreateFile Pin
CPallini10-Nov-08 7:50
mveCPallini10-Nov-08 7:50 
JokeRe: Unhandled Exception on CreateFile Pin
Mark Salsbery10-Nov-08 8:03
Mark Salsbery10-Nov-08 8:03 
JokeRe: Unhandled Exception on CreateFile Pin
CPallini10-Nov-08 8:58
mveCPallini10-Nov-08 8:58 
Question[Message Deleted] Pin
Anil K P10-Nov-08 1:46
Anil K P10-Nov-08 1:46 
AnswerRe: Protect executables and prevent end process Pin
Iain Clarke, Warrior Programmer10-Nov-08 2:34
Iain Clarke, Warrior Programmer10-Nov-08 2:34 
GeneralRe: Protect executables and prevent end process Pin
CPallini10-Nov-08 2:56
mveCPallini10-Nov-08 2:56 
QuestionRe: Protect executables and prevent end process Pin
Maximilien10-Nov-08 2:34
Maximilien10-Nov-08 2:34 
AnswerRe: Protect executables and prevent end process Pin
Rajesh R Subramanian10-Nov-08 2:56
professionalRajesh R Subramanian10-Nov-08 2:56 
AnswerRe: Protect executables and prevent end process Pin
22491710-Nov-08 15:14
22491710-Nov-08 15:14 
GeneralRe: Protect executables and prevent end process Pin
jlkdaslkfjd30-Mar-11 15:54
jlkdaslkfjd30-Mar-11 15:54 
AnswerRe: Protect executables and prevent end process Pin
Hamid_RT10-Nov-08 4:04
Hamid_RT10-Nov-08 4:04 
AnswerRe: Protect executables and prevent end process Pin
KarstenK10-Nov-08 4:14
mveKarstenK10-Nov-08 4:14 

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.