|
i used FindFirstChangeNotification()FindFirstChangeNotification()AND WaitForSingleObject() to notify any change in a mentioned directory.its working.But i want to mention the cause of notification (say its due to deletion of a file).i declared every filter condition in FindFirstChangeNotification()
|
|
|
|
|
|
this the code....
DWORD change= WaitForSingleObject(hr,INFINITE);
if(change==WAIT_OBJECT_0)
::AfxMessageBox("CHANGE HAS BEEN DETECTED");
FindCloseChangeNotification(hr);
in the ::AfxMessageBox() I WANT TO MENTION THE REASON FOR NOTIFICATION ie DUE TO FILE DELETION OR FILE RENAME ETC
|
|
|
|
|
|
|
How to convert a LONGLONG data type to binary ?
Thanks for any help.
|
|
|
|
|
I guess you mean convert to a binary string... right? If you can't find a runtime library function to do it, try something like this:
LONGLONG value = 12345;
TCHAR mystring[sizeof(LONGLONG)*8 + 1];
for(int i = 0; i < sizeof(LONGLONG)*8; i++)
mystring[i] = ((value >> (sizeof(LONGLONG)*8 - i - 1)) & 1) ? _T('1') : _T('0');
mystring[sizeof(LONGLONG)*8] = 0; Hope that helps.
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
Thank you.
I tried to put the answer to the code you gave me in a message box like that:
void CMyBitsDlg::ConvertLLtoBin()
{ LONGLONG value = 12345;
TCHAR mystring[sizeof(LONGLONG)];
for(int i = 0; i < sizeof(LONGLONG); i++)
mystring[i] = ((value >> (sizeof(LONGLONG) - i - 1)) & 1) ? _T('1') : _T('0');
AfxMessageBox(mystring);
}
The answer is 00111001P@
Any idea about the error?
|
|
|
|
|
you forgot to end your string with
mystring[i] = '\0'; that doesn't happend with my CString (see here[^])
of course, int i; should be declared before for() loop...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Yes the thought just popped into my mind, and I just returned now to correct my mistake.
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
datas are written in binary format in memory...
however, if you like to print an integer in binary format, this link[^] should help.
here is the sample :
<font color=#0000FF>LONGLONG</font> iVal = 125932; <font color=#008000>
CString strVal = <font color=#808080>""</font>; <font color=#008000>
<font color=#0000FF>for</font> (<font color=#0000FF>int</font> i = 0; i < <font color=#0000FF>sizeof</font>(LONGLONG); i++) {
strVal.Insert(0, ((iVal & 0x00000001) ? <font color=#808080>"1"</font> : <font color=#808080>"0"</font>));
iVal >>= 1;
}
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Thank you.
Pls read my reply to Joel Holdsworth.
|
|
|
|
|
fardak wrote:
Pls read my reply to Joel Holdsworth
hey, already done...
you define mystring as a TCHAR[], which need a trailing '\0' to be displayed correctly...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Thanks again.
I rewrote this:
void CMyBitsDlg::ConvertLLtoBin()
{ LONGLONG value = 12345;
TCHAR mystring[sizeof(LONGLONG)];
for(int i = 0; i < sizeof(LONGLONG); i++)
mystring[i] = ((value >> (sizeof(LONGLONG) - i - 1)) & 1) ? _T('1') : _T('0');
mystring[i]='\0'; //added
AfxMessageBox(mystring);
}
And the answer is 00111001 which is 39 hexadecimal.
So something is wrong.
But the strange thing happening now is that I have an error memory reading message.
|
|
|
|
|
Almost correct. You need to change
TCHAR mystring[sizeof(LONGLONG)]; to
TCHAR mystring[sizeof(LONGLONG) + 1]; and instead of writing
mystring[i]='\0'; try
mystring[sizeof(LONGLONG)] = 0; I think that might help
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
Thanks again.
Ok the last version is
void CMyBitsDlg::ConvertLLtoBin()
{ //LONGLONG value = 12345;
LONGLONG value = 0xFF FF FF FF FF FF FF FF;
TCHAR mystring[sizeof(LONGLONG)+1];
for(int i = 0; i < sizeof(LONGLONG); i++)
mystring[i] = ((value >> (sizeof(LONGLONG) - i - 1)) & 1) ? _T('1') : _T('0');
mystring[sizeof(LONGLONG)]='\0';
AfxMessageBox(mystring);
}
And the answer is 11 11 11 11
Instead od a 64 times '1'.
Where the rest has gone ?
|
|
|
|
|
|
Thank you for yor time and effort.
I tried you edited code with a value of
0xFF FF FF FF FF FF FF FF (//16 F)
and it gives 64 1's which is the correct answer .
Thanks again.
|
|
|
|
|
|
hum, well, it seems that the code is printing only the LSB and is missing the 0b 00110000 00111001
did you try my code ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Not yet,but I will and tell you about it.
Right now my head is spinning..dangerously!!
|
|
|
|
|
Thanks for the code you supplied.
I tried the one given by Joel Holdsworth,and it works perfectly well.
Here's the final version.
void CMyBitsDlg::ConvertLLtoBin()
{
LONGLONG value = 0xFFFFFFFFFFFFFFFF;//16 F
TCHAR mystring[sizeof(LONGLONG)*8 + 1];
for(int i = 0; i < sizeof(LONGLONG)*8; i++)
mystring[i] = ((value >> (sizeof(LONGLONG)*8 - i - 1)) & 1) ? _T('1') : _T('0');
mystring[sizeof(LONGLONG)*8] = 0;
AfxMessageBox(mystring);
}
The result is a 64 1's.
|
|
|
|
|
I'm so sorry to mess you around fardak! I'm really not thinking properly today! The problem is that sizeof(LONGLONG) is in bytes not bits. Change every reference to sizeof(LONGLONG) to sizeof(LONGLONG)*8, and everything should work out!
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^]
|
|
|
|
|
i tried to implement but i couldn't .i hope anyone could help me before 20 of this month
|
|
|
|
|
Hi,
I have alot of MFC and C++ Console applications & static library's.
I build all applications on Windows OS & main applications (console) on Linux (gcc gmake).
Which program do you guys advise to use to automated building so I can do building easily on Win & Linux? ant? Scons?
I realise this is not a general C++ question, but since you guys alsoo waste a lot of time building apps maybe anyone could give me some tips ..
Greetings,
Jens
|
|
|
|