C++ console question

Posts 1–7 of 7 · Page 1 of 1
C++ console question
Sorry but I am new to C++ and work mainly in VB.net
How can I Code my Console app to wait for my games process to be opened ?
I have tried some do whiles but they failed .
And I have looked for an example but have not found one that is right .
Everything else is working correctly I just can not seem to get that part correct .
Please remember I am very very new to the c language .
And i never really tried to code any project to wait for an .exe i would just have it throw an error message .
Any decent example would be great thank's .
convert this logic into C++:

while the handle is invalid keep looping and call the openhandle function.
Quote Originally Posted by ~BlackMaster~ View Post
convert this logic into C++:

while the handle is invalid keep looping and call the openhandle function.
I do better with a visual example I would think a do while would work but i have not had any luck . So I searched for some examples to which I could not find any so i turned to this post . And in my opinion a tutorial on just suck a thing should be on here really .
Quote Originally Posted by HOOSIER View Post
I do better with a visual example I would think a do while would work but i have not had any luck . So I searched for some examples to which I could not find any so i turned to this post . And in my opinion a tutorial on just suck a thing should be on here really .
Code:
//inside your main function
HWND tarWnd = NULL;

std::cout << "Searching for window: Example name\n";

while(tarWnd == NULL)
{
    tarWnd = FindWindow(NULL, "Example name");
}

std::cout << "Window: "Example name"  found! Executing program.\n";
Something like this? (This will look for the window, but looking for the actual process will be pretty much the same)
Quote Originally Posted by 1d1c7ad89cf1e2f3 View Post
Code:
//inside your main function
HWND tarWnd = NULL;

std::cout << "Searching for window: Example name\n";

while(tarWnd == NULL)
{
    tarWnd = FindWindow(NULL, "Example name");
}

std::cout << "Window: "Example name"  found! Executing program.\n";
Something like this? (This will look for the window, but looking for the actual process will be pretty much the same)
Thank's you
That's not the right answer tbh but ok !
Quote Originally Posted by SpyLegion View Post
That's not the right answer tbh but ok !
If you know the id it will work. Else you can create a snapshot of the processes, enumerate 'em all comparing szExeName or w/e the member's name was.

Care to explain why the logic is wrong?
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us