-3

I'm using d7zip for my project, everything worked very well as check list, compression, decompression, progress bar...

But I do not know how to abort compression or decompression. I checked the source code LZMA SDK but did not find anything.

Anything that can help me easier?

nguyentu
  • 45
  • 3
  • 8

1 Answers1

0

In your progress callback, try returning an error HRESULT value instead of S_OK or S_FALSE.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • I tried to return to `ERROR_CANCELLED` and it did nothing more – nguyentu Aug 11 '16 at 03:14
  • 1
    @nguyentu Try to use E_ABORT. – Denis Anisimov Aug 11 '16 at 03:47
  • Tried, nothing is executed except the finally block – nguyentu Aug 11 '16 at 03:50
  • 3
    @nguyentu: `ERROR_CANCELLED` is not an `HRESULT` value, `E_ABORT` is. `HRESULT` success values are positive, error values are negative. Regular Win32 error codes are positive. If you want to return a Win32 error code, wrap it with `HRESULT_FROM_WIN32()`, eg: `Result := HRESULT_FROM_WIN32(ERROR_CANCELLED);` – Remy Lebeau Aug 11 '16 at 04:01
  • 2
    @nguyentu: Did you verify that *any* of the callbacks are actually being called during compression/decompression? Please show your actual code. If the callbacks are being called, but returning an error code from them is not working, then I have to think that either d7zip is not hooking them up correctly internally (more likely), or 7zip is ignoring them (less likely). – Remy Lebeau Aug 11 '16 at 04:02
  • sorry because it was not clear. It work but nothing is executed after the process is canceled except the finally block but I want the thread is continued – nguyentu Aug 11 '16 at 04:22
  • 1
    There is likely an exception being thrown when an operation fails. Wrap the operation in a `try/except` block and move on. – Remy Lebeau Aug 11 '16 at 04:32
  • @nguyentu, So what was the problem/solution? – kobik Aug 11 '16 at 10:42
  • @kobik my problem I don't know how to abort the process of compression or decompression, my solution return `E_ABORT` on callback – nguyentu Aug 11 '16 at 11:29