Groups | Blog | Home
all groups > dotnet compact framework > november 2007 >

dotnet compact framework : Passing parameters to .NET smart device application


Junior
11/6/2007 3:35:01 AM
Hello !

I have this windows forms device application in VB .NET, and need to pass a
command line parameter to it, since it is going to be called by another
application under some circunstances. I've learned that it is not possible,
and one solution is to create a new C++ console application which would
receive the command line parameter and call my application passing the
parameter along, replacing the original Main Sub. It doesn't look elegant,
but solves the problem. Now, is this the way to go ? If so, and considering I
know nothing about C++, what would the C++ source code look like ? I included
the wizard code generated in C++. I imagine this would create a single
executable which receives the parameter and executes my existing application
-another project in the same solution.

Thanks very much, Junior.

// StartUpWithParmsInC.cpp : Defines the entry point for the console
application.
//
#include "stdafx.h"
#include <windows.h>
#include <commctrl.h>
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
Junior
11/6/2007 4:17:01 PM
Thanks for replying, Chris... I guess I was not really clear. I tried to
change the Sub Main signature in my VB .NET smart device application, but
couldn't... It seems it is not possible to pass command line parameters to an
application written in VB .NET... Then I Googled it, and it seems one really
can't pass them. Instead, I thougth I could add a new project to my solution,
this time in C++ as it accepts parameters, make it the startup project, pass
parameters to it and forward these parameter to my VB project within the same
solution... Now, if this is the possible solution, and considering I don't
know a thing about Visual C++, what should I do to make it call my other
project in VB .NET ? Thanks again !

[quoted text, click to view]
Junior
11/6/2007 4:27:00 PM
Ops, Sergey Bogdanov had already answered that ! Thanks !

Public Shared Sub Main(ByVal args() as String)
' args(0) -- the first parameter
' args(1) -- the second
End Sub


[quoted text, click to view]
Junior
11/6/2007 4:46:01 PM
You are right, Chris ! Thanks very much !

[quoted text, click to view]
ctacke/
11/6/2007 5:56:22 PM
Where did you get the info that you can't get parameters? Main gets an
array of strings as the command line parameters - you simply need to define
it as such. If you mean second instances, then C++ has a similar problem -
you have to get the command-line from the second instance from the second
instance to the first. IPC with a P2P message queue works well for that.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com



[quoted text, click to view]

ctacke/
11/6/2007 6:25:17 PM
Definitely not true. I'm not a VB developer, but I just created a new PPC
2003 app. I then added a new class called Class1 to it and added this to
the class:

Public Shared Sub Main(ByVal params As String())
For Each s As String In params
MessageBox.Show(s)
Next
End Sub

I then opened the project properties and changed the startup object from
Form1 to Class1 and added a debug set of command line arguments and got them
all as message boxes.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com



[quoted text, click to view]

AddThis Social Bookmark Button