1. RE: CopyFileEx API Call

>From: Larry Miller <guest at RapidEuphoria.com>
>Reply-To: EUforum at topica.com
>To: EUforum at topica.com
>Subject: CopyFileEx API Call
>Date: Sat, 02 Oct 2004 21:07:00 -0700
>
>posted by: Larry Miller <lmiller7 at mail.com>
>
>I have been trying to use the CopyFileEx function with a call back routine=

>provided by call_back(). The copy works and progress is reported, but ther=
e
>is a machine exception when CopyFileEx returns. I believe the problem is
>that CopyFileEx is passing too many parameters. It passes no less than 9
>separate parameters, 4 of which are LARGE_INTEGERS, for a total of 13
>32 bit values. According to the Euphoria documentation a maximum of 9 are
>allowed for a callback function.
>

   A LARGE_INTEGER is a union of a long long and two long's (ie. a 64-bit=

integer that can be accessed as two 32-bit integers). It should be regarded=

as a pointer (to the 64-bit integer.) That should give you exactly 9
parameters, just enough...

>This is with Euphoria 2.4 on Windows 2000.
>
>Am I understanding the situation incorrectly or is this a real problem?
>Is there some way I can use this function? My experience with Win32Lib and=

>Windows programming is somewhat limited. Maybe one of you seasoned
>programmers can shed some light on the subject.
>
>Larry Miller
>

~[ WingZone ]~
http://wingzone.tripod.com/

s

first two months FREE*.

new topic     » topic index » view message » categorize

2. RE: CopyFileEx API Call

Elliott S. de Andrade wrote:
> 
> >
> >posted by: Larry Miller <lmiller7 at mail.com>
> >
> >I have been trying to use the CopyFileEx function with a call back 
> >routine provided by call_back(). The copy works and progress is 
> >reported, but there is a machine exception when CopyFileEx returns. I 
> >believe the problem is that CopyFileEx is passing too many parameters. 
> >It passes no less than 9 separate parameters, 4 of which are 
> >LARGE_INTEGERS, for a total of 13 32 bit values. According to the 
> >Euphoria documentation a maximum of 9 are allowed for a callback 
> >function.
> >
> 
>    A LARGE_INTEGER is a union of a long long and two long's (ie. a 64-bit=
> integer that can be accessed as two 32-bit integers). It should be regarded=
> as a pointer (to the 64-bit integer.) That should give you exactly 9
> parameters, just enough...

Actually, these are passed by value, so he really does have 13 parameters.
You can have an unlimited number of parameters by using fptr.e:

http://www.rapideuphoria.com/fptr.zip

Here is an example:

include fptr.e
include dll.e

constant
k32 = open_dll( "kernel32.dll" ),
xCopyFileEx = define_c_func( k32, "CopyFileExA", repeat( C_POINTER, 6 ), C_LONG
)

constant
PROGRESS_CONTINUE   = 0,
PROGRESS_CANCEL     = 1,
PROGRESS_STOP       = 2,
PROGRESS_QUIET      = 3

function cb_fptr( atom total_file_size1, atom total_file_size2, 
					 atom total_bytes_transferred1, atom total_bytes_transferred2,
					 atom stream_size1, atom stream_size2,
					 atom stream_bytes_transferred1, atom stream_bytes_transferred2,
					 atom rest )
		atom stream_number, call_back_reason, source_file, destination_file, data
		sequence params
		
		params = peek4u( rest & 5 )
		stream_number = params[1]
		call_back_reason = params[2]
		source_file = params[3]
		destination_file = params[4]
		data = params[5]
		
printf(1,
"fptr:\n%08x\t%08x\n%08x\t%08x\n%08x\t%08x\n%08x\t%08x\n%08x\t%08x\t%08x\t%08x\t%08x\n",
{total_file_size1, total_file_size2,
total_bytes_transferred1,total_bytes_transferred2,
stream_size1, stream_size2, stream_bytes_transferred1,
stream_bytes_transferred2,
			 stream_number, call_back_reason, source_file, destination_file, data } )
		return 0
end function

constant 
fptr    = call_back_stdcall( routine_id("cb_fptr"), 13 ),
source  = allocate_string( "test_copy_source.txt" ),
dest    = allocate_string( "test_copy_dest.txt" ),
lpData  = allocate( 4 ),
cancel  = allocate( 4 )
poke4( cancel, 0 )

printf(1,"lpData: %08x\n", lpData )
? c_func( xCopyFileEx, { source, dest, fptr, lpData, cancel, 0 })
puts(1,"Done\n")
include get.e
abort(wait_key())

 

Matt Lewis

new topic     » goto parent     » topic index » view message » categorize

3. RE: CopyFileEx API Call

Thanks to Matt for the tip. I was hoping there might be a workaround 
for this problem but was unable to find anything in the archives. 

Larry Miller

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu