Solved

C++ MovieFile Errorcodes

Posted on 2009-04-08
4
294 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
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
no14 challenge 14 57
zeroFront challenge 7 71
Dynamically allocate memory 9 47
Thin secure Windows 10 5 49
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now