Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C++ MovieFile Errorcodes

Posted on 2009-04-08
4
Medium Priority
?
309 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

598 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