PC Review


Reply
Thread Tools Rate Thread

Passing parameters to .NET smart device application

 
 
=?Utf-8?B?SnVuaW9y?=
Guest
Posts: n/a
 
      6th Nov 2007
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;
}

 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      7th Nov 2007
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" <(E-Mail Removed)> wrote in message
news:6CE09EE8-9455-4A6A-95F4-(E-Mail Removed)...
> 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;
> }
>



 
Reply With Quote
 
=?Utf-8?B?SnVuaW9y?=
Guest
Posts: n/a
 
      7th Nov 2007
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" <(E-Mail Removed)> wrote in message
> news:6CE09EE8-9455-4A6A-95F4-(E-Mail Removed)...
> > 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;
> > }
> >

>
>
>

 
Reply With Quote
 
Guest
Posts: n/a
 
      7th Nov 2007
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" <(E-Mail Removed)> wrote in message
news:865FD736-2EB9-4147-B441-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:6CE09EE8-9455-4A6A-95F4-(E-Mail Removed)...
>> > 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;
>> > }
>> >

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?SnVuaW9y?=
Guest
Posts: n/a
 
      7th Nov 2007
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" <(E-Mail Removed)> wrote in message
> > news:6CE09EE8-9455-4A6A-95F4-(E-Mail Removed)...
> > > 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;
> > > }
> > >

> >
> >
> >

 
Reply With Quote
 
=?Utf-8?B?SnVuaW9y?=
Guest
Posts: n/a
 
      7th Nov 2007
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" <(E-Mail Removed)> wrote in message
> news:865FD736-2EB9-4147-B441-(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> >> news:6CE09EE8-9455-4A6A-95F4-(E-Mail Removed)...
> >> > 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;
> >> > }
> >> >
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing parameters from Access's VBA to another application's VBA =?Utf-8?B?R2FyeQ==?= Microsoft Access VBA Modules 0 13th Mar 2006 08:14 PM
How to convert Smart device 2003 application to Smart Device 2005 application Harsh Trivedi Microsoft Dot NET Compact Framework 4 22nd Feb 2006 07:49 AM
Re: Passing parameters to a c# application on web Karunakararao Microsoft C# .NET 0 29th Jun 2004 01:56 PM
Passing parameter to Smart Client application Suvendu Microsoft Dot NET Framework Forms 1 15th Nov 2003 05:17 AM
Passing Parameters to Console Application Michael Hetrick Microsoft C# .NET 1 16th Jul 2003 04:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:48 PM.