Solved

C++ MovieFile Errorcodes

Posted on 2009-04-08
4
304 Views
Last Modified: 2013-11-20
Hello,
is there a list available of the most happen errors with the movefile function? I want to query the most common errors with a case function to give the user a feedback and with the others, unknown, an message to contact support.

Thanks,

Orana
0
Comment
Question by:Ocrana
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Expert Comment

by:DaRakNa
ID: 24103039
MoveFile Function
Moves an existing file or a directory, including its children.

Syntax
C++
BOOL WINAPI MoveFile(
  __in  LPCTSTR lpExistingFileName,
  __in  LPCTSTR lpNewFileName
);

Parameters
lpExistingFileName [in]
    The current name of the file or directory on the local computer.
lpNewFileName [in]
    The new name for the file or directory. The new name must not already exist. A new file may be on a different file system or drive. A new directory must be on the same drive.

Return Value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.


GetLastError Function

Retrieves the calling thread's last-error code value. The last-error code is maintained on a per-thread basis. Multiple threads do not overwrite each other's last-error code.

    Visual Basic:  Applications should call err.LastDllError instead of GetLastError.

Syntax
C++
DWORD WINAPI GetLastError(void);

Return Value
The return value is the calling thread's last-error code.

To obtain an error string for system error codes, use the FormatMessage function.

More info:
http://msdn.microsoft.com/en-us/library/aa365239(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms679360(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms679351(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ms680746(VS.85).aspx
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 24103565
There are just three I could think of as the most prominent ones (others should be rare occasions):
//
// MessageId: ERROR_FILE_NOT_FOUND
//
// MessageText:
//
//  The system cannot find the file specified.
//
#define ERROR_FILE_NOT_FOUND             2L
 
//
// MessageId: ERROR_PATH_NOT_FOUND
//
// MessageText:
//
//  The system cannot find the path specified.
//
#define ERROR_PATH_NOT_FOUND             3L
 
//
// MessageId: ERROR_ACCESS_DENIED
//
// MessageText:
//
//  Access is denied.
//
#define ERROR_ACCESS_DENIED              5L

Open in new window

0
 
LVL 4

Expert Comment

by:StefanKittel
ID: 24104654
Hello,

I use this code to the error as normal text.
Exchange MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN) with your language and show the real error so the user can do something.

Stefan
CString returnString = GetLastErrorAsString(GetLastError());
 
 
CString GetLastErrorAsString(DWORD _errorID)
{
	char		GetLastErrorText[1024];
	CString		tempS;
 
	memset(GetLastErrorText, 0x0, sizeof(GetLastErrorText));
 
	FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, _errorID, MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), GetLastErrorText, 1024, NULL );
 
	tempS = GetLastErrorText;
	tempS.TrimRight();
 
	return tempS;
}

Open in new window

0
 

Author Closing Comment

by:Ocrana
ID: 31568308
Exact what we needed.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
c++ syntax question 9 66
unix example issues 18 113
Need some help with mailto 16 42
How do I get Window Title of all opened process? 4 60
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question