Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to give a specific event when executing the program.

For example,

C:\download\program.exe -Tray

As above if have followed the path '-####'

'-####' In the event program for.

How Can I Did?



(Sorry, I using Translater)
Posted

It would appear you want to use command line arguments in your application, to get the values passed for a win form application you can use;
VB
For Each arg As String In Environment.GetCommandLineArgs()
    'Do something here if the command you want is found.
Next arg


For a console application you can over ride the main method with;
VB
Shared Sub Main(ByVal args As String())
    For Each arg As String In args
        'Do something here if the command you want is found.
    Next arg

End Sub



Read this article[^] as well.
 
Share this answer
 
Where do you want to give an event ? You can tell what path you were passed in, in your code, but that's not really an 'event', you just respond to the value if it's what you expected.
 
Share this answer
 
You should edit your post to add detail, not push answer if you're not answering. Your application is passed the parameters you pass into it. You can store those in a variable, and then refer to them in your form load event, which is something you have to code into your application. Any time you want to do something based on what someone passed in, you can, so long as you stored it. This is not raising an event, at least, not according to what you've said before. It's a basic programming task, store the value, check it, and act on it's value. It's possible your question is being lost in translation but I think you just need to take a basic class or buy a basic book. If I'm not fully understanding you, posting some code with a comment of what you want to add, may help me to understand what you're asking.
 
Share this answer
 
Event the form is loaded.

uh.. how can i?
 
Share this answer
 

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