Click here to Skip to main content
15,902,492 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Convert total seconds to date time format Pin
Arif Liminto10-Nov-08 18:53
professionalArif Liminto10-Nov-08 18:53 
QuestionDrawing a windows without system frame Pin
Nacho Chip10-Nov-08 12:54
Nacho Chip10-Nov-08 12:54 
AnswerRe: Drawing a windows without system frame Pin
enhzflep10-Nov-08 14:28
enhzflep10-Nov-08 14:28 
Questionneed help Pin
faradgi10-Nov-08 9:56
faradgi10-Nov-08 9:56 
AnswerRe: need help Pin
Perspx10-Nov-08 10:27
Perspx10-Nov-08 10:27 
AnswerSTOP SPAMMING ALL THE FORUMS Pin
leckey10-Nov-08 11:07
leckey10-Nov-08 11:07 
GeneralRe: STOP SPAMMING ALL THE FORUMS Pin
Paul Conrad10-Nov-08 14:57
professionalPaul Conrad10-Nov-08 14:57 
GeneralRe: STOP SPAMMING ALL THE FORUMS Pin
leckey10-Nov-08 15:02
leckey10-Nov-08 15:02 
QuestionHow to show a value in an Edit Textbox Pin
J_E_D_I10-Nov-08 8:37
J_E_D_I10-Nov-08 8:37 
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 

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.