|
Hi,
Did you include Windows.h header ?
-----------
Mila
|
|
|
|
|
Hi Mila,
Thanks for the response.
I have included windows.h and I forgot to include #include "commdlg.h" .
|
|
|
|
|
|
Oops I forgot to include #include "commdlg.h"
Now the error have gone Thanks a lot Prasad.
|
|
|
|
|
When Our application is running, we are able to rename the .exe file from C:\Program files. How can we prevent the file or the folder from getting renamed?? Please post your suggestions..
Thanks for your time and help !!!
|
|
|
|
|
i think this is only possible if your exe is running from some other directory (i.e. not from C:\Program Files\) try running the executable by going to the directory and running it from there and then try renaming it.. As far as i remember i read somewhere that window's paging and filesystem machenism prevents the file to be renamed if its already being used!
|
|
|
|
|
The exe is not present in C:\Program Files. It is present inside a folder with the application name but it still allows me to rename the exe file.
|
|
|
|
|
When your app launches, try opening itself with a call to OpenFile() and set the permissions very high. This should in effect lock the file preventing other processes from deleting or renaming it. Remember to release the handle when your program terminates.
|
|
|
|
|
If I try to rename an application like Yahoo messenger when it is running..It gives me an error message
"ERROR: Unable to rename.It is being used by another person or program.
Close any programs that might be using the file and try again."
How do I do this for my application also??? So that when anyone tries to rename my application exe, when it is running, this error message appears and they are unable to rename the file..
Please post your suggestions.
Thanx!!!
|
|
|
|
|
Hi all,
I receive the following error:
Unhandled exception at 0x0045b287 in updCnf32.exe. 0xC0000005: Access violation writing location 0x00666e63.
Code (xutilty : compiler open this file):
inline void __CLR_OR_THIS_CALL _Container_base::_Orphan_all() const
{
_Lockit _Lock(_LOCK_DEBUG);
if (_Myfirstiter != _IGNORE_MYITERLIST)
{
for (_Iterator_base **_Pnext = (_Iterator_base **)&_Myfirstiter;
*_Pnext != 0; *_Pnext = (*_Pnext)->_Mynextiter)
(*_Pnext)->_Mycont = 0;
*(_Iterator_base **)&_Myfirstiter = 0;
}
}
This is my code:
for(int i=0; i < (int)getFileNamesString.size(); i++)
{
getFNamesString = CIniFile::GetSection(getFileNamesString[i], applicationFname);
for(int i=0; i < (int)getFNamesString.size(); i++)
cout << "File Names -> " << getFNamesString[i].Key.c_str() << "=" << getFNamesString[i].Value << endl;
}
string FileName = getFNamesString[0].Value;
string updateFName = getFNamesString[1].Value;
printf("Creating Directory\n");
TCHAR szDirPath[] = TEXT("C:\\Test\\");
if (!CreateDirectory(szDirPath, NULL))
{
printf("Could not create new directory.\n");
getch();
return -1;
}
else
printf("Directory Created...\n\n");
strcat((char*)szDirPath, (const char*)updateFName.c_str());
char lpExistingFileName[BUF_SIZE];
char lpNewFileName[BUF_SIZE];
strcpy((char*)lpExistingFileName, (const char*)updateFName.c_str());
strcpy((char*)lpNewFileName ,(const char*)szDirPath);
if(CopyFile((LPCTSTR)lpExistingFileName,(LPCTSTR)lpNewFileName,FALSE))
printf("File was copied successfully...\n");
else
printf("File copy failed....\n");
bool SecRc = false;
vector<string> getSecNameString = CIniFile::GetSectionNames(FileName);
for(int i=0; i < (int)getSecNameString.size(); i++)
{
vector<CIniFile::Record> getSecString = CIniFile::GetSection(getSecNameString[i], FileName);
for(int i=0; i < (int)getSecString.size(); i++)
{
if (CIniFile::SetValue(getSecString[i].Key,getSecString[i].Value,getSecString[i].Section,updateFName))
SecRc = true;
else
SecRc = false;
}
}
if (SecRc)
printf("\nSuccess...\nPress any key to continue....");
else
printf("\nFailed...\nPress any key to continue....");
getch();
return 0;
Many thanx ( .. ..)
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Did you use your debugger to see where the problem in your code is ? Can you tell us more about where it happens and what are the value of your variables at this point ?
|
|
|
|
|
Thanx for the reply Cedric,
The exception happens right at this point:
As I press any key, for the getch() the exception occurs.
getch();
return 0;
}
Does this help?
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
I get a feeling that the stack has become corrupted. Check the memory allocations. If you can't find it that way, try to comment out portions of the code until you can pinpoint the location of the source of the error.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
O.k I have done what you said and I have located the place where it happens, can you see anything wrong here:
strcat((char*)szDirPath, (const char*)dtStamp);
char lpExistingFileName[BUF_SIZE];
char lpNewFileName[BUF_SIZE];
strcpy((char*)lpExistingFileName, (const char*)updateFName.c_str());
strcpy((char*)lpNewFileName ,(const char*)szDirPath);
if(CopyFile((LPCTSTR)lpExistingFileName,(LPCTSTR)lpNewFileName,FALSE))
printf("File was moved successfully...\n");
else
printf("File move failed....\n");
Many thanx
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Got it ...
#define BUF_SIZE 1000
char szDirPath[BUF_SIZE] = "C:\\CNF_Update_Transactions\\";
:->
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Yes, you did.
I couldn't verify your code, since you didn't supply the variable declarations.
But anyhow, the problem is fixed, that's the main thing.
And you got a lesson about what happens in case of a stack corruption. Strange things happens...
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Many thanx Kakan
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
I'm glad I could help you out.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
hi,
I've a question.
Can use a class written in a file (fileA.cpp) and use the funtion from the class in another file(fileB.cpp) for example?
|
|
|
|
|
Offcourse.. just include the header file containing the definition of class most probably fileA.h, define an object wherever u want to use the functions of the class and call them. Simple ehh :P
|
|
|
|
|
hi friends !
please do anyone tell me why we put & character in copy constructor.
i know it is syntax. but i need a little explanation
thanks
|
|
|
|
|
Similar question[^] has appeared on this forum few days before. It should give you idea.
|
|
|
|
|
I am getting an exception while start running my project. i am included some 6 dll's and each dll is working and verified.
The error message shows,
"The application failed to initialize properly (0xc0000142). Click on OK to terminate the application"
"Unhandled exception in LFATE.exe (NTDLL.DLL): )xc0000142: DLL Initialization Failed"
|
|
|
|
|
|
I would guess DLLMain is returning FALSE in response to the DLL_PROCESS_ATTACH notification and you're statically linking to the DLL.
Steve
|
|
|
|