Click to Rate and Give Feedback
MSDN
MSDN Library
COM
COM Fundamentals
Reference
Functions
 CoTaskMemFree Function
CoTaskMemFree Function

Frees a block of task memory previously allocated through a call to the CoTaskMemAlloc or CoTaskMemRealloc function.

Syntax

C++
void CoTaskMemFree(
  __in_opt  LPVOID pv
);

Parameters

pv [in, optional]

A pointer to the memory block to be freed. If this parameter is NULL, the function has no effect.

Return Value

This function does not return a value.

Remarks

The CoTaskMemFree function uses the default OLE allocator.

The number of bytes freed equals the number of bytes that were originally allocated or reallocated. After the call, the memory block pointed to by pv is invalid and can no longer be used.

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderObjbase.h
LibraryOle32.lib
DLLOle32.dll

See Also

CoTaskMemAlloc
CoTaskMemRealloc
IMalloc::Free

Send comments about this topic to Microsoft

Build date: 10/22/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
vb.net syntax      dmex   |   Edit   |   Show History
<DllImport("ole32.dll")> _
Public Shared Sub CoTaskMemFree(ByVal ptr As IntPtr)
End Sub
Flag as ContentBug
C# syntax      dmex   |   Edit   |   Show History
[DllImport("ole32.dll")]
public static extern void CoTaskMemFree(IntPtr ptr);
Tags What's this?: c# (x) syntax (x) Add a tag
Flag as ContentBug
Why P/Invoke?      joechung   |   Edit   |   Show History
Why bother with those P/Invoke methods when you can just call Marshal.FreeCoTaskMem?
Tags What's this?: c# (x) syntax (x) vb.net (x) Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker