Click here to Skip to main content
16,010,114 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: hex to dec Pin
David Crow25-Feb-04 4:24
David Crow25-Feb-04 4:24 
GeneralRe: hex to dec Pin
Prakash Nadar25-Feb-04 4:33
Prakash Nadar25-Feb-04 4:33 
GeneralRe: hex to dec Pin
David Crow25-Feb-04 4:38
David Crow25-Feb-04 4:38 
GeneralRe: hex to dec Pin
Prakash Nadar25-Feb-04 4:49
Prakash Nadar25-Feb-04 4:49 
GeneralRe: hex to dec Pin
David Crow25-Feb-04 5:18
David Crow25-Feb-04 5:18 
GeneralRe: hex to dec Pin
Cedric Moonen25-Feb-04 4:52
Cedric Moonen25-Feb-04 4:52 
GeneralRe: hex to dec Pin
erkanina26-Feb-04 0:14
erkanina26-Feb-04 0:14 
GeneralERROR:cannot open file "nafxcwd.lib" Pin
JoeMass25-Feb-04 3:16
JoeMass25-Feb-04 3:16 
--------------------Configuration: Wyse2 - Win32 Debug--------------------
Here is the only error I get when building my app: Any ideas? I am using VC++ 6.0

Compiling resources...
Compiling...
stdafx.cpp
Wyse160.cpp
Linking...
LINK : fatal error LNK1104: cannot open file "nafxcwd.lib"
Error executing link.exe.

Souce code:

// Wyse160.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "Wyse160.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
#undef mc
//#define mc

// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;

DCB dcb;
int fSuccess;
DWORD dwResult;
DWORD BaudRate;
BYTE ByteSize;
BYTE Parity;
BYTE StopBits;
CString csErrMsg;
CString csTitle;
CString csComm;

char inBuffer[512];
char outBuffer[512];

int Read1COMM(char * inBuffer, DWORD nBytesToRead);
int Write1COMM(char * outBuffer,DWORD nBytesToWrite);

// Fill in the default com port and values for DCB: 9600 bps, 8 data bits, no parity and 2 stop bits
char *pcCommPort = "COM2";
BaudRate = CBR_9600; // set the baud rate
ByteSize = 8; // data size
Parity = NOPARITY; // set parity
StopBits = TWOSTOPBITS; // two stop bits

csTitle.Format("Data Station Wyse Terminal %.2f", version);
SetConsoleTitle(csTitle);
m_hMainWait = CreateEvent( NULL, FALSE, FALSE, NULL);

pcCommPort = "COM1";
BaudRate = CBR_9600;
Parity = NOPARITY;
ByteSize = 8;
StopBits = ONESTOPBIT;

/*Parity = EVENPARITY;
Parity = ODDPARITY;
Parity = NOPARITY;
Parity = MARKPARITY;
StopBits = ONESTOPBIT;
StopBits = ONE5STOPBITS;
StopBits = TWOSTOPBITS; */


csTitle.Format("Data Station Wyse Terminal %.2f %s", version, pcCommPort);
SetConsoleTitle(csTitle);

CommTimeouts = new _COMMTIMEOUTS;
/* m_PKeybrdThread = 0;
m_PScreenThread = 0;*/

m_bLine = false;

// initialize MFC and print and error on failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
// TODO: change error code to suit your needs
_tprintf(_T("Fatal Error: MFC initialization failed\n"));
nRetCode = 1;
}
else
{
// TODO: code your application's behavior here.
m_hCom = CreateFile (pcCommPort,
GENERIC_READ | GENERIC_WRITE,
0, // open as exclusive access
NULL, // no security
OPEN_EXISTING,
0, // not overlapped I/O
NULL // comm device
);
if (m_hCom == INVALID_HANDLE_VALUE)
{
wyseErr("Connect to COM port failed.");
return (1);
}

// Configure the comm port

fSuccess = GetCommState(m_hCom, &dcb);

if (!fSuccess)
{
// Handle error
wyseErr("Could not get COM state.");
return (2);
}

dcb.BaudRate = BaudRate;
dcb.ByteSize = ByteSize;
dcb.Parity = Parity;
dcb.StopBits = StopBits;

fSuccess = SetCommState(m_hCom, &dcb);

if (!fSuccess)
{
wyseErr("Could not set COM state.");
return (3);
}

CommTimeouts->ReadIntervalTimeout = MAXDWORD;
CommTimeouts->ReadTotalTimeoutConstant = 0;
CommTimeouts->ReadTotalTimeoutMultiplier = 0;
CommTimeouts->WriteTotalTimeoutConstant = 0;
CommTimeouts->WriteTotalTimeoutMultiplier = 0;

fSuccess = SetCommTimeouts(m_hCom, CommTimeouts);

if (!fSuccess)
{
wyseErr("Could not set COM timeouts.");
return (4);
}

fSuccess = GetCommTimeouts(m_hCom, CommTimeouts);

if (!fSuccess)
{
wyseErr("Could not get COM timeouts.");
return (5);
}


printf ("Serial port %s is successfully reconfigured.\n", pcCommPort);
WaitForSingleObject(m_hMainWait, 2000);


Write1COMM(outBuffer,2 /*{# of bytes to write}*/);

Read1COMM(inBuffer,1 /*{# of bytes to read}*/);


_onexit (exitMain);

while (m_bRunning)
{
dwResult = WaitForSingleObject(m_hMainWait, 1000);
}
}
return nRetCode;

