Hi all,i am using function COpyFile() to copy a file to windows directory,but the function return error code 5:

char win_path[MAX_PATH];
	char reg[MAX_PATH];
	

	GetModuleFileName(NULL , reg ,MAX_PATH);
	GetWindowsDirectory(win_path , MAX_PATH);
	bool x = CopyFile(reg , win_path , true);
	if(!x)
		cout << GetLastError() << endl;

Recommended Answers

All 2 Replies

Could be one (or both) of two problems:
1) The destination can not be just the path, but the path + filename. The destination filename may be the same as the source filename or something else if you want to rename it.

2) You may not have permissions to write into the destination path.

yes,it was the first one :) thanx ,i missunderstood the function :P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.