AutoHotkey Community

It is currently May 27th, 2012, 10:06 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: June 15th, 2006, 1:15 am 
Offline

Joined: September 14th, 2004, 11:03 pm
Posts: 21
Hi everyone !

I want to write a file copy subroutine which can resume file if it was interrrupted. I found kernel32.dll\CopyFileEx is just perfect for my needs.

It is described in MSDN as

Quote:
BOOL CopyFileEx(
LPCTSTR lpExistingFileName,
LPCTSTR lpNewFileName,
LPPROGRESS_ROUTINE lpProgressRoutine,
LPVOID lpData,
LPBOOL pbCancel,
DWORD dwCopyFlags
);


I am a complete newbie to DLLCall function of Autohotkey, but this is what I have buit:
Quote:
lpProgressRoutine = 0
lpData = 0
pbCancel = 0
COPY_FILE_RESTARTABLE = 0x02

result := DllCall("CopyFileEx", "str", ExistingFileName, "str", NewFileName, "int *", 0, "int *", lpData, "int *", pbCancel, "int", COPY_FILE_RESTARTABLE)


This will give me 0x05 error which is Access violation. After my testing, I am convinced it is caused by lpProgressRoutine = 0.

I wonder, is it possible to run CopiFileEx() at all from Autohotkey ?
How should I pass a NULL pointer to CopyFileEx ?
What am I missing here :?:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2006, 3:12 am 
MSDN wrote:
lpProgressRoutine
[in] The address of a callback function of type LPPROGRESS_ROUTINE that is called each time another portion of the file has been copied. This parameter can be NULL. For more information on the progress callback function, see the CopyProgressRoutine function.


AHK doesn't support callbacks, as I found out recently :(

There might be another way to do what you are wanting with FileReadLine though...


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2006, 1:03 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Cool, all information is here, no research to do... That's rare enought to be pointed out. :-)
valenock: to pass a NULL pointer, use "UInt", 0, no "UInt *".

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2006, 4:50 pm 
Offline

Joined: September 14th, 2004, 11:03 pm
Posts: 21
Thanks a lot - that Uint worked just fine.

Could this information also be added to the Autohotkey help file ?
Or should I really bother Chris on this issue ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 15th, 2006, 8:06 pm 
Offline

Joined: February 9th, 2006, 8:36 pm
Posts: 339
valenock wrote:
Could this information also be added to the Autohotkey help file ?
Or should I really bother Chris on this issue ?


it is basic knowledge for winapi calls. pointers, by references, by value, etc. If you go into Windows kernel be sure to know these things. You can find winapi guide for newbies or something like that on the Net. Several pages of common API "contract" will be enough I suppose


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2006, 2:24 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
It seems useful enough to mention, so I've added the following to the parameter types table in the "Int" row:
Quote:
To pass a NULL handle or pointer, pass the integer 0.

Thanks for the suggestion.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2006, 4:59 am 
That'll teach me to read the whole MSDN thing. :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 16th, 2006, 12:09 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Good move, Chris! Indeed, this isn't intuitive, even for experimented WinAPI developpers (that's more AutoHotkey knowledge that WinAPI/C one).
I found the trick in someone's code.

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 18th, 2006, 6:24 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2545
PhiLho wrote:
I found the trick in someone's code.
Same here.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Maestr0 and 66 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group