|
Hello,
Is it possible to emulate keyboard event (using keybd_event) on the desktop, that is different from active (input) desktop? I.e. I want to create a thread, that calls SetThreadDesktop() and then emulates some keyboard activity on the desktop, whos handle was passed to SetThreadDesktop().
Currently, I have no result until I pass handle of input desktop to SetThreadDesktop().
|
|
|
|
|
Hi,
I am trying to write a stack trace function for an application.
If an exception occurs, I need the stack trace to be printed.
I am using stackwalk64 API to read the stack. But some times
the exception record retreived is improper resulting in inadequate
or junk reports. So I plan to access the stack pointer directly using
Inline Assembly. But the SetUnhandledException
pops the stackframes soon after the crash(before the filter function is called).
So Is there any API which simply notifies the occurence of the exception
without popping the stack soon after the exception occurs.
Thanks in Advance.
-Mathespa
|
|
|
|
|
You're best off just letting the application crash in most cases. Dr. Watson will generate a stack dump and if need be you can configure it to produce a crash dump file which you can load up with WinDBG (and other tools) to get stack traces, examine memory and more. In short you get more functionality for free by not doing anything.
Steve
|
|
|
|
|
When ever i see example and stuff they always use int main() then end with return 0
Whats wrong with just void main()?
Is it just some thing that happened, y'know, one person did it, then a couple, and so on and so forth?
|
|
|
|
|
You might want to return an exit code of some type to a calling or monitoring process.
|
|
|
|
|
The Undefeated wrote: Whats wrong with just void main()?
Absolutely nothing. I use void main( void ) all the time when I am not interested in returning a value or handling any command-line arguments.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Forgiving compiler... the standard actually states that main shall return int. You are however not required to return a value from the main function! If you omit the return statement, it'll default to 0. I thought it was bogus, but the c++ standard says it isn't so.
--
Torn from tomorrow's headlines
|
|
|
|
|
I'm well aware of that. Nine times out of ten, however, I'm not concerned about standards or compliance. When I create a console application, it's just to test a theory, not to create a "real" application.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
From the documentation:
"Alternatively, the main and wmain functions can be declared as returning void (no return
value). If you declare main or wmain as returning void, you cannot return an exit code to the
parent process or operating system using a return statement; to return an exit code when main or
wmain is declared as void, you must use the exit function."
|
|
|
|
|
because void main() is not part of the C++ standard, it is an illegal definition and will not be accepted by a standards-compliant compiler.
|
|
|
|
|
And there you have it.
So in short, you can use void if you want, but you should return an exit code of some sort.
Well, i suppose i should keep using int then
|
|
|
|
|
EDIT - after re-reading your post, my smart-alec response made no sense. I need more caffeine!
Cheers!
|
|
|
|
|
actually, it is the other way around.
void main() is illegal, you must always use int main(), but you don't *have* to return a value:
int main()
{
}
is valid c++
C on the other hand is a little different...
|
|
|
|
|
James Brown wrote: int main()
{
}
Hmm That wouldn't compile for me
|
|
|
|
|
James Brown wrote: because void main() is not part of the C++ standard
Standards schmandards! This is the Visual C++/MFC message board!
|
|
|
|
|
pity that MS share this philosophy though...
|
|
|
|
|
I've been asked to remove all access keys from an application's menu. (I know, stupid right?) Anyway, I've removed the access keys. However it turns out that when you press the ALT key and then the first letter of a submenu or menu item, it behaves just like an access key. Is this just inherent Windows behavior? Is there any way to prevent this behavior?
Thanks,
Stephanie
|
|
|
|
|
sdehart wrote: I've been asked to remove all access keys...
Do you mean the mnemonics? The "first letter" way of accessing a menu is built in.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
a well designed windows application is supposed to work even if no mouse is connected...
why on earth would someone break the mnemonics ?
|
|
|
|
|
This may be a dumb question, but I would like to know the answer.
1. A static variable is initialized only once, and remains in memory until the end of the program. It can only be accessed from the scope of the funtion. Correct?
2. A static function can only be accessed from the source file from within which it is contained. Correct?
3. A static class member is shared by all instances of the class, and only initialized once ( not counting initialization within the c'tor ). Also this type of function can be called from anywhere it is visible, ie not only from class instances. Correct?
4. But this one confuses the hell out of me. What about a static variable defined within a class function. I know a member variable is better suited for the job, but still... Am I correct in thinking it would be shared by all instances of the class?
|
|
|
|
|
WalderMort wrote: 1. A static variable is initialized only once, and remains in memory until the end of the program. It can only be accessed from the scope of the funtion. Correct?
Yes (I mean, for the last part it has to be declared in the function of course). But you can still change its value afterward (it's not a constant)
WalderMort wrote: 2. A static function can only be accessed from the source file from within which it is contained. Correct?
Don't know exactly what's the purpose of global static functions
WalderMort wrote: 3. A static class member is shared by all instances of the class, and only initialized once ( not counting initialization within the c'tor ).
Yes, a static member variable is shared among all instances but it is not initialised in the constructor but before the constructor gets called (at global scope in fact).
WalderMort wrote: Also this type of function can be called from anywhere it is visible, ie not only from class instances. Correct?
For static member functions, you don't need to have an instance to call it. You can simply call it this way: CMyClass::MyStaticFunc(); . This is true only if the function is public of course.
In fact the difference between a static and a non-static mem function is that the latter receive an implicit parameter: the this parameter (which identifies to which instance the function 'belongs to').
WalderMort wrote: 4. But this one confuses the hell out of me. What about a static variable defined within a class function. I know a member variable is better suited for the job, but still... Am I correct in thinking it would be shared by all instances of the class?
I would say that it is shared among all instances but I'm not 100% sure. In fact, I suppose it because for two different classes, it's the same function that will get called and it can know to which instance it belongs to because it received the implicit this parameter. So, I suppose that it works like a standard function. But for this point, I'm not totally sure but it is easy to test: just make two instances of a class with a function that increment the static variable and then prints the result and check the output.
|
|
|
|
|
4.
It's a class local variable (as opposed to an instance local variable)
|
|
|
|
|
Thanks for the explanations.
Cedric Moonen wrote: Don't know exactly what's the purpose of global static functions
I remember reading somewhere that this was a C thing, enabling two or more functions with the same name and paramaters to be defined, but each function is only avaialable to the single source file. Not entirely sure about it though.
For the 4th question. I honestly can't see the need for having a static variable in a function like this, EVER.
|
|
|
|
|
Yes - static functions at file scope are only visible within the source file they are declared and defined.
4th - if you have a function which needs to track something private to function but at class scope.
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
Blake Miller wrote: 4th - if you have a function which needs to track something private to function but at class scope.
This is what confuses me. Private to function, fine, but won't all the other instances of the same class have access to the same variable (memory location) when they themselves run the same function? If so, isn't it a little risky!
|
|
|
|