Jump to content

heaplock example


Recommended Posts


Not sure what for, or in what language. So I'll assume VC++ and doing nothing else besides lock/unlock...


#include <windows.h>
#include <iostream>

void main()
{
HANDLE hHeap = GetProcessHeap(); //or HeapCreate
if(hHeap == 0)
{
printf("GetProcessHeap error %d\r\n", GetLastError());
return;
}
if(!HeapLock(hHeap))
{
printf("HeapLock error %d\r\n", GetLastError());
return;
}

//do something with it...

if(!HeapUnlock(hHeap))
{
printf("HeapUnlock error %u\r\n", GetLastError());
return;
}
}

Edit: looks like Glen9999 beat me to it, and with nicer code too (and it's unicode...) Oh well :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...