Pelles C forum

C language => Windows questions => Topic started by: czerny on March 27, 2013, 06:02:52 PM

Title: GetEnvironmentStrings and HeapLock
Post by: czerny 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?
Title: Re: GetEnvironmentStrings and HeapLock
Post by: jj2007 on March 27, 2013, 06:22:58 PM
You are mixing global and heap functions here:

GlobalHandle (http://msdn.microsoft.com/en-us/library/windows/desktop/aa366582%28v=vs.85%29.aspx)

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