ws1999
asked on
about buffer
ask this question for my friend,his code:
var
Buffer: Pointer;
begin
Buffer := Pointer(LocalAlloc( LPTR, dwSizeofDataToWrite+1 ));
He told me that when use locafree, error message is found.
How to solve this problem, buffer cannot use localfree?
var
Buffer: Pointer;
begin
Buffer := Pointer(LocalAlloc( LPTR, dwSizeofDataToWrite+1 ));
He told me that when use locafree, error message is found.
How to solve this problem, buffer cannot use localfree?
var
ptr : pointer;
begin
ptr := pointer(LocalAlloc(lptr, 1024));
lstrcpy(ptr, 'I was here!');
ShowMessage(pchar(ptr));
LocalFree(cardinal(ptr));
end;
Work's fine. Allocates, writes, reads, frees - no problems...
ptr : pointer;
begin
ptr := pointer(LocalAlloc(lptr, 1024));
lstrcpy(ptr, 'I was here!');
ShowMessage(pchar(ptr));
LocalFree(cardinal(ptr));
end;
Work's fine. Allocates, writes, reads, frees - no problems...
what is that error message?
are you sure you don't try to free the buffer twice?
are you sure you don't try to free the buffer twice?
ASKER
Sorry for late reply, the problem indeed comes from the thread using, the question is, is it possible before the main thread completed setup, the child thread can take function?
Sorry again, and 50 ponts added.
Sorry again, and 50 ponts added.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This works for me:
var
Buffer : Pointer;
begin
Buffer := Pointer( LocalAlloc( LPTR, 1024 ) );
LocalFree( Cardinal(Buffer) );
end;