Solved

C++ MovieFile Errorcodes

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sum13 challenge 24 90
wordappend challenge 8 147
Excel file not created as expected 7 50
x-bar in Google Sheets 2 26
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

910 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

24 Experts available now in Live!

Get 1:1 Help Now