|
Meat Loaf wrote: e thread gets deleted automatically.
that will do
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Yes your thread will go to death automatically. because a thread created with a AfxBeginThread() call in MFC is always a CWinThread .
Happy programming keep asking.
I am the brain behind...
|
|
|
|
|
HELLO,
Now i can read and write all events in any log source (Application,System...)
i can catch each event logging in a specified log source.
the problem is that i want to cach any event in any log source.
this is the proc of catch:
BOOL notifyChange(LPCTSTR logSource)
{
BOOL bSuccess;
HANDLE hEventLog, hEvent;
DWORD dwWaitResult;
hEventLog = OpenEventLog(NULL, // local machine
logSource); // event log source name
if (hEventLog == NULL)
{
printf("Could not open event log.");
return FALSE;
}
hEvent = CreateEvent(NULL, // default security attributes
FALSE, // no manual reset
FALSE, // create as not signaled
NULL); // no event name
NotifyChangeEventLog(hEventLog, hEvent);
dwWaitResult = WaitForSingleObject(hEvent, INFINITE);
if (dwWaitResult == WAIT_FAILED)
bSuccess = FALSE;
else bSuccess = TRUE;
CloseHandle(hEvent);
CloseEventLog(hEventLog);
return bSuccess;
}
|
|
|
|
|
Hello everyone,
I have verified that the following approach works to set the size of a file (newly created file) to be 100 bytes, but I am not sure whether it is the correct/best way to have a maximum portability (I need to write code on both Windows and Linux).
Could anyone give me any comments?
<br />
#include "fcntl.h"<br />
#include "sys/types.h"<br />
#include "sys/stat.h"<br />
#include "io.h"<br />
#include "stdio.h"<br />
<br />
int main()<br />
{<br />
FILE* file = fopen ("foo123", "w+");<br />
<br />
fseek (file, 99, SEEK_SET);<br />
<br />
fprintf (file, "x");<br />
<br />
fclose (file);<br />
<br />
return 0;<br />
}<br />
thanks in advance,
George
-- modified at 6:11 Monday 17th July, 2006
|
|
|
|
|
It's probably a lot more portable than SetEndOfFile() .
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thank you DavidCrow!
What do you mean SetEndOfFile()? Is there a method called SetEndOfFile() in C?
regards,
George
|
|
|
|
|
George_George wrote: Is there a method called SetEndOfFile() in C?
There's a function called SetEndOfFile().
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thank you DavidCrow!
Why my method is better than SetEndOfFile()?
regards,
George
|
|
|
|
|
George_George wrote: Why my method is better than SetEndOfFile()?
You wanted portability, didn't you?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thank you DavidCrow!
Yes, I mean why SetEndOfFile() has worse portability?
regards,
George
|
|
|
|
|
George_George wrote: ...why SetEndOfFile() has worse portability?
It's only for a Windows platform.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thank you DavidCrow!
regards,
George
|
|
|
|
|
There's two ways to get portability; the first is to use a common API and test it enough to make sure it works the same way on both systems; the second is to do such:
int main(int argc, char** argv)
{
#if defined(WINDOWS)
#elif defined(LINUX)
#endif
return 0;
}
The former tends to make for much more readable code... at least IMO.
earl
|
|
|
|
|
Thank you earl!
Your sample is only the general principle to develop portable code. In my case, to set the length of a file, is my method showed above has good portability? Do you have any better ideas or any comments?
regards,
George
|
|
|
|
|
Why do you need the file to be 100b?
I imagine your example should work, unless there are examples of sparse filesystems in use? I doubt it, but I don't keep up with the various file systems in use under linux.
Alternatively, you could just fwrite 100b of zeroes...
unsigned char buff[100];
memset(buff, 0x0, 100 * sizeof(unsigned char));
fwrite(buff, sizeof(unsigned char), 100, fp);
earl
|
|
|
|
|
Thank you earl!
Your method is using more memory compared with my method -- 100 more bytes for the local char array. Agree?
regards,
George
-- modified at 4:28 Wednesday 19th July, 2006
|
|
|
|
|
Sure, but who cares? As written it'll be allocated on the stack and disappear after the function is finished. You also could call fwrite 100 times on a single byte, if you're working in a space where 100b matters.
earl
|
|
|
|
|
Thank you earl!
regards,
George
|
|
|
|
|
Hi,
I have declared an integer type variable for an edit box.My requirement is I want the edit box to be left blank i.e there should be no "0" when it is displayed.How can this be done?
Thanks in advance
Sandhya
|
|
|
|
|
Before showing the Edit Control set its window text to null.
that is, if you are using dialog based application then in OnInitDialog() use the below statement;
GetDlgItem(EditCtrlID)->SetWindowText("");
or
if you have a control variable say m_editctrl then
m_editctrl.SetWindowText("");
Do your Duty and Don't expect the Result
|
|
|
|
|
SetDlgItemText (IDC_MYEDIT,"");
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
i forget the SetDlgItemText(..).
This will be more appropriate than SetWindowText():->
Do your Duty and Don't expect the Result
|
|
|
|
|
SetWindowText() is still good . dont worry .
|
|
|
|
|
Hi,
Please can u say How can we convert CString variable to char data type.
Thanks in advance,
tejaswini
|
|
|
|
|
<br />
char myCharVar[20];<br />
CString myStrVar;<br />
<br />
myStrVar = "This will be copied";<br />
myCharVar = myStrVar.GetBuffer(myStrVar.GetLength());<br />
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|