|
|
hi,
i want to know that,how to delete a particuler file using a path in vc++
i knew that DeleteFile() ,resolve it...but i have a piece of code ..will show below..can u give me the solution ..
i stored the path in Dir,
Dir = "d:\testapp\abc.exe"
now delete a file:
deletefile(Dir);//if i take path like this then this function will delete it. //("d:\\testapp\\abc.exe")
now i want to delete this file using single slash("\") inside path..
anybody know???
|
|
|
|
|
|
Hi kamalilam,
kamalilam wrote: now i want to delete this file using single slash("\") inside path..
As per C++ Character Constants[^], \ has special meaning in strings.
So - "d:\\testapp\\abc.exe" is really "d:\testapp\abc.exe".
Best Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Is there a application that can export Line Drawings, into POINT = {4,5,10,12...} struct arrays.. to be used with API calls like Polyline(...)
|
|
|
|
|
You may use, for instance, a Windows Metafile [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Well i was thinking of more of a drawing tool, or somewhat that could convert it into POINT locations instead? so you could use Polyline, to draw out the item.. Microsoft example uses
POINT aptHexagon[7] = {50,2, 93,25, 93,75, 50,98, 7,75, 7,25, 50,2};
but the Hexagon is way too big, editing it manualy takes alot of time to make it smaller because you would have to recompile to see if lines match up
|
|
|
|
|
I'm hosting Windows Media Player in an application and can't figure out how to detect when a clip is done playing. Unfortunately, the EndOfStream event isn't implemented. I ran across the idea to use the MediaChange event, but I can't see how that's helpful since it's called multiple times and not very accurately.
Does anyone have a working solution?
|
|
|
|
|
To answer my own question, it appears that PlayStateChange event passes a value of 8 when the media is done.
|
|
|
|
|
I'm using mutexes to control access to shared data areas between the primary thread and the secondary threads. Is it possible for a thread to miss a mutex event?
|
|
|
|
|
It seems there is no chance that a mutex's signaled state is undetected by a waiting thread.
MSDN - "When the mutex's state is signaled, one waiting thread is granted ownership, the mutex's state changes to nonsignaled, and the wait function returns. Only one thread can own a mutex at any given time."
|
|
|
|
|
What happens if the waiting thread isn't waiting? It could be in the middle of processing some other mutex event.
|
|
|
|
|
A thread would 'miss' this event, if it is not waiting on the mutex. If it is waiting on the mutex, then the wait function will return, indicating the mutex was acquired (unless something really weird happens, like the mutex was destroyed, in which case too the waiting thread will know what exactly happened).
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
This is what I was thinking. Therefore, special retry logic would be required to help insure that the buffer getting turned over to the main thread does get processed -sooner or later.
|
|
|
|
|
My question has something to do with C/C++ and Visual Studio. I have an MFC project in VS2005 with lots of .h and .cpp files. The program has problems so I run it in debug mode to try to find out what the problems are. For one situation it showed the following message:
Unhandled exception at 0x00761001 in XPT.exe: 0xC0000005: Access violation reading location 0x00000044.
As I clicked the Break button, VS2005 breaks at a line in a source file in my project. The problem is it is on a line irrelavent to the error. It is on a comment line outside any function. The function following that comment block does not seem to have anything to do with that error.
This happened many times in different situations, breaking on comment lines that give me no clue.
This only happened when breaking happened on a third party source file. In my project, this is the sqlite3.c file from SQLite.
I have done a lot such as deleting all the files that are not critical to the project and relaunching the project. (Files such as .ncb, .suo, user-specific options file, etc)
Any idea how to cure that? Any settings, etc. I am running out of ideas. Thanks!
|
|
|
|
|
You IntelliSense is screwed. Try deleting .ncb and .opt files from your project directory and then you may see the code line which point to your exception code.
|
|
|
|
|
I just did this:
1. Deleted the .ncb file
2. Deleted the .suo file
3. Deleted the folder "DebugUnicode" (this is the folder for my DebugUnicode build of this project which contains all the intermediate files such as .obj files, and the final .exe file for this project.)
4. Deleted the user options file (.user)
After those, the only files I have in the project are
The .sln file
The .rc file
The .vcproj file
The .h files
The .cpp files
and the two files from sqlite.org: sqlite3.h and sqlite3.c
However, after relaunching VS2005 and the project, it still breaks on that comment line!
Any other suggestions? Thanks!
|
|
|
|
|
Does it breaks in your code or sqlite3.c? Why don;t you single step in your code and then check calls made to functions in sqlite3.c, BTW are you running debug or release version?
Regards
Abhi
|
|
|
|
|
It breaks in sqlite3.c. I am running the debug version. I will set break points on calls to sqlite functions and try to find out what is happening. I can find the problems that way, which involves a little bit more hassle. I am just annoyed by the strange behavior of VS2005.
Thanks for your help!
|
|
|
|
|
Can you simplify the function by #define or something else?
I want to simplify code bellow, both dll and dynamically reading file are not suitable because of 2 reasons:
1. those files are created by others, if in my way, I only need to re-compile, and do not need to copy the 150 files (will be more soon) into code.
2. there are around 3K of words and sentences in different languages, which can not be used by index. i.e. for string "Apply now", we can not use
CString cs=data[1743]+data[725] - no one can remember which index is which word.
there is a definition class (generated from Data file), looks like:
class Data
{
WORD
*Time,
....,
*Now,
....,
*Apply,
....
};
use is one of #include bellow, then
CString cs=data.Apply+data.Now;
is OK.
void LangData::P_InitLangFull()
{
char*p0[]=
{
#include "Language\english\language_full.h"
};
char*p1[]=
{
#include "Language\french\language_full.h"
};
char*p9[]=
{
#include "Language\german\language_full.h"
};
}
Function code above is quite repeat: only language directory name, english, french, ..., german are changed - totally repeated for 10 times.
It is ok if so, but each language directory has 15 file, so I have to "repeat" the function for 15 times, so second to 15th function look like (only file name is different from first function):
every included h file is plain text as:
"good",
"bad",
"next",
void LangData::P_InitWeather()
{
char*p0[]=
{
#include "Language\english\Weather.h"
};
char*p1[]=
{
#include "Language\french\Weather.h"
};
char*p9[]=
{
#include "Language\german\Weather.h"
};
}
You can imagine how ugly the file is at last - I haven't completed it.
I think we may simplify code by #define or some idea, but the #include causes trouble to #define.
any ideas or suggestions?
thanks
modified on Monday, December 21, 2009 9:32 AM
|
|
|
|
|
Depending on what you are trying to do, you may be better off using Message Text Files[^], which allow you to have a set of common messages, but in different languages. This allows all your messages to be compiled into your application's resources and then referenced by unique id and language.
|
|
|
|
|
it is not suitable for me.
|
|
|
|
|
Sorry, but I am not sure that your request is possible, as the #include directive is a preprocessor directive and I do not think it can be generated from a #define statement.
|
|
|
|
|
the real problem is that #include statement must be in a line itself and excludes other code in the line.
this define and include is legal:
#define aaaaa "c:\....\my.h"
#include aaaaa
|
|
|
|
|
But this does not help you at all. I am not quite sure why you need to do this with #include statements, or what you are trying to achieve. As I said earlier I think the best method is to have a message file with the different languages as part of your resources.
|
|
|
|