473,386 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ShellExecute in VB2005

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.
Jan 17 '06 #1
5 8936
"Jedi10180" <Je*******@discussions.microsoft.com> schrieb:
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'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 17 '06 #2
Jedi10180 wrote:
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()
///

--

(O)enone
Jan 17 '06 #3
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.

"Herfried K. Wagner [MVP]" wrote:
"Jedi10180" <Je*******@discussions.microsoft.com> schrieb:
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'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 17 '06 #4
why doesn't cmd.exe with arguments /c copy c:\file.txt d:\directory work with
the process start?

"Oenone" wrote:
Jedi10180 wrote:
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()
///

--

(O)enone

Jan 17 '06 #5
Jedi10180,

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

Kerry Moorman
"Jedi10180" wrote:
Also, we want this program to be run directly from a CD with no installation
- how do I go about doing that?
Thanks.


Jan 17 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marcel Sammut | last post by:
Greetings, I am converting a VB6 application to .net and am having troubles trying to print a document directley to the printer. My VB6 app used the API ShellExecute method to accomplish this,...
3
by: Wiktor Zychla | last post by:
I have a problem I cannot solve. My application hosts IE activex control. I follow the standard procedure: I just aximp shdocvw.dll. Note that this gives you two files: axshdocvw.dll and...
1
by: MCzajk | last post by:
Is there a function similar to ShellExecute, which I can hook to when the program is started using Start Menu icon? MCzajk
11
by: Le, Thanh-Nhan | last post by:
Hi, Is there a same function in .Net as API shellexecute? Thanks Nhan
0
by: the_openFace | last post by:
I'm trying to display the shell's property page for various files and I'm using this code: class Win32Shell { // ... other stuff here public static extern Int32 ShellExecute( Int32 hwnd,...
0
by: the openBack | last post by:
I'm trying to display the shell's property page for various files and I'm using this code: class Win32Shell { // ... other stuff here public static extern Int32 ShellExecute( Int32 hwnd,...
0
by: David | last post by:
We have an mfc application in which we use ShellExecute to launch the browser with an initial web site. {ShellExecute( NULL, "open", "http://www.SomeWebSite.com", NULL, NULL, SW_SHOWNORMAL ) } ...
4
by: fdmaxey | last post by:
I currently start a target executable written in VB.Net from an application that uses a C-script language. I start the target executable using ShellExecute in the C-script. The target runs fine...
2
by: John Smith | last post by:
Hi, I have an access database form with an image. I'm trying to create an onclick event on the image so that when a user clicks on the image it opens that file with the default viewer the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.