C++ Window Scanner
<p>Need help with the loop. My Idea was scann for windows and when a window found check its procces Id so if the window was already found dont try to find it again. A piece from my code is like that:</p>

<pre><code>if (Selection == 1)
{
    cout &lt;&lt; endl &lt;&lt; "================================= Scan Result =================================" &lt;&lt; endl;
    cout &lt;&lt; endl &lt;&lt; "Scan Log:                                                        Times Found: " &lt;&lt; TimesFound &lt;&lt; endl;
    cout &lt;&lt; "   - Scanning windows..." &lt;&lt; endl;

    while(PressedKey != 27)
    {
        if (kbhit())
        {
            PressedKey = getch();
        }

        HWND WindowFound = FindWindow(0, "Untitled - Notepad");

        if (WindowFound != 0) 
        {
                            // My Idea was compare the procces Id of the found window
                            // to learn the found window was already found
            DWORD ProcessId;
            GetWindowThreadProcessId(WindowFound, &amp;ProcessId);

            if(ProcessId != OtherId)
            {
                TimesFound++;
                cout &lt;&lt; "Window found ! Times found: " &lt;&lt; TimesFound &lt;&lt; endl;
            }
        }
    }
}
</code></pre>

<p>I hope you guys can help me. Cheers</p>

<p>Edit: New Code</p>

<pre><code>BOOL CALLBACK EnumFunc(HWND hwnd, LPARAM lParam)
{
    wchar_t lpString[32];

    GetWindowText(hwnd, (LPSTR)lpString, _countof(lpString));

    if(wcscmp(lpString, L"Untitled - Notepad") == 0) 
    {
        *((int *)lParam)++;
    }

    return TRUE;
}
</code></pre>

<p>This part of *((int *)lParam)++; code not works. Error is: expression must be a modifiable lvalue @MikeKwan</p>

<p>Edit: Me with same question again @MikeKwan :)</p>

<pre><code>    while(PressedKey != 27)
    {
        if (kbhit())
        {
            PressedKey = getch();
            printf("Times found: %d \n", TimesFound);
        }

        EnumWindows(EnumFunc, (LPARAM)&amp;TimesFound);
    }
</code></pre>

<p>I use this code to detect window every time but It detects a window and it redetects the same window again and again so nothing is changed :/</p>
