SetProcessDataProc

From TotalcmdWiki
Jump to: navigation, search

This function allows you to notify user about the progress when you un/pack files.

 void __stdcall SetProcessDataProc (HANDLE hArcData, tProcessDataProc pProcessDataProc);

Description

pProcessDataProc contains a pointer to a function that you may want to call when notifying user about the progress being made when you pack or extract files from an archive. You need to store the value at some place if you want to use it; you can use hArcData that you have returned by OpenArchive to identify that place.

Take care when to store that function pointer global, and when you should store it together with your own archive data, identified by hArcData. For list/test/unpack operations you can safely use hArcData, but for PackFiles you have no choice but to store it global, as this operation is not bound to an archive "handle". To identify this, you need to look at the hArcData value:
Although a HANDLE is a Windows API data type, the same rule is applied to identify errors:
INVALID_HANDLE_VALUE will be returned when the call to that function is not linked to a list/test/unpack operation, which will most likely be before a call to PackFiles. You should therefore not expect a null pointer, but INVALID_HANDLE_VALUE, which is defined as -1, or 0xFFFFFFFF (32-bit). This means that before starting PackFiles you best copy that global value to your own data structure, and use it until the function call is finished.

Also take care not to use the same function pointer for subsequent pack/unpack operations. If you defined your plug-in to be thread-safe (through GetBackgroundFlags), you should always use the most recent pointer, as that function will probably be different for every parallel operation.



Back to Packer plugins developer guide Back to Packer plugins developer guide overview Back to TProcessDataProc