-
Feb 23rd, 2017, 07:33 AM
#41
Member
Re: [VB6] Use IFileOperation to replace SHFileOperation for modern Copy/Move box/prom
Hi fafalone, First - THANK YOU for this!
I am not actually using the class, but took out the necessary parts I needed to do a basic move operation and it works fine. However, both my code and also in the class invokes an interface function like so:
In MoveFile function for instance:
iFileOp.PerformOperations
Not:
retval = iFileOp.PerformOperations
which won't work. How do I get the return value from the PerformOperations function? Surely there's a way as that's important to know what the error return code is!??
In other words, all the "functions" seem to be declared as Subs in the tlb and thus not returning their hresult/long. Yet that hresult is key to knowing what went wrong. For example, if the move didn't succeed, that hresult tells you why.
What am I missing? Is there some other way I'm supposed to be getting the return value of those interface functions?
EDIT: I ran across your notes for the TLB and see this problem is a common one. I don't understand why you declared them as HRESULT in the TLB if VB treats those as Subs? I also am not clear at all how to use the SwapvTableEntry thing to get the return value. Is there another way? What do I need to do?
Last edited by chrislong2; Feb 23rd, 2017 at 08:27 AM.
-
Feb 23rd, 2017, 09:26 PM
#42
Re: [VB6] Use IFileOperation to replace SHFileOperation for modern Copy/Move box/prom
It's declared as an HRESULT because that's the default; it's not that HRESULT by definition is a Sub, that's something that VB forces behind the scenes. If you used it in another language, it would have a return value.
Changing it to a Long to get the return value has a consequence; any interface that has a return other than HRESULT cannot be implemented in VB (Implements)- that's why oleexmpimp.tlb exists, because it contains alternate versions of interfaces that do have non-HRESULT returns.
To get the return values, the TLB itself has to be changed. Swapping the v-table entry is only for when you're sending a return from your program, not receiving one, in an interface you're implementing yourself (e.g. IFileOperationProgressSink).
Since it's very uncommon to implement IFileOperation yourself, I'll go ahead and change it in the next version. I'll post the next version sometime in the next few days (as there's unrelated updates for a new version that I'm in the middle of), until then, there's two options:
1) Use IFileOperationProgressSink. In each 'Post' event, e.g. PostCopyItem, and after each series of operations, FinishOperations, the HRESULT of that particular operation is returned as one of the parameters. This has the added benefit of telling you precisely which operations failed if you were working with more than 1 file.
2) Modify the TLB yourself; IFileOperation is in exp_main.odl; change HRESULT to long, then recompile. Please do not distribute a modified TLB (a program compiled with it is fine though, as the TLB shouldn't be included with a compiled app).
Last edited by fafalone; Feb 23rd, 2017 at 09:38 PM.
-
Feb 23rd, 2017, 09:54 PM
#43
Member
Re: [VB6] Use IFileOperation to replace SHFileOperation for modern Copy/Move box/prom
Originally Posted by fafalone
Since it's very uncommon to implement IFileOperation yourself, I'll go ahead and change it in the next version. I'll post the next version sometime in the next few days
Thank you so much for the explanation! I don't have VC6 installed anymore so am not easily set up to create a TLB and I don't really need the callback function so I'll just wait for your version update - thank you!
-
Mar 1st, 2017, 07:12 PM
#44
Re: [VB6] Use IFileOperation to replace SHFileOperation for modern Copy/Move box/prom
The updated TLB has been posted in the main oleexp thread.
-
Mar 1st, 2017, 07:41 PM
#45
Member
Re: [VB6] Use IFileOperation to replace SHFileOperation for modern Copy/Move box/prom
Thanks so much fafalone!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|