I'm making a small download program . And I would like to make it useble via Internet explorer .
(like Flash get ) .But how to integrate it in i-net explorer and make it call my program .
how to make I-net explorer call my program sending to it a http addres of a file to download .
Posted on 2004-07-04 13:47:38 by Gangleri
BHO - Browser Helper Object - essentially a dll you code which is registered to the os so that when ie loads , your dll is loaded.
Posted on 2004-07-05 01:26:06 by Homer
can you post you code?
Posted on 2004-07-10 21:59:40 by bgcq
You can read all about it here :

BHO
Posted on 2004-07-10 22:18:43 by donkey
here is the code . I've been playing with it for some time :



.386
.model flat, stdcall
option casemap:none
include windows.inc
include kernel32.inc
includelib kernel32.lib
include wininet.inc
includelib wininet.lib
include shell32.inc
includelib shell32.lib
include user32.inc
includelib user32.lib
include masm32.inc
includelib masm32.lib
include comdlg32.inc
includelib comdlg32.lib

.data
agent db "PamPamTadam",0
Err1 db "NoWhere to save the file",0
open db "open",0
titl db "Minidownloader",0
MSGopenF db "File Download Ready . Do you want to open the file ?",0
szFilter db "All files (*.*)", 0, "*.*", 0
.data?
szOFNBuffer db 512 dup (?)
FileName db 512 dup (?)
URL db 512 dup (?)
ihwn HWND ?
fdown HWND ?
hFile HWND ?
ofn OPENFILENAME <?>
.code
start:
DownloadFile PROTO :DWORD,:DWORD
SavFile PROTO

invoke GetCL,1,addr URL
.if eax==1
jmp @F
.else
invoke MessageBox,0,0,0,MB_OK
jmp exit
.endif
@@:
invoke SavFile
invoke MessageBox,0,offset URL,offset FileName,MB_OK
invoke DownloadFile,addr URL,addr FileName
invoke MessageBox,0,addr MSGopenF,addr titl,MB_YESNO
.if eax==IDYES
invoke ShellExecute,0,addr open,addr FileName,0,0,SW_SHOW
.endif

exit :
invoke ExitProcess,0
DownloadFile proc FromURL:DWORD,ToFile:DWORD
LOCAL Bufferlen :DWORD
LOCAL bwrite :DWORD
LOCAL BigBuffer[4096] :BYTE
LOCAL BytesReceived :DWORD
invoke InternetOpen,addr agent,INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0
mov ihwn,eax
invoke InternetOpenUrl,ihwn,FromURL,0,0,INTERNET_FLAG_RELOAD,0
mov fdown,eax
invoke CreateFile,ToFile,GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL
mov hFile,eax
mov BytesReceived,0
@@:
invoke InternetReadFile,fdown,addr BigBuffer,sizeof BigBuffer,addr Bufferlen
invoke WriteFile,hFile,addr BigBuffer,Bufferlen,ADDR bwrite,NULL
mov eax,Bufferlen
mov ebx,BytesReceived
add eax,ebx
mov BytesReceived,eax
mov ebx,Bufferlen
cmp ebx,0
jne @B
invoke InternetCloseHandle,ihwn
invoke InternetCloseHandle,fdown
ret
DownloadFile endp
SavFile proc
mov ofn.lStructSize, sizeof OPENFILENAME
push 0
pop ofn.hwndOwner
mov ofn.hInstance, 40000h
mov ofn.lpstrFilter, offset szFilter
mov ofn.lpstrFile, offset szOFNBuffer
mov ofn.nMaxFile, 512
mov ofn.lpstrTitle, offset titl
mov ofn.Flags, OFN_EXPLORER or OFN_FILEMUSTEXIST or OFN_HIDEREADONLY
invoke GetSaveFileName,offset ofn
invoke lstrlen,addr szOFNBuffer
.if eax==0
invoke MessageBox,0,offset Err1,offset titl,MB_OK
jmp exit
.endif
invoke lstrcpy, addr FileName, addr szOFNBuffer
invoke RtlZeroMemory, addr szOFNBuffer, 512
ret
SavFile endp
end start
Posted on 2004-07-12 11:29:28 by Gangleri
Hi Gangleri,

Thanks for your example code :alright:
Posted on 2004-07-12 13:07:07 by Vortex
I'm always happy to help
Posted on 2004-07-12 17:20:17 by Gangleri
Hello,

I am just up to download a file directly into memory. So, I have written a long, but working code to get the file length. Then, I allocate some memory and put the downloaded file into it. The problem is that there are only chaotic ASCII-Chars when I want to put this text into a label. I know the use of lstrcat is problematic as there might be nullchars in the downloaded text, but I'm sure there are no in my test-text.

Is there anybody who sees a problem:


LOCAL Buff[1024]: BYTE

invoke InternetOpen,
ADDR szUserAgent,
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,
NULL,
0

mov hOpen, eax

invoke InternetConnect,
hOpen,
ADDR szUrl,
INTERNET_DEFAULT_HTTP_PORT,
NULL,
NULL,
INTERNET_SERVICE_HTTP,
0,
0

mov hInternet, eax

;here is a code for reading the file size and putting it into FileSize
;I am really sure this code is working as I have tested it several times

invoke GlobalAlloc,
GPTR,
FileSize

mov hFileMem, eax

invoke InternetOpenUrlA,
hInternet,
ADDR szFullUrl,
NULL,
NULL,
NULL,
NULL

mov hFile, eax

DownloadLoop:

invoke InternetReadFile,
hFile,
ADDR Buff,
sizeof Buff,
ADDR BufferSize

invoke lstrcat,
hFileMem,
ADDR Buff

cmp BufferSize, sizeof Buff
je DownloadLoop

invoke SetWindowText,
hLabel,
hFileMem

invoke GlobalFree,
hFileMem


I can publish the code to get the filesize if you like, but by this time I just wanted that the code is concise.

Regards,
Claus
Posted on 2004-07-13 06:21:52 by ndn4u
Hello,

is there anyone reading this thread any more?
It would be nice if someone could give some help.

Regards,
Claus
Posted on 2004-07-14 12:08:02 by ndn4u