Well, I'm using Borland C++ Builder, and I don't think that would have much to do with my problem. At the moment, my program works fine on my computer, but not on a friend's. He get's Abnormal Program Termination whenever he hits a button that runs this function:
Code:
//These are global variables:
HWND hWnd[256];
HWND hCur;
AnsiString asHcur;
int iHwnd = 0;
void RefreshHWND()
{
iHwnd = 0;
frmMain->lstProcs->Clear();
HWND hFirst, hNext, hTemp;
hFirst = GetForegroundWindow();
AnsiString asWinfo;
char szWintit[256];
GetWindowText(hFirst, szWintit, GetWindowTextLength(hFirst) + 1);
asWinfo.sprintf("%08X - %s", hFirst, szWintit);
frmMain->lstProcs->AddItem(asWinfo, NULL);
hTemp = hFirst;
hWnd[iHwnd] = hFirst;
while ((hNext = GetNextWindow(hTemp, GW_HWNDNEXT)) != NULL)
{
iHwnd++;
GetWindowText(hNext, szWintit, GetWindowTextLength(hNext) + 1);
asWinfo.sprintf("%08X - %s", hNext, szWintit);
frmMain->lstProcs->AddItem(asWinfo, NULL);
hTemp = hNext;
hWnd[iHwnd] = hNext;
}
}
Is there something wrong with my code that uses too much memory?
(the edit I did was to add in spacing for easier reading)