|
yes, you're writing one line at a time, whereas I was writing the whole string at once. But since I wanted to keep the previous contents of the file, I specified CFile::modeNoTruncate as one of the flags, but whatever I write is still appended to the end of the line that was previously there.
If it's broken, I probably did it
bdiamond
|
|
|
|
|
The seek to end may be truncating the \r\n on the final line.
Try adding a \r\n pair to the beginning of your string.
Brad
|
|
|
|
|
Hi,
How about this?
CString s = "\r\none more line";
CFile file("c:\\test.txt", CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate);
file.SeekToEnd();
file.Write(s, s.GetLength());
Fabian
|
|
|
|
|
thank you BradBruce and f64!! that worked!!
If it's broken, I probably did it
bdiamond
|
|
|
|
|
bdiamond wrote:
text has the 'r\n\'
I hope this is a typo and you actually have '\r\n'....
Elaine
The tigress is here
|
|
|
|
|
YES, that was a typo; I actually did have the right text down, even though I've made stupider mistakes before!!;)
If it's broken, I probably did it
bdiamond
|
|
|
|
|
I need to shut down explorer.exe programmatically. I think I can use PostThreadMessage but how do I retrieve the process ID for explorer.exe?
-Ian
|
|
|
|
|
easy. have a look at msdn, topic "OpenProcess". there you will find the link "Taking a Snapshot and Viewing Processes" with an example of how to list all processes. execute this code, check if the exe file name is "explorer.exe" and so you will get all instances of the explorer. open it with OpenProcess and then close it by TerminateProcess.
Don't try it, just do it!
|
|
|
|
|
From MSDN:
The TerminateProcess function is used to unconditionally cause a process to exit. Use it only in extreme circumstances. The state of global data maintained by dynamic-link libraries (DLLs) may be compromised if TerminateProcess is used rather than ExitProcess.
MSDN suggests you should use ExitProcess instead of TerminateProcess...
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
ExitProcess() only exits the current process. To force another process to close, you have no choice but TerminateProcess() .
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hmm, I should've read further...
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
how do I find out the current path that my executable is executing in? Thanks
If it's broken, I probably did it
bdiamond
|
|
|
|
|
|
No, this is wrong. This will get the path the executable is currently "working" in. Might be as well C:\Windows or any other directory.
What you want is GetModulePath .
modified 12-Sep-18 21:01pm.
|
|
|
|
|
thanks!!! the other solution gave me the last path that the user browsed to with my 'File Open' dialog.
If it's broken, I probably did it
bdiamond
|
|
|
|
|
using simple sockets how can you test if the connection has been broken by the other server?
|
|
|
|
|
try to receive data and if it fails check call WSAGetLastError and then you will see if the connection was closed.
Don't try it, just do it!
|
|
|
|
|
Hey all,
I have some problems when I try to load a DLL file, I m using afxloadlibrary cause I need to work with multithreads... when I compile everything goes ok, but when I execute I get this error messagebox
Debug Assertion Failed!
Program ...\ewcapt.exe
File appcore.cpp
Line 85
does anyone know what it means?
Daniel
|
|
|
|
|
Is the DLL being loaded an MFC extenbsion DLL? If so, are AfxInitExtensionModule() and AfxTermExtensionModule() being used?
danielsdl wrote:
File appcore.cpp
Line 85
does anyone know what it means?
Have you set a breakpoint on line 85 of appcore.cpp to see why the assertion is firing?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Debug -vs- Release?
Make sure the dll and the executable are compiled for the same type.
Brad Bruce
|
|
|
|
|
Thank u guys... the problem was that I declared a pointer as a member of my class inside my dll, I dont know why, it doesnt work when u have a pointer variable...
|
|
|
|
|
if i want to implement a firewall with windows apis for
processing each input/output packet please introduce me that apis (if there is)
koosha
|
|
|
|
|
|
First some details:
Our application receives a data feed over a fiber optic T1. We develop both the client and server applications that send and receive the data. Both applications are written in ANSII C++ for portability. We use Winsock when running on a Windows platform.
The problem:
Sometimes the T1 line experiences 25% loss according to the ping tool. During these times we often see our connection from client to server disconnect with an error 10054 (An existing connection was forcibly closed by the remote host.). Is there anything we can do, programatically, to avoid connection loss or to quickly recover from the connection loss?
Thanks in advance
|
|
|
|
|
Hi
is it dangerous to have many threads read one shared variable/object without using any synchronization mechanisms?
(read only)
this variable can be a static or a regular member of a class...
|
|
|
|