hey guys im currently working on a ftp client and it seems that when I start to transfer the file is when it messes up. Everything works fine and it seems to transfer the file but no file is transfered. Heres the source:


WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

mov eax,uMsg
.if eax==WM_INITDIALOG
push hWin
pop hWnd
.elseif eax==WM_COMMAND
mov eax,wParam
and eax,0FFFFh
.if eax==IDM_FILE_EXIT
invoke SendMessage,hWin,WM_CLOSE,0,0
.elseif eax==IDM_HELP_ABOUT
invoke ShellAbout,hWin,addr AppName,addr AboutMsg,NULL
.elseif wParam==1001
invoke InternetOpen,addr ftpname,INTERNET_OPEN_TYPE_DIRECT,0,0,0
.if eax==NULL
invoke MessageBox,hWin,addr errortxt,addr errorcap,MB_OK
.else
mov return,eax
invoke MessageBox,hWin,addr openedtxt,addr openedcap,MB_OK
.endif
.elseif wParam==1002
invoke InternetConnect,return,addr ftpserv,INTERNET_DEFAULT_FTP_PORT,addr usrname,addr pword,INTERNET_SERVICE_FTP,0,0
.if eax==NULL
invoke MessageBox,hWin,addr errortxt,addr errorcap,MB_OK
.else
mov ftphandle,eax
invoke SetDlgItemInt,hWin,IDC_EDT1,ftphandle,NULL
invoke MessageBox,hWin,addr ftptxt,addr ftpcap,MB_OK
.endif
.elseif wParam==1004
invoke FtpGetFile,ftphandle,addr aj,addr josh,0,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_BINARY,NULL
.endif
; .elseif eax==WM_SIZE
.elseif eax==WM_CLOSE
invoke InternetCloseHandle,return
invoke InternetCloseHandle,ftphandle
invoke DestroyWindow,hWin
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret

WndProc endp


and heres the .inc



include windows.inc
include user32.inc
include kernel32.inc
include shell32.inc
include comctl32.inc
include comdlg32.inc
include wininet.inc

includelib user32.lib
includelib kernel32.lib
includelib shell32.lib
includelib comctl32.lib
includelib comdlg32.lib
includelib wininet.lib

WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD

.const

IDM_FILE_EXIT equ 10001
IDM_HELP_ABOUT equ 10101
IDC_BTN1 equ 1001
IDC_BTN2 equ 1002
IDC_EDT1 equ 1003
IDC_BTN3 equ 1004

.data

ClassName db 'DLGCLASS',0
MenuName db 'MyMenu',0
DlgName db 'MyDialog',0
AppName db 'Dialog as main',0
AboutMsg db 'MASM32 RadASM Dialog as main',13,10,'Copyright ? MASM32 2001',0
ftpname db 'Ftp Direct',0
errortxt db 'Error',0
errorcap db 'Error',0
openedtxt db 'Internet Opened Successfully!',0
openedcap db 'Success!',0
ftptxt db 'FTP Session Started Successfully!',0
ftpcap db 'Success!',0
ftpserv db 'ftp.*********.com',0
usrname db '*Edited*',0
pword db '*Edited*',0
dltxt db 'Download Success! Check Joshs folder',0ah
db 'for the file',0
dlcap db 'Success!',0
aj db 'aj.html',0
josh db 'C:\Documents and Settings\P\Desktop\J\aj.html',0


.data?

hInstance dd ?
CommandLine dd ?
hWnd dd ?
return dd ?
ftphandle dd ?
any help on this is VERY much appreciated thx..
Posted on 2002-09-02 22:13:45 by resistance_is_futile
Well you should check for errors after FtpGetFile, that may explain whats going wrong. Otherwise the code seems ok.
Posted on 2002-09-03 05:14:44 by Eóin
wouldnt that be like invoke getlasterror or something like that??
Posted on 2002-09-03 22:03:36 by resistance_is_futile
is there anyone else that can help me on this? please i really need help on this one because this is my first real big project and i want to finish it..I appreciate the help I have received already but would like more because i cant seem to figure out whats going wrong..
Posted on 2002-09-04 21:13:33 by resistance_is_futile
Not to familiar with wininet myself but I suggest checking for error after
invoke FtpGetFile,.....



.elseif wParam==1004
invoke FtpGetFile,ftphandle,addr aj,addr josh,0,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_BINARY,NULL
.if eax==NULL
Invoke GetLastError
; Check error code here
.endif
.endif


WinInet Error Codes
Posted on 2002-09-05 00:28:01 by WillASM
I tried this and it didnt work :confused:



.elseif wParam==1004
invoke FtpGetFile,ftphandle,addr aj,addr josh,FALSE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_BINARY,NULL
.if eax==NULL
invoke GetLastError
invoke MessageBox,hWin,eax,addr ok,MB_OK
.endif

.endif
.elseif wParam==1004
invoke FtpGetFile,ftphandle,addr aj,addr josh,FALSE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_BINARY,NULL
.if eax==NULL
invoke GetLastError
invoke MessageBox,hWin,eax,addr ok,MB_OK
.endif

.endif


??
Posted on 2002-09-07 10:36:55 by resistance_is_futile
GetLastError returns a value in eax not a pointer to a string.
Use FormatMessage to get the error message string.
Posted on 2002-09-08 11:51:35 by WillASM
Try this marco
ErrorMessage macro

IFNDEF ErrorMessage_lpmsg
.data?
ErrorMessage_lpmsg dd ?
.code
ENDIF
call GetLastError
invoke FormatMessage, FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM, NULL, eax, LANG_NEUTRAL,\
ADDR ErrorMessage_lpmsg,0,NULL
invoke MessageBox, NULL, ErrorMessage_lpmsg, 0, MB_OK
invoke LocalFree, ErrorMessage_lpmsg
endm
Posted on 2002-09-09 08:32:02 by roticv