|
Hello!
I have made a tiny change to a console-application I've been using for years. I changed some variables of type 'unsigned long' into '_int64' to be able to represent larger numbers. As a result the application now halts before execution even enters the main() function. Only after I give a character input and then hits return does the program start its normal execution. This is inconvienient since the program is normally run as a child of another application.
Any ideas about how to fix this?
Thanks in advance!!!
maladuk
|
|
|
|
|
If you change those __int64 references back to unsigned long , does it start working again?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
I got another hint which I checked out first, that the error could stem from erroneous initialization in global objects. It turned out to be the case.
Thanks a lot for engaging anyway!
maladuk
|
|
|
|
|
Hi,
I was just wondering if anyone else has ever seen this problem, and might be aware of a fix for it:
I'm calling malloc in a recursive fuction I recently wrote, and it gets called a ton of times very quickly, could be 1-2k times or more per fraction of a second.
For some reason, if I have it call too many times, the program crashes. If I lower the bounds of the recursive exit slightly, then I can get it to work most of the time. Lowering the bounds further will result in the program working 100% of the time, but I don't get the results I need (it needs to be very precise).
Of course the first instinct is to assume I'm running out of memory, but no, that is not the case, I'm calling malloc on tiny tiny portions of memory and when the program crashes it's normally only using between 1700 and 3500K of RAM.
The program is actually crashing inside of malloc so there isn't much I can do about the function itself, it doesn't even get to the return.
I tried placing sleep calls into the function but this strategy didn't work, as well as causing the function call to take horrendously long amounts of time to run.
Any ideas?
Thanks!
Kelly Ryan
|
|
|
|
|
KellyR wrote: I'm calling malloc in a recursive fuction I recently wrote, and it gets called a ton of times very quickly, could be 1-2k times or more per fraction of a second.
Recursion is very stack-intensive.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Are you sure that malloc is the cause? or are you running out of stack space by making all those recursive function calls. You must remember that every time you make a recursive function call new storage space is allocated on the stack for the parameters, and all your register values are also pushed onto the stack so that they are saved for when the function returns. If you make too many recursive function calls you stack will get used up very quickly and your program will crash.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
That's probably what it is, thanks.
Kelly Ryan
|
|
|
|
|
In C/C++ when u malloc() memory you allocate heap, which is memory. Whereas your recursion calls are like the proverbial stack of plates. Each pass takes one more away until they are all gone.
You could increase the stack space in you program but that will only buy you a temporary fix. Instead you should probably revist the design of your app and decide if recursion is really needed.
Good Luck
Mike Luster
|
|
|
|
|
Hello,
I have a GUI application developed in VS.net. Depending on a users OS, they may require that certain DLL's be in the system folder(s) in order for the GUI to run.
Can someone tell me how to develop a simple installation CD, that will load the GUI exe, and then load the required DLL(s) onto the users system.
Thanks.
Jerry
|
|
|
|
|
Google for InnoSetup.
~RaGE();
|
|
|
|
|
Microsoft Visual Studio .NET 2003 -> File -> New Project -> Setup And Deployment Projects -> Setup Wizard -> ...
From here you should do everything its not difficult
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
jerry1211a wrote: Can someone tell me how to develop a simple installation CD, that will load the GUI exe, and then load the required DLL(s) onto the users system.
In Continuation with Mr. Rage,
here is the link for InnoSetup:-
http://www.jrsoftware.org/isinfo.php[^]
"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
|
|
|
|
|
Thanks for providing the link.
~RaGE();
|
|
|
|
|
|
I have the need to execute a console application from within my dialog based one, and I need to retrieve the output of the console app in a string form.
The console app doesn't require user input, it accepts an argument, then just runs and generates a string.
I would imagine I have to use ShellExecute, or CreateProcess, but am not sure how to get the output, other than simply it's return code.
Any ideas?
Thx,
Rick
|
|
|
|
|
If you could get away with an intermediate file, you could simply use the "myprg.exe >intermediate.file" syntax to catch the output of "myprog.exe" in "intermediate.file" .
I am positively sure there other and are more elegant ways, but this one is a matter of half an hours work.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
Try and search Code Project (using the search functionality at the top of this page) for CWaitProcess. It seems a bit complicated at first sight, but it is exactely what you need.
~RaGE();
|
|
|
|
|
Look at the parameter list for CreateProcess(). Some of them are file handles that you can specify where you want to the output to go to i.e. create a file and then pass its HANDLE into CreateProcess()/
The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison
Awasu 2.2 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
See here and here.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Have a look at the popen() function.
|
|
|
|
|
Thanx for the replies
I did find something that looks like it's exactly what I want here: http://www.codeproject.com/threads/consolepipe.asp.
Apparently I wasn't searching for the right keywords
-- modified at 7:11 Tuesday 10th January, 2006
|
|
|
|
|
Does anybody know how to detect if there are system global window hooks present? Piece of code, freeware, or a solid pointer to where I may find the information, is highly welcome.
|
|
|
|
|
Jörgen Sigvardsson wrote: Does anybody know how to detect if there are system global window hooks present? Piece of code, freeware, or a solid pointer to where I may find the information, is highly welcome.
I've seen this question asked before, and as far as I know, you cannot do it (at least in user mode) in 32 bit Windows. I believe it was possible in the 16-bit days.
So, you'd probably have to go the kernel route and try some undocumented stuff.
Alternatively, you could hook the hooker - SetWindowsHookEx, when Windows starts.
Regards,
Nish
|
|
|
|
|
I've seen shareware apps claiming they can detect window hooks, but I have yet to find a free one. Nor do they provide any technical detail on how it is done (trade secrets ).
Nishant Sivakumar wrote: Alternatively, you could hook the hooker - SetWindowsHookEx, when Windows starts.
That won't help me much, as I'm trying to detect what's messing up my keyboard input. I know (from dabbling with hooks myself), that it is easy to screw up the keyboard handling, if you do not pass all messages to the next hook on the chain. I remember failing to forward "peeks" to the next chain, which caused the accelerator translation to fail in some instances, depending on key up/down sequences in n-key combinations. The symptoms I'm witnessing right now matches such bad hook behaviour. The only problem is that I have no hooks installed on this machine...
|
|
|
|
|
Jörgen Sigvardsson wrote: I've seen shareware apps claiming they can detect window hooks, but I have yet to find a free one. Nor do they provide any technical detail on how it is done (trade secrets ).
Do any of them work?
Jörgen Sigvardsson wrote: That won't help me much, as I'm trying to detect what's messing up my keyboard input.
Well, if you hook it, you'll at least know what program it is that's putting a silent hook without your knowledge.
Regards,
Nish
|
|
|
|