Using Shell Execute to open IE

S

Stefan Mähr

Hello NG

I use the following code (taken from opennnetcf.org) to shell the Pocket-IE.
If i do so, my programm shuts down. IE is started but not activated.
Any idea why?

Thanks for your help in advance

Imports System.Runtime.InteropServices
Imports System.Text

Class SHELLEXECUTEEX
Public cbSize As UInt32
Public fMask As UInt32
Public hwnd As IntPtr
Public lpVerb As IntPtr
Public lpFile As IntPtr
Public lpParameters As IntPtr
Public lpDirectory As IntPtr

Public nShow As Integer
Public hInstApp As IntPtr
' Optional members
Public lpIDList As IntPtr
Public lpClass As IntPtr
Public hkeyClass As IntPtr
Public dwHotKey As UInt32
Public hIcon As IntPtr
Public hProcess As IntPtr
End Class 'SHELLEXECUTEEX



Public Class Shell

<DllImport("coredll")> _
Private Shared Function ShellExecuteEx(ByRef ex As ShellExecuteEx) As
Integer

End Function

<DllImport("coredll")> _
Private Shared Function LocalAlloc(ByVal flags As Integer, ByVal size As
Integer) As IntPtr

End Function

<DllImport("coredll")> _
Private Shared Sub LocalFree(ByVal ptr As IntPtr)

End Sub

Public Shared Sub open(ByVal file As String)

Dim docname As String = file
Dim nSize As Integer = docname.Length * 2 + 2
Dim pData As IntPtr = LocalAlloc(&H40, nSize)
Marshal.Copy(Encoding.Unicode.GetBytes(docname), 0, pData, nSize - 2)

Dim see As New SHELLEXECUTEEX
see.cbSize = System.Convert.ToUInt32(60)
see.dwHotKey = System.Convert.ToUInt32(0)
see.fMask = System.Convert.ToUInt32(0)
see.hIcon = IntPtr.Zero
see.hInstApp = IntPtr.Zero
see.hProcess = IntPtr.Zero
see.lpClass = IntPtr.Zero
see.lpDirectory = IntPtr.Zero
see.lpIDList = IntPtr.Zero
see.lpParameters = IntPtr.Zero
see.lpVerb = IntPtr.Zero
see.nShow = 0
see.lpFile = pData

ShellExecuteEx(see)

LocalFree(pData)

End Sub

Mähr Stefan
visit www.visualsoft-net.de
 
P

Peter Foot [MVP]

Have you tried running our Core.ShellExecuteEx P/Invoke (written in C#)
through one of the C# to VB converters listed in the forums? or better still
you could use the compiled library as a reference in your VB project. The
Smart Device Framework contains a OpenNETCF.Diagnostics.Process class which
is a subset of the desktop framework equivalent -
www.opennetcf.org/smartdeviceramework.asp

Peter
 

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