ShellExecute in VB2005

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does ShellExecute work in VB2005? I am trying to open a pdf with a button - I
get no errors, but nothing is happening. Here is my code:
Option Explicit On

Public Class frmPROTest
Const SW_SHOWNORMAL = 1
Dim hwnd

Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Private Sub PDF_Click()

Call ShellExecute(Me.hwnd, "open", "S:\Users\JJolly\PRO
CD\pdf\english\ESY Book.pdf", "", 0, SW_SHOWNORMAL)

End Sub

End Class

Thanks for any help.
 
Jedi10180 said:
Does ShellExecute work in VB2005? I am trying to open a pdf with a
button - I
get no errors, but nothing is happening. Here is my code:
Option Explicit On

Public Class frmPROTest
Const SW_SHOWNORMAL = 1
Dim hwnd

Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String,
_
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Your declarations are wrong. Instead of fixing them, I suggest to use
'System.Diagnostics.Process.Start' instead of 'ShellExecute'.
 
Jedi10180 said:
Does ShellExecute work in VB2005? I am trying to open a pdf with a
button - I get no errors, but nothing is happening.

Have you considered the following method using the .NET framework?

\\\
Dim proc As New Process

With proc.StartInfo
.FileName = "S:\Users\JJolly\PRO CD\pdf\english\ESY Book.pdf"
.UseShellExecute = True
.Verb = "open"
End With

'Launch the file
proc.Start()
///
 
I have also tried 'System.Diagnostics.Process.Start', but apparently my
declarations are wrong when I try it too because nothing happens at all. Can
you just give a short code snippet that would include everything I need to
open a pdf file using 'System.Diagnostics.Process.Start'?
Also, we want this program to be run directly from a CD with no installation
- how do I go about doing that?
Thanks.
 
why doesn't cmd.exe with arguments /c copy c:\file.txt d:\directory work with
the process start?
 
Jedi10180,

Programs written in a .Net language require the .Net framework to be
installed in order to execute the program.

Kerry Moorman
 
Back
Top