here i'm in situation like never faced before.....that i'm using the program
include \masm32\include\masm32rt.inc
.data
oldfile db 'G:\Images\325837.jpg',0
newfile db 'forget.jpg',0
.data?
.code
start:
cls
invoke CopyFile,offset oldfile,offset newfile,FALSE
print str$(eax),13,10
invoke GetLastError
print str$(eax),13,10
exit
end start
thats like that i compile , link it and runt it without any problem running successfully. actually it done its work perfectly..but while using copyfile function in middle of a big program it is giving trouble it is not copying and returning error code 5. in two or five line code it is perfect but in among lots of instructions it is not going well as it in here...can any body tell me what is going on ............ my experience is at the top of all instructions in a big program its running well but putting it middle in that program returnig error code 5............thats it
As described on MSDN (http://msdn.microsoft.com/en-us/library/windows/desktop/aa363851(v=vs.85).aspx):
QuoteReturn 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.
Did you try to call LastError$ macro in "a big program" ? If so what did it say?
[EDIT]: From the list of System Error Codes (0-499) (http://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx):
Quote
ERROR_ACCESS_DENIED
5 (0x5)
Access is denied.
No mysteries - check permissions
If as you said it failed due to 'error access denied' then why it is succeeding at top of 'the big program', i'm not tried that macro yet. just justify this one before that......
are you trying to copy to or from a network drive ?
Quote from: shaikkareem on March 29, 2014, 03:26:55 AM
If as you said it failed due to 'error access denied' then why it is succeeding at top of 'the big program'...
It's hard to say without "a big program" source code ;)
Quote from: dedndave on March 29, 2014, 03:46:55 AM
are you trying to copy to or from a network drive ?
no i'm not, i'm just copying from removable media(pendrive) to my local disk thats it ......
Quote from: vertograd on March 29, 2014, 03:47:20 AM
Quote from: shaikkareem on March 29, 2014, 03:26:55 AM
If as you said it failed due to 'error access denied' then why it is succeeding at top of 'the big program'...
It's hard to say without "a big program" source code ;)
it is really returning with 'access is denied' when i called LastError$ what i've to do
Check to see what the current directory is - you give a full path for the source but only a name for the destination.
If you change directories to e.g. a CD or C:\Windows then you would most likely get "access denied".
Quote from: shaikkareem on March 29, 2014, 02:41:06 PM
it is really returning with 'access is denied' when i called LastError$ what i've to do
What do you do if you put the key into your door, and it won't open?
- call the police?
- ask for help in a forum?
- or try to find out why the key doesn't open the door??
The message is utterly clear: ACCESS DENIED. You are not allowed to copy file A to destination B.
Check if you can copy that particular file to destination B using Windows Explorer. And read carefully what sinsi wrote above.
If that still doesn't help, use this snippet to test where is your file's destination.
include \masm32\include\masm32rt.inc
.data?
buffer db MAX_PATH dup(?)
.code
start:
push eax
invoke GetFullPathName, chr$("AnyFile.txt"), sizeof buffer, addr buffer, esp
pop edx
print offset buffer
exit
end start
check the destination folder, right-click, properties
see if your user account has write permission on that folder
Quote from: shaikkareem on March 28, 2014, 10:33:09 PM
but while using copyfile function in middle of a big program it is giving trouble it is not copying and returning error code 5.
CopyFile does not return error code 5 it returns non-zero for success or zero for failure. The last-error code value is meaningful only when a function that sets the last-error code value returns failure. If you are calling GetLastError without first determining that CopyFile failed, the returned last-error code value could be a leftover from some other function call.
Quote from: MichaelW on March 29, 2014, 03:59:52 PM
CopyFile does not return error code 5 it returns non-zero for success or zero for failure. The last-error code value is meaningful only when a function that sets the last-error code value returns failure. If you are calling GetLastError without first determining that CopyFile failed, the returned last-error code value could be a leftover from some other function call.
Perfectly right, of course, although it seems that OP does check for return code:
invoke CopyFile,offset oldfile,offset newfile,FALSE
print str$(eax),13,10 <<<<<<<<<<<<< OP, what do you see here???
invoke GetLastError
Quotealthough it seems that OP does check for return code
Yes, in the code that is functioning correctly, but not necessarily in the big program where it is giving trouble, and also where there are more potential errors.
print str$(eax),13,10 <<<<<<<<<<<<< OP, what do you see here???
invoke GetLastError
Swap those two lines maybe? The macros probably use APIs that set the last error code.
thank you all................the problem is with restriction of access to removable disk. that is i just open the removable disk with un-proper access rights (stupid)......just closed it by adding additional access rights and the denying access problem closed with it, things are good now,.,.,.,.,.,.,.,..,, :icon_rolleyes: