🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #3579

Re: [VB.NET] Open een bestand??? Vanuit listbox.

#3579
From: Gijs Beukenoot
Date: Thu, 04 Dec 2003 18:18
54 lines
3707 bytes
"KLinZ" <klinz@NOSPAMMERTSzenobits.com> schreef in bericht
news:bqnmou$2sv$1@hermes.castel.nl...
> Muse wrote:
>
> > Ik probeer een bestand te openen van uit een listbox. Het path kopmt
> > prima door, maar ik krijg het maar niet voor elkaar op het te openen.
> > Een .exe lukt prima. Maar als ik een doc of pdf wil openen, dan werkt
> > het niet. Het gaat dus om een willekeurig bestand.
>
> Hoe ziet de code eruit die het bestand opent? Gebruik je
> System.Diagnostics.Process.Start()? Staat UseShellExecute op true?
>
> -- 
> www.zenobits.com
>

Voor de volledigheid, ofwel je gebruikt :
Shell("c:\winnt\notepad.exe", AppWinStyle.MaximizedFocus, False, -1)

Ofwel je gebruikt :
Dim p As System.Diagnostics.Process = New Process()
p.StartInfo.FileName = "c:\winnt\notepad.exe"
p.StartInfo.WindowStyle = ProcessWindowStyle.Maximized
p.StartInfo.UseShellExecute = False
p.Start()
The code shown above would still launch Notepad without changing
UseShellExecute but p.Start() would call ShellExecuteEx rather than
CreateProcess as called by Shell.

Although more coding is required to use it, the Process class is more
powerful than the Shell method. Like its Visual Basic 6 precursor,
Microsoft.VisualBasic.Interaction.Shell is only capable of launching files
that are executable files (such as .exe and .bat files). Its call chain
leads to CreateProcess in the Win32 API. The Process class also calls
CreateProcess when Process.StartInfo.UseShellExecute is explicitly set to
False. Otherwise Process.Start uses the operating system shell to launch the
specified file. If the file is non-executable or a URI, the OS shell opens
the file or resource using the default action for that file or URI type
(that is, the default verb-usually open). Using the operating system shell
in Visual Basic 6 requires a Declare statement to call the API function
directly.

Using the Process class with UseShellExecute = False is sometimes slightly
faster than the Shell method but the very slight performance gain is
negligible and insignificant against the overhead of loading a new process
unless you are launching dozens of short-lived processes from the UI thread.

Recommendation: For launching only executable files, there is no compelling
performance reason to choose Process over Shell, and Shell is often more
productive. Use Process when features not provided by Shell are required
(for example, I/O redirection or UseShellExecute).

Aldus de MSDN library...
Technical Details
Message-ID: <3fcf7a6d$0$175$1b62eedf@news.wanadoo.nl>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.multikabel.nl!news2.euro.net!postnews1.euro.net!news.wanadoo.nl!not-for-mail
References: <3fcf1d7d$0$41763$5fc3050@dreader2.news.tiscali.nl> <bqnmou$2sv$1@hermes.castel.nl>

Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit
X-Google-Thread: 107324,2cb999485abb4946
X-Google-Attributes: gid107324,public
X-Google-Thread: fcea4,2cb999485abb4946
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2003-12-04 10:18:23 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.multikabel.nl!news2.euro.net!postnews1.euro.net!news.wanadoo.nl!not-for-mail
From: "Gijs Beukenoot" <Gijs.Beukenoot@.Wanadoo.nl.REMOVEALLAFTERDOTNL>
Newsgroups: be.comp.programming,nl.comp.programmeren
References: <3fcf1d7d$0$41763$5fc3050@dreader2.news.tiscali.nl> <bqnmou$2sv$1@hermes.castel.nl>
Subject: Re: [VB.NET] Open een bestand??? Vanuit listbox.
Date: Thu, 4 Dec 2003 19:18:17 +0100
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Lines: 56
Message-ID: <3fcf7a6d$0$175$1b62eedf@news.wanadoo.nl>
Organization: Wanadoo
NNTP-Posting-Date: 04 Dec 2003 18:18:21 GMT
NNTP-Posting-Host: c3eea2565.cable.wanadoo.nl
X-Trace: 1070561901 willi.euronet.nl 175 62.234.37.101:3704
X-Complaints-To: abuse@wanadoo.nl