Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have given up on all of the smart device boards because no one seems to have answered so I have expanded onto you desktop programmers in hopes someone may be able to help. I am programming for a Windows CE .NET device using VS 2003 (VB). All I need to do is launch an executable from inside my program - you wouldn't think it would be causing me such grey hair. So far I have found the following are not supported in device programming: shell(), shellexecute(), process.start(), createprocess(). I heard a rumor that ShellExecuteEx() is supported, but I have only found 1 VB example which implements it and I cannot get the sample to work (it needs the window handle - me.hWnd - but I'm thinking window handles don't exist in VB.NET/SD programming). Does anyone have an example of how to use ShellExecuteEx() in VB? Or have another idea? Or possibly have a clue how I can get hWnd so I can use my other example? Anything! I'm getting desperate!

 

Jenn

Posted

I tried passing it zero at first and it wouldn't launch anything so I think it didn't appreciate my workaround. Also, there is no such thing as a handle property that I can find. I have tried "me", "form", and "formName" and none support the handle property when developing for a smart device. But I found a workaround which seems to work and completely avoids using a handle. Thanks for your suggestion!

 

Jenn

Posted

Here's the solution I found for launching an application from within a VB.NET application for Smart Devices:

 

Imports System

Imports System.Runtime.InteropServices

 

Public Class frmGMNAOSetup

Inherits System.Windows.Forms.Form

 

<DllImport("coredll.dll")> _

Protected Shared Function CreateProcess( _

ByVal imageName As String, _

ByVal cmdLine As String, _

ByVal lpProcessAttributes As IntPtr, _

ByVal lpThreadAttributes As IntPtr, _

ByVal boolInheritHandles As Int32, _

ByVal dwCreationFlags As Int32, _

ByVal lpEnvironment As IntPtr, _

ByVal lpCurrentDir As IntPtr, _

ByVal si() As Byte, _

ByVal pi As ProcessInfo) As Int32

End Function

 

 

Private Sub frmGMNAOSetup_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim si(128) As Byte

Dim pi As New ProcessInfo

Dim iRtn As Int32

iRtn = CreateProcess("\windows\pword.exe", "", IntPtr.Zero, IntPtr.Zero, 0, 0, IntPtr.Zero, IntPtr.Zero, si, pi)

MsgBox(iRtn)

 

End Sub

 

End Class

Public Class ProcessInfo

Public hProcess As Int32

Public hThread As Int32

Public ProcessID As Int32

Public ThreadID As Int32

End Class

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...