Announcement

Collapse
No announcement yet.

Wie verwendet man SystemParametersInfo(***);

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Wie verwendet man SystemParametersInfo(***);

    Hallo, ich brauche informationen über den Monitor bzw. über den Bildschimrschoner (ob Aktive[Energiesparfunktion] und wann Abschaltung).
    Bin ich dort mit der Function SystemParametersInfo(***) richtig Oder nicht.
    und wenn ja WARUM FUNKTIONIERT DER SCXHEISS NICHT!?
    Muß ich irgend etwas beachten?

  • #2
    Hallo,

    das Verhalten hängt an dieser Stelle davon ab, welche Windows-Version verwendet wird. Microsoft hat dazu u.a. folgendes veröffentlicht:

    <i>
    Sometimes applications need to terminate a screensaver that is already running. In Windows 3.1 or Windows 95, a screensaver could be terminated easily by posting a WM_CLOSE message to the currently active screensaver window as in this example:
    <pre>
    PostMessage (GetActiveWindow(), WM_CLOSE, 0, 0L);
    </pre>
    Windows NT, however, introduces the concept of separate desktops, so that applications can run on one, and screen savers can run on another. This makes screensaver termination under Windows NT a bit more difficult.

    MORE INFORMATION

    Under Windows NT, obtaining a handle to the currently active screensaver window is not as straightforward as it is in Windows 3.1 and Windows 95. Calling GetForegroundWindow() returns NULL because the screensaver is running on a different desktop than the calling application. Similarly, calling FindWindow ("WindowsScreenSaverClass", NULL) to determine if the screen saver is currently active won't work either. The way to do it is to get a handle to the screen saver's desktop, enumerate that desktop's windows, and then post a WM_CLOSE to the screen saver window. The following code demonstrates how to do this. Note that if a screen saver password is set, the following code brings up the password dialog box,
    prompts the user for a password, and then actually terminating the screen saver application.
    <pre>
    BOOL CALLBACK KillScreenSaverFunc(HWND hwnd, LPARAM lParam)
    {
    PostMessage(hwnd, WM_CLOSE, 0, 0);
    return TRUE;
    }

    HDESK hdesk;

    hdesk = OpenDesktop(TEXT("Screen-saver"),
    0,
    FALSE,
    DESKTOP_READOBJECTS | DESKTOP_WRITEOBJECTS);
    if (hdesk)
    {
    EnumDesktopWindows(hdesk, KillScreenSaverFunc, 0);
    CloseDesktop(hdesk);
    }
    </pre>
    Note that terminating a screensaver that is already running as demonstrated above is totally separate from disabling the screen saver altogether, so that no screen saver starts after the designated time period expires. This can be done easily using:
    <pre>
    SystemParametersInfo( SPI_SETSCREENSAVEACTIVE,
    FALSE,
    0,
    SPIF_SENDWININICHANGE
    );
    </pre>
    This method works well for terminating the currently running screen saver. However, one problem that you might encounter is that the system will not restart the screen saver unless the user moves the mouse or presses a key. If you need the screen saver to start up again, you'll need to reinitialize the time-out period. Do this by:

    #Calling SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, TRUE, 0,
    SPIF_SENDWININICHANGE).

    -or- #Using SetCursorPos() to simulate user input.

    Both of these methods will cause the system to restart the time-out counter for the screen saver. </i&gt

    Comment

    Working...
    X