|
To open a COM port, you can use the CreatFile( ... )
To access COM port properties, use GetCommProperties(...)
To write to a COM port, use WriteFile(...)
see this link:
http://www.control.com/966781257/index_html
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
I have the following code:
<br />
void* fixaddr;<br />
DWORD delta<br />
.<br />
.<br />
.<br />
<br />
*((WORD *)fixaddr) += HIWORD(delta);<br />
.<br />
.<br />
.<br />
During compilation I get the following error:
warning C4244: '+=' : conversion from 'int' to 'unsigned short', possible loss of data
Since I don't want any warnings appear in my code I wonder how to fix this ?
|
|
|
|
|
You could turn down the warning level
|
|
|
|
|
cast HIWORD result to WORD:
*((WORD *)fixaddr) += (WORD)HIWORD(delta);
|
|
|
|
|
Which makes little sense since the HIWORD() macro already casts its result to a WORD . The int that the compiler is complaining about is on the left of the += operator, not the right.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I don't understand why, since the expression on the left IS a WORD. And we have no knowledge of this HIWORD macro; it maybe does not cast to a WORD.
|
|
|
|
|
I have reduced warning level to 3, and this warning does not appear.
Thanks for help!
|
|
|
|
|
Which does nothing but mask this and other potential problems. Leave the compiler warning level at 4 and fix the problem correctly. The compiler generates warnings/errors for a reason. If something wasn't suspect, there'd be no reason to warn you.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
How refreshing! It's not just me that works that way, then
(The more of your replies I read, the more I wish you worked at the same place I do...) [fx: toadying mode off]
Steve S
|
|
|
|
|
Hi, newbie here,
I was wondering what's the best way to use the CMemoryState object to check for memory leaks in a MFC program.
I want to set a checkpoint at the very beginning of the program and the very end, so in what functions should I call
oldState.Checkpoint() and newState.Checkpoint()?
|
|
|
|
|
Call the CheckPoint() method of a CMemoryState object where you want to start tracking. At the point where you want to stop tracking, call the CheckPoint() method of a second CMemoryState object. Then, call the Difference() method of a third CMemoryState object, passing to it the other two CMemoryState objects.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I know how to use the functions, I want to know where is the best place to call them in the App.
I was calling the oldState.Checkpoint() in the App() and
newState.Checkpoint() in App::ExitInstance() but it returned a difference.
When I called oldState.Checkpoint() it listed (I think) a CDocTemplateManager object and a CSingleDoctemplate object.......
So this is obviously not the best place to call oldState.DumpAllObjectsSince() to check overall memory usage.
Is there a function after App::ExitInstance to do the difference check in?
|
|
|
|
|
Generally speaking, in a DEBUG build you'll get this behaviour anyway providing your CPP files have the '#define new ....' stuff in them.
Are you calling CheckPoint before or after calling the base ExitInstance()?
Steve S
|
|
|
|
|
I don't know what you mean by '#define new..."
I'm overriding the MFCApp::ExitInstance() function and calling the base ExitInstance(). Then I do the object dump, so I can't see why a few objects are still allocated.
BTW I am extremely paranoid about memory leaks after having lots of trouble with my last PC (crashing.......sloooowdown etc..)
|
|
|
|
|
I need to link to this lib ws2_32.lib, and would like to know how to do this in the project->settings->link tab.
What exactly do I type in, and where in the project->options text box in the link tab?
Thanks,
ns
|
|
|
|
|
ns wrote:
I need to link to this lib ws2_32.lib, and would like to know how to do this in the project->settings->link tab.
Enter ws2_32.lib in the Object/library modules box.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Appreciate the speedy response
Thanks,
ns
|
|
|
|
|
#pragma comment(lib, "ws2_32.lib") also does the trick
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Hi
I am creating a project (base in a single document), I modified the initial class *View(at the end of the wizard) to be based in CFormView, so that the project is like one based on dialogs (but with other classes and format).
I set up a tabcontrol in the window, and I want to get the other frames because nothing appears in the tab.
I made some other examples but as this one is based on other classes, I have no idea how to get the information.
Can anybody help?
Thanks
rubencmos@hotmail.com
rubencmos@hotmail.com
|
|
|
|
|
This should get you started:
http://msdn.microsoft.com/msdnmag/issues/0600/wicked/default.aspx
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I really apreciate that.
Thanks so much that was really what I was looking for.
Thanks again. Ruben
|
|
|
|
|
I see that given an ftp site, you can use CInternetSession, CFTPConnection with
char* ftpserver = "ftp.microsoft.com" for e.g.
So if I have instead an IP adress for a computer, how do I get the CString for the fptserver.
Basically I need to download some data files off a given IP adress programmatically. Any suggestions appreciated.
Thanks,
ns
|
|
|
|
|
See this project in sourceforge.net
http://sourceforge.net/projects/filezilla/
You can download the source from this URL.
|
|
|
|
|
See this project in sourceforge.net
http://sourceforge.net/projects/filezilla/
You can download the source from this URL.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
hello everybody,
I want create a listbox dynamically on the click of a button in a dialog box.
i had used the following code then also it is not visible when ever i click a button
CListBox clb;
clb.Create(LBS_SORT,CRect(10,10,100,150),this,123);
this->Invalidate(TRUE);
even i had commented the last line then also it was not visible.
thank you.
|
|
|
|