/*******************************************************************/
} /* END OF MAIN ROUTINE ********************************************/
/*******************************************************************/

int exitMain ()
{
m_bRunning = false;
return 0;
}


int Read1COMM(char * inBuffer, DWORD nBytesToRead)
{
DWORD nBytesRead = 0;
DWORD dwResult;
int nResult;

m_hCOMMWait = CreateEvent( NULL, FALSE, FALSE, NULL);

while (!nBytesRead)
{
nResult = ReadFile(m_hCom, inBuffer, 1, &nBytesRead , NULL);
if (nBytesRead)
inBuffer[nBytesRead] = 0;
else
dwResult = WaitForSingleObject(m_hCOMMWait, 100);
}
return nBytesRead;
}

int Write1COMM(char * outBuffer,DWORD nBytesToWrite)
{
/* char inBuffer[InBuffSize];*/
DWORD nBytesWritten;
int fSuccess;

nBytesWritten=0;

fSuccess = WriteFile(m_hCom, outBuffer, nBytesToWrite, &nBytesWritten , NULL);

/* m_PKeybrdThread = NULL; */
return fSuccess;
}

GeneralRe: ERROR:cannot open file "nafxcwd.lib" Pin
Prakash Nadar25-Feb-04 3:23
Prakash Nadar25-Feb-04 3:23 
GeneralRe: ERROR:cannot open file "nafxcwd.lib" Pin
Michael Dunn25-Feb-04 4:51
sitebuilderMichael Dunn25-Feb-04 4:51 
GeneralGetting text of selected combobox item Pin
monrobot1325-Feb-04 3:14
monrobot1325-Feb-04 3:14 
GeneralRe: Getting text of selected combobox item Pin
Prakash Nadar25-Feb-04 3:20
Prakash Nadar25-Feb-04 3:20 
GeneralRe: Getting text of selected combobox item Pin
David Crow25-Feb-04 3:35
David Crow25-Feb-04 3:35 
GeneralRe: Getting text of selected combobox item Pin
monrobot1325-Feb-04 4:13
monrobot1325-Feb-04 4:13 
GeneralCODE Pin
Goh Hui Beng25-Feb-04 2:59
Goh Hui Beng25-Feb-04 2:59 
GeneralRe: CODE Pin
Prakash Nadar25-Feb-04 3:18
Prakash Nadar25-Feb-04 3:18 
GeneralRe: CODE Pin
Maximilien25-Feb-04 3:26
Maximilien25-Feb-04 3:26 
GeneralRe: CODE Pin
Goh Hui Beng25-Feb-04 3:49
Goh Hui Beng25-Feb-04 3:49 
GeneralPrinter fonts setting Pin
El'Cachubrey25-Feb-04 2:56
El'Cachubrey25-Feb-04 2:56 
GeneralRe: Printer fonts setting Pin
ana_v1237-Aug-07 11:52
ana_v1237-Aug-07 11:52 
QuestionHow to create hidden Dialog Window ? Pin
vgrigor25-Feb-04 2:42
vgrigor25-Feb-04 2:42 
AnswerRe: How to create hidden Dialog Window ? Pin
David Crow25-Feb-04 2:52
David Crow25-Feb-04 2:52 
GeneralRe: How to create hidden Dialog Window ? Pin
vgrigor25-Feb-04 3:04
vgrigor25-Feb-04 3:04 
GeneralRe: How to create hidden Dialog Window ? Pin
David Crow25-Feb-04 3:08
David Crow25-Feb-04 3:08 
GeneralRe: How to create hidden Dialog Window ? Pin
vgrigor25-Feb-04 3:19
vgrigor25-Feb-04 3:19 

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.