Is it possible to allocate memory for a function? I'm running a program that consumes massive amounts of memory. I'm also interfacing with this program and checking various states of the program. After the program reaches a specific state, I exit my message loop and destroy my interfacing window through DestoryWindow(). I then proceed to close the memory-intensive program by looping. Here's the gist...
Again, this code will work as long as the computer has not been on for a while, running the memory-intensive program. However, if it has been running the memory-intensive program, this code seems to not exist, and this code does not terminate the memory-intensive program -- even with the loops. That's why I added the loops. I thought they might not have been loaded, but it doesn't seem to matter.
Also, I know I'm consuming a lot of memory as when the computer has been running the memory-intensive program for thirty minutes or so, I receive a message that Windows has adjusted the virtual memory. That's why I'm asking if it's possible to set aside memory for this function. I'm thinking this is my problem.
Again, it seems that if the memory-intensive program has been running for about 30 minutes, my program will terminate the other program. However, if it exceeds thirty minutes, my program seems to stop at the point where I DestroyWindow(MyProgramWindow). I've even added MessageBoxes on the other side of the code, and they don't even appear! My program just seems to terminate nicely, for it's no longer running in the taskmgr. *shrugs*
Any ideas and suggestions into tackling this problem would be much appreciated. Thank you.
Code:
HWND hWndToClose = NULL;
while (!hWndToClose)
{
hWndToClose = FindWindowEx(NULL, NULL, "Class", "Title");
}
PostMessage(hWndToClose, WM_COMMAND, 0x5, 0x0); // File -> Exit
HWND hWndConfirmClose = NULL;
while (!hWndConfirmClose) // Pops up a MessageBox, asking
// for me to confirm exiting
{
hWndConfirmClose = FindWindowEx(NULL, NULL, "Class", "Close?");
}
HWND hWndYes = NULL;
while (!hWndYes)
{
hWndYes = FindWindowEx(NULL, NULL, "Class", "\&Yes");
}
SendMessage(hWndConfirm, WM_COMMAND, MAKELONG(hWndYes, BN_CLICKED), (LPARAM)hWndYes);
Again, this code will work as long as the computer has not been on for a while, running the memory-intensive program. However, if it has been running the memory-intensive program, this code seems to not exist, and this code does not terminate the memory-intensive program -- even with the loops. That's why I added the loops. I thought they might not have been loaded, but it doesn't seem to matter.
Also, I know I'm consuming a lot of memory as when the computer has been running the memory-intensive program for thirty minutes or so, I receive a message that Windows has adjusted the virtual memory. That's why I'm asking if it's possible to set aside memory for this function. I'm thinking this is my problem.
Again, it seems that if the memory-intensive program has been running for about 30 minutes, my program will terminate the other program. However, if it exceeds thirty minutes, my program seems to stop at the point where I DestroyWindow(MyProgramWindow). I've even added MessageBoxes on the other side of the code, and they don't even appear! My program just seems to terminate nicely, for it's no longer running in the taskmgr. *shrugs*
Any ideas and suggestions into tackling this problem would be much appreciated. Thank you.