|
bob16972 wrote: if there is a situation where it could burn me.
If you are the writer of the application you must know if and when the CWinApp is constructed / destroyed (that is: if it's a global variable, it is never null inside the CWinApp running)
If not (you're working on a part of somebody else application) don't trust.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
I'll probably keep coding the same way as usual then.
I prefer to be cautious anyway.
Thanks for the guidance.
|
|
|
|
|
If you are writing a console (DOS-box) application with MFC support, this might happen.
Maxwell Chen
|
|
|
|
|
The approach I've seen in that case is to just use a bare CDocument .
Software Zen: delete this;
|
|
|
|
|
I am developing application which has to use third party dll,(for scanning)who only has described exported functions with function definition.
After I developed a application,which gives proper result but it gives assertion in debug mode at each and every call of function imported from dll. Following is assertion.
"The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention."
And after completion of process (scanning) application terminates.
I read articles from google,msdn and included __stdcall ,WINAPI ,combination
but error comes as it is. In release mode assertion does not come.but application crashes everytime. I cannot debug it as application is terminating after passing end of function call. Only all it shows in debug is access violation and all binary code.
|| ART OF LIVING ||
|
|
|
|
|
This normally happens when you are using a wrong version of the library for linking with the dll. If you have the source code for the dll try rebuilding the dll and rebuilding the application.
Have you tried invoking the dll routines using LoadLibrary, and GetProcAddress. If the functions works perfectly using LoadLibrary calls, the problem is because of your wrong linking.
Arun Krishnan
|
|
|
|
|
The "calling convention" refers to which end of the function call is responsible for cleaning the stack. From your error, it sounds like you are using the wrong call and the stack is not being cleaned correctly. An important thing to note here, when a function is called, a pointer is pushed onto the stack so that the function knows which part of the code to return to. If the stack is not cleaned correctly, this pointer is lost causing the function to return to an incorrect location, causing a crash.
Read this[^] to get a better idea.
|
|
|
|
|
I am not having source code of dll and no contact with writer of that dll.
I also agree it is problem of calling convention. But what is solution for that.
I tried allmost all __cdecl,__stdcall,WINAPI, something like __forcecall (not exact)
.But it crashes after end of function.
|| ART OF LIVING ||
|
|
|
|
|
Do you have the header file for the dll? If not then how do you know the function paramaters?
|
|
|
|
|
Try calling your function using LoadLibrary and verify the results. If the problem is because of calling convention or linkage, LoadLibrary call will be successful.
I am not sure whether i am mis guiding you or not, but this is another alternative when you are stuck.
Arun Krishnan
|
|
|
|
|
Dear Friend I am not having .h file so I am loading it dynamically using LoadLibrary Only. I am having documentation of dll in which it is described the details of
each functions ,what it does and its parameters. Even dll version number is also mentioned. so no chance of Mistake of parameters.
|| ART OF LIVING ||
|
|
|
|
|
CFileStdio saptxt;<br />
saptxt.Open("temp_170807.txt",CFile::modeRead);
In the above case the file temp_170807 has to be located in the same folder as the application. How can i change it to something like "C:\My folder\temp_170807.txt"??
Also how can i make this text-file name generic ie. like "temp_*.txt"??
I m using VC++ MFC application
|
|
|
|
|
Isn't it CStdioFile?? And you can just include the path also with the file name.
saptxt.Open("C:\\My Folder\\temp.txt",CFile::modeRead);
But you can’t open a bunch of files using *, if that’s what you meant by generic file name.
"What's on your mind, if you will allow the overstatement?"
|
|
|
|
|
yashveer wrote: In the above case the file temp_170807 has to be located in the same folder as the application. How can i change it to something like "C:\My folder\temp_170807.txt"??
Err, saptxt.Open("C:\My folder\temp_170807.txt",CFile::modeRead); or am I missing something here?
|
|
|
|
|
Well thanks Swathee
i was putting single back-slash"\"
double back-slash solved the problem...thnks[ ]
but the problem of temp_*.txt still remains
what can i do to get rid of this problem??
Program doesnt take temp_*.txt
|
|
|
|
|
hi,
please mention the complete error...
also,change the line to
saptext.Open("C:\\My folder\\temp_170807.txt",CFile::modeRead);
note the slashes...
swaroop
|
|
|
|
|
What are you trying to do exactly?? you have to open files separately you can't open them in a bunch.
"What's on your mind, if you will allow the overstatement?"
|
|
|
|
|
hi swaroop
double back-slash solved that problem...
In the location C:\Myfolder i could have, lets say:
temp_170807.txt
temp_180807.txt, etc....
But only one file at a time will be present
so i need to give a generic criteria like:
C:\\My folder\\temp_*.txt
Hope you got the problem
|
|
|
|
|
i m opening only one file at a time....
only one file at any given time will be present in the folder:
C:\\My folder\\
i.e. i have either text_1000.txt or text_1001.txt in that location
so i need to give something like text_*.txt
i hope its clear...
|
|
|
|
|
better u don use the multiple selection like this, use a CFileDialog class for that purpose, refer MSDN
swaroop
|
|
|
|
|
I guess you will have to find the file name at runtime and then read it?!!
There is a class called CFileFind MFC, you can use that,
<br />
CFileFind finder;<br />
finder.FindFile("C:\\Design Docs\\temp*.txt");
<br />
finder.FindNextFile();
<br />
CString filename = finder.GetFilePath();
<br />
finder.Close();<br />
Hope this solves your problem. Happy weekend.
"What's on your mind, if you will allow the overstatement?"
|
|
|
|
|
actullay by giving * wont solve ur problem, os else wat u can do is , if the file name ends with constant increase like temp_001, temp_002, etc just put the file open in a loop , concat the file name with the count (eg001,002) and open it and use it, don forget to close before u leave the loop
swaroop
|
|
|
|
|
Thank you very much Swathee
It solved my problem
Happy weekend
|
|
|
|
|
I suggest studying up on the concept of absolute vs. relative paths.
"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
|
|
|
|
|
Hey friends..
CDC::Arc/CDC::Pie are not supported in Windows CE..
I have tried to draw Arc using simple for loop and x = cos(Angle) * radius...
and then CDC::SetPixel used to Glow it...
but
there is Aliasing problem...
Is there any efficient Algorith to Draw Arc/Pie
Thanks in advance...
|
|
|
|