What you need to do is to get a reference of the object in use without increasing the reference counter. You can do that if you have the address of the object, and use CopyMemory to copy this address into a new reference variable. However you must then remove this reference by making the reference variable point to NULL, you do that simply by copy 0, to the reference variable. So your callback procedure should look like this:You have FilesClass already declared, however I personally would move that declaration into the function as a local variable. I haven't done that above since I didn't want to make to much of a change to your code.vb Code:
Public Function CopyProgressRoutine(ByVal TotalFileSize As Currency, ByVal TotalBytesTransferred As Currency, ByVal StreamSize As Currency, ByVal StreamBytesTransferred As Currency, ByVal dwStreamNumber As Long, ByVal dwCallbackReason As Long, ByVal hSourceFile As Long, ByVal hDestinationFile As Long, ByVal lpData As Long) As Long Dim Pr As Double Dim DataPointer As Long Dim CfilesCopyFrame As ClsFiles Dim CfilesCopyContent As ClsFiles ' Recieved = lpData Pr = (TotalBytesTransferred * 10000) / (TotalFileSize * 10000) * 100 CopyMemory FilesClass, lpData, 4 FilesClass.ShowProgress Pr, "Test" CopyMemory FilesClass, 0, 4 'continue filecopy CopyProgressRoutine = PROGRESS_CONTINUE End Function
You must also change the code in your class module where you call CopyFilesEx, you almost had the correct code in the line you had comment out. The only difference is that you must pass the ObjPtr byval otherwise you pass a pointer to that pointer....Good luck!vb Code:
Ret = CopyFileEx(source, Target, AddressOf CopyProgressRoutine, ByVal ObjPtr(Me), bCancel, COPY_FILE_RESTARTABLE)




Reply With Quote