Reputation: 555
I'm creating a AddIn application for Autodesk Inventor. This AddIn has the purpose to have some designtools that will increase the productivity.
(This tool in particular will perform a copy design but that just for info.)
I have written the tool in a standalone application and it worked, then I added into the Autodesk Inventor AddIn and it didn't work anymore.
So I searched around a bit and I found that I should keep the standalone application and call it from the AddIn.
This would be the call from my AddIn I'm doing it like this I think, there are a bunch of methods on the msdn page but, I guess this is what I need
Sub OpenWithArguments()
' url's are not considered documents. They can only be opened
' by passing them as arguments.
Process.Start("IExplore.exe", "www.northwindtraders.com")
' Start a Web page using a browser associated with .html and .asp files.
Process.Start("IExplore.exe", "C:\myPath\myFile.htm")
Process.Start("IExplore.exe", "C:\myPath\myFile.asp")
End Sub 'OpenWithArguments
But how do I create my copydesign.exe that it can accept arguments when I call it?
Upvotes: 0
Views: 784
Reputation: 4796
You actually have two options (that I know of) :
Option 1
Use the Main method with argument.
Somewhere in you code there is your main method, i.e. the first method that will be called when your application starts. It should look like this :
Sub Main()
...
End Sub
You can actually decide that this method should receive arguments :
Sub Main(ByVal cmdArgs() As String)
For Each Arg As String in cmdArgs
'Do some stuff with this Arg
Debug.Writeline("Argument : " & Arg)
Next For
End Sub
Check this link for more information
Option 2
Use the CommanLine property of Environment
Sub Main()
Dim arguments As String() = Environment.GetCommandLineArgs()
For Each Arg As String in arguments
'Do some stuff with this Arg
Debug.Writeline("Argument : " & Arg)
Next For
End Sub
Check this link for more information
EDIT
Be aware that usually the first argument you receive will be the path to your executable... So you always have one more argument than needed...
Upvotes: 0
Reputation: 1071
You can check the input arguments in your application by using System.Envirement.CommandLine
and do appropriate action for each command. but I recommend choose another communication approach.
Upvotes: 1