NO

Author Topic: GetEnvironmentStrings and HeapLock  (Read 3993 times)

czerny

  • Guest
GetEnvironmentStrings and HeapLock
« on: March 27, 2013, 06:02:52 PM »
Hallo!

I have the following code:
Code: [Select]
HANDLE hHeap = GlobalHandle(GetEnvironmentStrings());
PROCESS_HEAP_ENTRY Entry;

if (!hHeap) return 0;

if (HeapLock(hHeap) == FALSE) {
        wprintf(L"Failed to lock heap with LastError %d.\n", GetLastError());
        return 1;
}
What are the most likely causes that HeapLock fails?

Offline jj2007

  • Member
  • *
  • Posts: 536
Re: GetEnvironmentStrings and HeapLock
« Reply #1 on: March 27, 2013, 06:22:58 PM »
You are mixing global and heap functions here:

GlobalHandle

The global functions have greater overhead and provide fewer features than other memory management functions. New applications should use the heap functions