Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2004

Tip: Looking for answers? Try searching our database.

HOW TO: Determine If Screen Saver Is Start to Run by Using C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Yan - 30 Mar 2004 11:46 GMT
I would like my application to execute a function if and when the screen saver starts. I have been searching for a way for my program to know that the screen saver has started but the only thing I could find was how to do it in C++ & Visual Basic 6.

The question is How can I determine if screen saver is start to run by using C#

Thanks in advance,
Yan
Gabriele G. Ponti - 31 Mar 2004 16:29 GMT
This is one approach, but it only works if your application is the
foreground application when the screen saver starts.

const int WM_SYSCOMMAND = 0x0112;
const int SC_SCREENSAVE = 0xF140;

protected override void WndProc( ref Message m )
{
   if( m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_SCREENSAVE )
   {
       // your code here
   }
   base.WndProc( ref m );
}
Marc Bernard - 31 Mar 2004 20:35 GMT
> I would like my application to execute a function if and when the screen saver starts. I have been searching for a way for my program to know that
the screen saver has started but the only thing I could find was how to do
it in C++ & Visual Basic 6.

> The question is How can I determine if screen saver is start to run by using C#.

Try this:

[DllImport("user32.dll", CharSet=CharSet.Auto)]
 public static extern int SystemParametersInfo(int uAction,
  int uParam, ref int lpvParam, int fuWinIni);

const int SPI_GETSCREENSAVERRUNNING = 114;
int screenSaverRunning = -1;

// is the screen saver running?

int ok = SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, ref
screenSaverRunning, 0);

if (ok == 0)
{
    Console.WriteLine("Call to SystemParametersInfo failed.");
}

if (screenSaverRunning != 0)
{
    // screen saver is running

}

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.