PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Passing parameters to .NET smart device application
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Passing parameters to .NET smart device application
![]() |
Passing parameters to .NET smart device application |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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; } |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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" <Junior@discussions.microsoft.com> wrote in message news:6CE09EE8-9455-4A6A-95F4-5DD5679DD7E4@microsoft.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; > } > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
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 ! "<ctacke/>" wrote: > 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" <Junior@discussions.microsoft.com> wrote in message > news:6CE09EE8-9455-4A6A-95F4-5DD5679DD7E4@microsoft.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; > > } > > > > > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
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" <Junior@discussions.microsoft.com> wrote in message news:865FD736-2EB9-4147-B441-C8BC48DC43F5@microsoft.com... > 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 ! > > "<ctacke/>" wrote: > >> 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" <Junior@discussions.microsoft.com> wrote in message >> news:6CE09EE8-9455-4A6A-95F4-5DD5679DD7E4@microsoft.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; >> > } >> > >> >> >> |
|
|
|
#5 |
|
Guest
Posts: n/a
|
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" wrote: > 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 ! > > "<ctacke/>" wrote: > > > 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" <Junior@discussions.microsoft.com> wrote in message > > news:6CE09EE8-9455-4A6A-95F4-5DD5679DD7E4@microsoft.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; > > > } > > > > > > > > > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
You are right, Chris ! Thanks very much !
"<ctacke/>" wrote: > 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" <Junior@discussions.microsoft.com> wrote in message > news:865FD736-2EB9-4147-B441-C8BC48DC43F5@microsoft.com... > > 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 ! > > > > "<ctacke/>" wrote: > > > >> 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" <Junior@discussions.microsoft.com> wrote in message > >> news:6CE09EE8-9455-4A6A-95F4-5DD5679DD7E4@microsoft.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; > >> > } > >> > > >> > >> > >> > > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

