EDN Admin
Well-known member
Hi, I used GloballAlloc here:
<pre>...
case IDC_NC2:
int len1;
LPSTR nome;
// Nome de Login
len1 = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDIT2));
nome = (LPSTR)GlobalAlloc(GPTR, len1 + 1);
SendMessage(GetDlgItem(hwnd, IDC_EDIT2), WM_GETTEXT, len1 + 1, (LPARAM)nome);
<br/>...
//There is some code here, it doesnt matter
...<br/>
GlobalFree((HANDLE)nome);
break;[/code]
Well, when the program gets to the GlobalFree part then it shows up an error messsage: <br/>
<br/>
"Windows has triggered a breakpoint in Login-Teste.exe.
This may be due to a corruption of the heap, which indicates a bug in Login-Teste.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while Login-Teste.exe has focus.
The output window may have more diagnostic information. "<br/>
<br/>
Why is it happening?
View the full article
<pre>...
case IDC_NC2:
int len1;
LPSTR nome;
// Nome de Login
len1 = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDIT2));
nome = (LPSTR)GlobalAlloc(GPTR, len1 + 1);
SendMessage(GetDlgItem(hwnd, IDC_EDIT2), WM_GETTEXT, len1 + 1, (LPARAM)nome);
<br/>...
//There is some code here, it doesnt matter
...<br/>
GlobalFree((HANDLE)nome);
break;[/code]
Well, when the program gets to the GlobalFree part then it shows up an error messsage: <br/>
<br/>
"Windows has triggered a breakpoint in Login-Teste.exe.
This may be due to a corruption of the heap, which indicates a bug in Login-Teste.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while Login-Teste.exe has focus.
The output window may have more diagnostic information. "<br/>
<br/>
Why is it happening?
View the full article