Re: DLL question

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hallvard Ystad wrote:
> 
> Hello folks,
> 
> I found the URL Moniker wrapper in the archive and wonder how to download a
> URL, not to a file, but to a string.
> 
> I looked at the urlmon.dll file and found what looks to me like several method
> names indicating it should be possible, but I know too little about this dll.
> 
> Does anyone know how to accomplish it?
> 
> Thanks,
> HY

Hello HY,

This is what I use:

include urlmon.ew
--
 atom lastTime,lastProgress
function OnProgress(atom progress,atom progressMax,atom status,atom statusText)
	atom t,dt,speed
	if status=URLMON_BEGINDOWNLOADDATA then
		puts(1,"Starting download\n")
	elsif status=URLMON_ENDDOWNLOADDATA then
		puts(1,"\n\nDownload finished!*\n")
	elsif status=URLMON_DOWNLOADINGDATA then
		t = time()
		dt = t-lastTime
		if dt=0 then dt=0.001 end if
		speed = (progress-lastProgress)/dt
		if speed=0 then speed=0.001 end if
		lastTime = t
		lastProgress = progress
		position(5,1)
		printf(1,"%d of %d kB done at %1.2f kB/s. %d seconds remaining        ",
			floor({progress,progressMax,speed,(progressMax-progress)/speed}/1024))
		puts(1,"\nPress [ESC] to abort download")
	elsif status=URLMON_CONNECTING then
		puts(1,"Connecting to host..\n")
	elsif status=URLMON_SENDINGREQUEST then
		puts(1,"Requesting file..\n")
	end if
	if get_key()=27 then
		puts(1,"\n\nDownload aborted!\n")
--pause()
		return URLMON_ABORT
	end if
	return 0
end function

------------------------------start of program-------------------------
-------------------------download----------------------------
global procedure download(sequence webpage,sequence asp_loc)
  atom result,fn3
puts(1,"Starting Program...\n")
  fn3=open(asp_loc,"w")
?fn3

  close (fn3)
lastTime = time()
lastProgress = 0
   result =  URLDownloadToFile(webpage, 
		   asp_loc,
	        call_back(routine_id("OnProgress")),
		   0)
if result then
	puts(1,"Download failed!*\n")
?result
--pause()
end if
for x= 1 to 10 do
?x
end for
end procedure

Don Cole

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu