Newbie: start external program like Shell() function

F

Francesco Ranieri

Hi to all,
I've started programming vb.net last week and I'm a newbie...

I'm programming an application for my navigation system.
1) Development tool is: MS Visual Studio .Net 2003 - SP1
2) Navigation system is equipped with:
a) MS Windwows CE .net 5.00
b) MS .NET Compact Framework 1.0.4292.00

I've a question for you:
I wish to "start external program" programmatically, on button click event.

I'm Visual Basic v. 6.0 expert and Shell(), ShellExecute() and
ShellExecuteEx() were very useful, but into vb.net language they are not!???

I wish the vb.net equivalent of vb60 instruction:

retVal=Shell("\MySubDir\Notepad.exe", vbShow)

I've tried "ShellExecute API" but gives me a NotSupportedException
I've tried to use "Process class" but I've not found it into CF.
I explain better... following a summary of my code into form
"frmNavSystem.vb"

----------------------------------------------------------------------------
------------------------
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports Microsoft.VisualBasic


Public Class frmNavSystem
Inherits System.Windows.Forms.Form
.......................... blà blà blà .....................
Private Sub pcxButton_TopLeft_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles pcxButton_TopLeft.Click
Call ExecuteExternalProgram("\MySubDir\MyApp.exe", "\MySubDir\")
End Sub
.......................... blà blà blà .....................
Private Function ExecuteExternalProgram(ByVal strPRMPath As String, ByVal
strPRMDirectory As String) As Boolean
'********************************* HERE IS THE QUESTION
*****************************
'***************** Here I wish "Process class" option into drop-down
list, but it isn't there!!!!!
'Dim objProcess As System.Diagnostics.{}

'************ This is inexistent
'Call Shell(strPRMPath , AppWinStyle.NormalFocus)
'********************************* HERE IS THE QUESTION
*****************************
End Function
.......................... blà blà blà .....................
End Class
----------------------------------------------------------------------------
------------------------

Besides, Project => MyProject property => Common Properties => Imported
reference => List of name spaces includes only "System".

The Shell() function doesn't exist into .net (? I think ?), because
generation gives me an error.
The drop-down list of System.Diagnostic.{--} doesn't give me the .Process
class option... so, I can't select it!!

Please, can you help me? Can you give me an example?
Thanks in advance
Francesco
 
C

Christopher Fairbairn

Hi,

Look at the System.Diagnostics.Process class.

Chris probably missed the bit where the original poster mentioned they were
using CF 1.0. Version 1 of the Compact Framework did not have the
System.Diagnostics.Process class.

Your only solution is to use some PInvoke declarations to access an API
within the operating system called CreateProcess (and/or ShellExecuteEx
depending upon your needs).

Alternativly you might like to investigate the OpenNETCF Smart Device
Framework (SDF). Version 1.4 supports compact framework 1.0 and provides a
suitable Process class which behaves similiar to the one found in .NET CF
2.0.

take a look at
http://samples.gotdotnet.com/quickstart/CompactFramework/doc/waitforsingleobject.aspx
for one example way to wrap up the CreateProcess API

Hope this helps,
Christopher Fairbairn
 
F

Francesco Ranieri

Thanks Christopher, thank you very much: you have solved my troubles.
Unfortunately, .NET 2003 has CF v. 1.0.5000 while, smart device, has CF v.
1.0.4292.00: I can't update CF of smart device because it has its operative
system into nand memory (rom)...and updating it, I could lose warranty on
it.

I've another question for you: distribuiting application on my smart device,
..NET 2003 puts its libraries .dll (Microsoft.VisualBasic.dll,
Microsoft.WindowsCE.Forms.dll, mscorlib.dll, System.Data.dll etc) in the
same folder of my application "NavSystem.exe".
Could I set any option to copy my application into a folder FolderA and
library files into another sub-folder FolderB?
I wish something like this:

-SDMMC
|-NavSystem.exe
|-BinFolder
| |-Microsoft.VisualBasic.dll
| |-Microsoft.WindowsCE.Forms.dll
| |- ...............................
| |-System.Xml.dll
|
|-OtherFolder

Thank you very much again
Francesco
 

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