-
Sep 21st, 2020, 02:17 PM
#1
Thread Starter
Lively Member
CoTaskMemFree vs ILFree
Is anyone else having problems with CoTaskMemFree() crashing the IDE recently when trying to free ITEMIDLIST's?
I have code that i have been using for years is all of a sudden not working on updated Win 10 with no change to the code. Calling cotaskmemfree closes the IDE but ILFree() works fine.
-
Sep 21st, 2020, 02:36 PM
#2
Re: CoTaskMemFree vs ILFree
I'd almost expect the opposite behavior. Per MSDN: "Note When using Windows 2000 or later, use CoTaskMemFree rather than ILFree."
For now, ignore that fact that it was working before. Look at each case you are calling CoTaskMemFree and ensure you are passing the memory address ByVal or ByRef dependent on how you declared the API.
Try to create an example that will crash on demand and post that example here.
-
Sep 21st, 2020, 06:42 PM
#3
Re: CoTaskMemFree vs ILFree
Definitely want to be using CoTaskMemFree.
How exactly are you using id lists? If you're creating the structure and doing manual operations on them, there's a lot more room for issues; especially depending on how you're allocating it.
If you're using pidls allocated and managed by the system, such that you're only ever dealing with a Long containing a pointer to it, you'd generally use it declared with ByVal and just pass the pointer itself, not a pointer to the pointer.
E.g. if you're using a pidl as a long returned from ILCreateFromPath or SHGetFolderLocation, you'd have Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long), then
Dim pidl As Long
pidl = ILCreateFromPath(path)
...
CoTaskMemFree pidl
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
|