Click here to Skip to main content
15,513,655 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI,
I have written a program that would work well as a screen saver and am attempting to convert it to one. (not just changing the extension)

As far as I understand the first thing you need to do is intercept the commandline arguments when the program executes. I wrote this and put it in my form_load event.
VB
Dim ss As Array = Environment.GetCommandLineArgs
Dim s As Integer = ss.Length
If s > 1 Then
MsgBox("switch found " & s & vbNewLine & vbNewLine & ss(1).ToString)
If InStr(ss(1), "c") > 0 Then
End
End If
If InStr(ss(1), "p") > 0 Then
End
End If
If InStr(ss(1), "a") > 0 Then
End
End If
Else
MsgBox("No Switch " & s & vbNewLine & ss(0).ToString)
End If

Which works fine if I double click or right click/test.(the commandline /s is captured and displayed) right click/configure produces no commandline found and going to the screen saver panel and clicking a button the program just executes as if this code is not there?!?

Any suggestions welcomed.
Posted
Updated 28-Nov-14 7:50am
v3

1 solution

 
Share this answer
 
Comments
5everin 28-Nov-14 18:55pm    
Having looked at the link, I don't see why my code shouldn't work. Maybe I am missing something obvious as my .net knowledge is patchy. After some testing and adding more message boxes the code defiantly picks up commandline args passed to the program.
Richard MacCutchan 29-Nov-14 4:31am    
If you look carefully at the sample it only offers the main method for capturing the parameters. you are using Environment.GetCommandLineArgs, which may only work for 'normal' executables. Screensavers are started in a different way from normal executable programs.
5everin 29-Nov-14 18:17pm    
Makes sense, I will do it as shown and see what happens.
Thanks for the replies.
5everin 29-Nov-14 19:54pm    
Yes that works. I suspect my code also works. (but is less useful)

Found out why it didn't. I'm ashamed to say I compiled and used install after renaming to .scr completely forgetting that I had an old version of the code sitting in the windows folder and the control panel was executing that rather than the copy I thought it was executing.
Richard MacCutchan 30-Nov-14 5:10am    
Many of us have made a similar mistake, easy to do.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900