jenn5175 Posted December 27, 2002 Posted December 27, 2002 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 Quote
*Gurus* divil Posted December 28, 2002 *Gurus* Posted December 28, 2002 You can get the hWnd of a form using the Form.Handle property. It will be of the IntPtr type, so make sure your api declare has the hWnd parameter defined that way too. You could probably pass 0 to it too. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
jenn5175 Posted December 30, 2002 Author Posted December 30, 2002 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 Quote
*Gurus* divil Posted December 30, 2002 *Gurus* Posted December 30, 2002 Would you mind posting your workaround here, for future reference? Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
jenn5175 Posted December 30, 2002 Author Posted December 30, 2002 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 Quote
Recommended Posts