Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 21, 1997

Protect Your Screen Saver From Restarting

When you create a screen saver in Visual Basic, you may sometimes utilize the command-line options such as "/s" to start a screen saver directly or "/c" to run the configuration. By simply using App.PrevInstance, your application may not detect the running screen saver and attempt to start another when the normal Windows screen saver time-out occurs. To ensure that Windows will detect the running screen saver, regardless of the use of command-line options, use this code:
 
Private Declare Function GetModuleHandle% Lib "Kernel" _
	(ByVal lpModuleName$)
Private Declare Function GetModuleUsage% Lib "Kernel" _
	(ByVal hModule%)
Sub StartUp()
Dim Inst%
	Inst = GetModuleHandle(App.Path + _
		"\" + CStr(Trim(App.EXEName) + ".scr"))
	If GetModuleUsage_
		(GetModuleHandle(App.Path + "\" _
		+ CStr(Trim(App.EXEName) + ".scr"))) > 1 Then End
End Sub
Call the sub like this:
 
Sub Main()
	Call StartUp
End 
This method works well with Windows 3.11. You can use this basic idea with any application you write, not just screen savers.
Uwe Pryka
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date