|
I included Window Mouse Hook in my app, when compiled I get this:
"error C2065: 'WH_MOUSE_LL' : undeclared identifier"
???
g_hMouseHook = SetWindowsHookEx(WH_MOUSE_LL,MouseProc,GetModuleHandle(NULL),0);
|
|
|
|
|
Did you bother looking in winuser.h for why:
#if (_WIN32_WINNT >= 0x0400)
#define WH_KEYBOARD_LL 13
#define WH_MOUSE_LL 14
#endif // (_WIN32_WINNT >= 0x0400)
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
can any body suggest me some code to set the system time?
please help.
thanks in advance.
|
|
|
|
|
SetSystemTime
Wasn't too hard
You need special privileges, though.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
And see GetSystemTime() and SetLocalTime() .
|
|
|
|
|
Hi all,
I want to convert my CString string/variable into lowercase characters....Is there any API for doing so.........
thanks in advance
|
|
|
|
|
why?
dont you know about str.MakeLower(); function,
it is as simple as that.
if that is not working for you,
then i can suggest something else.
-- modified at 8:08 Wednesday 5th September, 2007
|
|
|
|
|
i m working in mfc so this function is not available there
|
|
|
|
|
CString is from MFC.
so follow this.
CString str;
str="HELLO";
str.MakeLower();
now this should work.
|
|
|
|
|
if your problem is solved, please indicate the same in your main subject by prefixing [SOLVED] to your subject.
|
|
|
|
|
Can you help me.
Help to be going to create Virtual IP using "iphlp" libarary raise just there is example code using c++
wait for your advice.
thank you.
ps : thanks is add "iphlp" library fils(iphlp.h , iphlp.dll ...)
|
|
|
|
|
There is no need to repeat your question. When and if somebody is able to help you, they will reply to your origional post!
|
|
|
|
|
I think I saw your question 6 hours ago why but you asked again?
|
|
|
|
|
Hi All
I have a confusion related to global and local variables...
why global variables are initialized to zero whereas local variables are not...
What is the reason behind this.
Please suggest me the answer.
Thanks & Regards
|
|
|
|
|
Global variables can be used within any function from anywhere within your code, local variables can only be used within scope that they were created ( usualy a single function ). It's good practice and reduces many bugs if you initialize all your variables when you create them, regardless of what the books tell you.
|
|
|
|
|
thanks WalderMort
it is fine that we should initialize each var while creating it,
but wondering that why global variables are initialized to zero by compiler whereas local variables are not..
Please help to understand the logic
Thanks & Regards
|
|
|
|
|
In a debug build, variables are initialized, but you will find that within a release build, they are not. This is one of the main reasons why people complain that their release build doesn't work. Take the following example:
bool bIsEqual;<br />
<br />
if ( ... )<br />
bIsEqual = true;<br />
<br />
if ( bIsEqual )
....
|
|
|
|
|
Hi
could not understand your example
I wrote an example As follows:
int pg;
int _tmain(int argc, _TCHAR* argv[])
{
int pl;
int s;
printf("Global %d \n", pg);
printf("Local %d \n" , pl);
scanf("%d", &s);
return 0;
}
and while printing pl prompts an error message
"Run-Time Check Failure #3 - The variable 'pl' is being used without being defined."
any comments on this....
|
|
|
|
|
rajeevktripathi wrote: "Run-Time Check Failure #3 - The variable 'pl' is being used without being defined."
At compile time, you have got a "warning C4700: local variable 'pl' used without having been initialized".
As you have enabled "Runtime checks" (probably a Debug-build), the runtime complains that you use this variable without prior assignment to it.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
rajeevktripathi wrote: why global variables are initialized to zero whereas local variables are not...
During the CRT initialization routine ( wWinMainCRTStartup function ), there is special code for intializing the c objects and c++ objects. You can find a function called _initterm() called from the wWinMainCRTStartup. That function does all this.
|
|
|
|
|
rajeevktripathi wrote: why global variables are initialized to zero whereas local variables are not...
You'll likely see a difference in initialization between release and debug compiles of your program. In debug mode, since the frame pointer is always pushed onto the stack at routine entry, variables are almost always assigned locations on the stack (e.g., 0). In the release mode, optimizations of the compiler (and other factors) may detect that the frame pointer is not needed, so the frame pointer is not pushed onto the stack, thus no initial value.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Would this warrent taking any safeguards for reader writer lock?
Thread 1 pushes items to the back of a vector.
Thread 2 pops the first item ( if not empty ), does some action, and loops constantly.
The vector contains only pointers. I'm not worried about the execution time of thread 2, but it's critical that Thread 1 isn't required to wait? Using Mutex's or critical sections all involve using the WaitXXX functions. If a safeguard is required, would setting a simple bool be adequate enough to prevent Thread 2 from reading the data while Thread 1 is writing?
|
|
|
|
|
definitely this will work,
in one of my project, i had to implement it.
sure that, it will work even for you,
any more suggestions required,
please.
|
|
|
|
|
There are two issues here. One is the internal gubbins of the vector class you're using. If it's the stl vector then you may be stuck as the code is essentially unreadable gibberish. The other is the synchronisation issue itself.
I use a very similar trick with a queue implemented as a linked list where one thread can remove from the queue and another append to it wihtout any blocking calls. The proviso is that there must be at least 3 items in the queue to gaurantee that the threads don't clash while they're rearraning the node pointers. My queue class itself checks this and it has never failed me. It works in practice because in low load situations where you only have on or two queue items at a time perfromance is not so critical and I can afford to switch on the locking code. I wrote this by implementing it all wiht full locking and testing it then made each locking and unlocking call conditional on swithc which is set and unset when the list size goes over the 3 item boundary. The switch itself is just a long which is incremented and decremented with the Interlocked functions.
The issue if you use someone elses underlying data structure like std::vector is that you don't know what the conditions are for it restructuring or reallocating the memory involved so this kind of scheme is risky. The activity of one thread could cause the data being access by the other to be moved even though there is no obvious overlap between what they're doing. No harm in trying it though and let me know if it works.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Your idea of a linked list que sounds interesting, though in my situation it would not work.
I'm implementing a console stub which will divert a second consoles output to my gui app in real time. The main loop constantly scans the screen buffer, reads the text and clears it. Due to sluggish behaviour I'm using a thread to do the actual writing to the pipe ( since the text gathered from the buffer needs manipulating ).
Thinking about the vector class, esentialy it's just an array which is re-arranged on each insert() erase(). So it would cause reader/writer problems. I've had to use a critical section
|
|
|
|