News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

wanted help with CopyProgressRoutine

Started by remus2k, November 17, 2006, 07:18:51 PM

Previous topic - Next topic

remus2k

could you help me in this problem

i found in this forum  a CopyProgressRoutine.
if i try to copy it showes my progressbar not correcktly

thanks in forward

[attachment deleted by admin]

six_L

.386
.model flat, stdcall  ;32 bit memory model
option casemap :none  ;case sensitive
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\Comctl32.inc
include \masm32\include\shell32.inc
include \masm32\include\debug.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\Comctl32.lib
includelib \masm32\lib\shell32.lib
includelib \masm32\lib\debug.lib
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DlgProc   PROTO:HWND,:UINT,:WPARAM,:LPARAM
CopyFilez PROTO
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.const
IDD_DIALOG1 equ 101
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data
szfinalpth db "c:\win32asm.zip",0
szcopypath db "e:\win32asm_bak.zip",0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.data?
hInstance dd ?
ThreadID dd ?
hFile dd ?
fSize dd ?
pzdata DWORD ?
hProgress DWORD ?
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
.code
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
start:
invoke GetModuleHandle,NULL
mov    hInstance,eax
invoke InitCommonControls
invoke DialogBoxParam,hInstance,IDD_DIALOG1,NULL,addr DlgProc,NULL
invoke ExitProcess,0
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DlgProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM

.if uMsg==WM_INITDIALOG
invoke GetDlgItem,hWnd,1002
mov hProgress, eax
invoke SendMessage,hProgress,PBM_SETBKCOLOR,0,0FF0000h  ; blue
invoke SendMessage,hProgress,PBM_SETBARCOLOR,0,0FFh ; red
.elseif uMsg==WM_COMMAND
         mov ebx,wParam
.if ebx==1001
          invoke CreateThread,0,0,addr CopyFilez,0,0,addr ThreadID
.endif
.elseif uMsg==WM_CLOSE
invoke EndDialog,hWnd,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret

DlgProc endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
CopyFilez proc

invoke CreateFile,ADDR szfinalpth,GENERIC_READ or GENERIC_WRITE,\
FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL
mov hFile,eax
invoke GetFileSize, hFile, NULL
mov fSize,eax
invoke SendMessage,hProgress,PBM_SETRANGE32,0,fSize
invoke CloseHandle, hFile
push NULL
push FALSE
push offset pzdata
push offset CopyProgressRoutine
push offset szcopypath
push offset szfinalpth
call CopyFileEx
ret

CopyFilez endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
CopyProgressRoutine PROC TotalFileSize:QWORD,TotalBytesTransferred:QWORD,StreamSize:QWORD,StreamBytesTransferred:QWORD,dwStreamNumber:DWORD,dwCallbackReason:DWORD,hSourceFile:DWORD,hDestinationFile:DWORD,lpData:DWORD
LOCAL CurrentBytesTransferring:DWORD

fild [TotalBytesTransferred]
fild [TotalFileSize]
fdiv
fild [fSize]
fmul
fistp [CurrentBytesTransferring]

;// Display progress here
mov eax,[CurrentBytesTransferring]
cmp eax,[fSize]
je @1
invoke SendMessage,hProgress,PBM_SETPOS,CurrentBytesTransferring,0
@1:
ret
CopyProgressRoutine endp
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

end start
regards