Passing parameters to .NET smart device application


G

Guest

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;
}
 
Ad

Advertisements

G

Guest

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
 
G

Guest

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 !

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



Junior said:
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;
}
 
G

Guest

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



Junior said:
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 !

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



Junior said:
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;
}
 
G

Guest

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


Junior said:
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 !

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



Junior said:
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;
}
 
Ad

Advertisements

G

Guest

You are right, Chris ! Thanks very much !

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



Junior said:
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 !

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



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;
}
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top