|
Hello,
thanx for your answers! I try with one of the examples in this community!
with best regards
break;
|
|
|
|
|
if we load an exe file in CMemFile object how can we run that exe file from there (memory)?
eg, CMemFile m_file;
....... // loaded exe into memory in binary format
.......
.......
WinExec("m_file",SH_SHOW);
above statement donot executes it looks in the directory for exe file m_file.exe.
All i want is to execute that program which is loaded in memory file from memory and not from disk.
|
|
|
|
|
This has been a frequently asked question. However, the consensus has always been that you cannot. See here.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
|
You can't do this, because the EXE that starts a process has to be an on-disk file. The OS loader gets the EXE into memory with a memory-mapped file.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
How to set the static edge/ client edge property of a dialog box to true at run time. Iam using SDK.
|
|
|
|
|
with ModifyStyle you can change some object styles
|
|
|
|
|
I need to test system in release mode using similar to TRACE(" %d %d\n", a,b) geting variable number of arguments to formated string but saveing it to some file. Is there some code available
|
|
|
|
|
To work with file, take a look at ofstream. You can do things like that:
ofstream File("MyFile.txt");
int Variable = 10;
File<<"Text"<<Variable<<endl;
|
|
|
|
|
how to handle variable number of arguments in function?
TRACE( ... )
{
//check how many argc
//out put them to file
file<<"arg1 type";
file<
|
|
|
|
|
And how do you manage that with the TRACE macro ? It should be the same.
-- modified at 7:28 Tuesday 2nd May, 2006
To take your example:
TRACE(" %d %d\n", a,b)
Would be:
File<<a<<b<<endl;
|
|
|
|
|
I'm not going to manage it with TRACE macro, I mentioned that I need to write similar function like TRACE for outputing formatted string to file
9ine
|
|
|
|
|
9ine wrote: I mentioned that I need to write similar function like TRACE
This part was not clear. Now I see what you want to do. I never worked with functions with variable arguments list but you can take a look at the MSDN[^].
|
|
|
|
|
9ine wrote: how to handle variable number of arguments in function?
See va_arg() , va_start() , va_list , and va_end() .
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
HI,
Your question doesn't explain itself fully.Please post some sort of relevant information on what type of application are you working on and some code if possible.
As far as I understand your question you want to write a formatted string to a file so You can use fprintf()
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
-- modified at 7:31 Tuesday 2nd May, 2006
|
|
|
|
|
No I'd like to paste some "TRACE" like function in the release code which is run faster than in debug mode using TRACE().
When the code is executed we can output TRACE() messages to VC window but in release mode I'd like to substitute TRACE() function with something similar but puting its output to file
some hard C console app code:
....
....
TRACE(" %d %d", var1,var2);
...
...
change the same of TRACE() function to put (" %d %d", var1,var2) formated string to file by invoking just that function
9ine
|
|
|
|
|
Take a look at vfprintf .
Nibu thomas
Software Developer
|
|
|
|
|
Make couples of defines, and define TRACE to a function of yours in release mode.
In that function, do the formatting and file writing.
Then you can use the same TRACE-statements in debug as well as in relese mode, and the release-version vill write to a file of your choice.
I won't give you a code sample, since I'm likely to get flamed for it. But it can be done, quite easily.
Put your email address in your profile and I can email you a working example.
|
|
|
|
|
9ine@mail.ru
that would be great
9ine
|
|
|
|
|
You've got it.
I hope you will find it useful.
Kakan
|
|
|
|
|
Still have not recieved it.
I'm going to use just one file for log trace.
9ine
|
|
|
|
|
great thing, thanks, strange that you get 550 smtp error?
9ine
|
|
|
|
|
Actually this part of your idea is good - I am not so sure about the implementation though.
I would take a look at TRACE's implementation. It takes a while to wade through but you can learn a bit along the way. It eventually boils down to calling _snprintf (or _sntprintf for TCHAR usage) into a text buffer (1024 bytes long) and then calling OutputDebugString in AtlDebugAPI.cpp around line 306. OutputDebugString works in release and debug mode as long as a debugger is running.
What I am getting at is in release builds TRACE is compiled to no-ops so you can implement your own trace statements that do essentially the same thing. If you do it right you can disable them all by commenting out a few lines and recompiling.
Good luck.
|
|
|
|
|
There is always room for improvements.
The way I see it there is a distinction between "good" and "good enough"
In this case, the the objective was to get a way of tracing the app in a release build.
Of course, a guy can spend, say 10 hours, to get the trace code perfect in every aspect.
Or, spending 1 hour to get a code that's good enough, and the remaining 9 hours to do the actual debug.
IMO, the second alternative is the best, since it faster will lead to making the "debugee" work.
Correct me if I'm wrong, but that was the goal, wasn't it?
|
|
|
|
|
9ine wrote: I need to test system in release mode using similar to TRACE(" %d %d\n", a,b) geting variable number of arguments to formated string but saveing it to some file. Is there some code available
as others said, write to a file using sprintf or other stream writing. I use sprintf with a stream to sockets so that the debugger can be off system for embedded debugging as well as local.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|