Home All Groups Group Topic Archive Search About

Scanning for Wordpad.exe program

Author
4 Jun 2005 3:23 AM
Ken Uzzell
Hello,

I program with vb6 sp6 on win98se. I've always used windows write.exe and
now use windows wordpad.exe to act as a report viewer, document editor and
printer system for my vb apps.

Windows 2000 and on up seem to have renamed or used a different path system
for placing their windows document editor in.  In win98se the path is
usually on a default install "c:\program files\accessories\wordpad.exe"

To get this feature I use to work on all levels of windows, I thought I'd
write a routine that scans the HD looking for wordpad.exe so my app can set
it into its config file.

Before I commit to coding this function, I thought I'd just touch base here
to see if there is a more robust way of doing this? I.E. in scanning the HD
for wordpad.exe. My thoughts are to just open a directory, scan it, and keep
doing this until my app found wordpad.exe. Does wordpad.exe exist on all
levels of windows ?


Author
4 Jun 2005 1:47 PM
MikeD
Show quote Hide quote
"Ken Uzzell" <kev***@pacific.net.au> wrote in message
news:nc9oe.17342$Le2.110549@nasal.pacific.net.au...
> Hello,
>
> I program with vb6 sp6 on win98se. I've always used windows write.exe and
> now use windows wordpad.exe to act as a report viewer, document editor and
> printer system for my vb apps.
>
> Windows 2000 and on up seem to have renamed or used a different path
> system
> for placing their windows document editor in.  In win98se the path is
> usually on a default install "c:\program files\accessories\wordpad.exe"
>
> To get this feature I use to work on all levels of windows, I thought I'd
> write a routine that scans the HD looking for wordpad.exe so my app can
> set
> it into its config file.
>
> Before I commit to coding this function, I thought I'd just touch base
> here
> to see if there is a more robust way of doing this? I.E. in scanning the
> HD
> for wordpad.exe. My thoughts are to just open a directory, scan it, and
> keep
> doing this until my app found wordpad.exe. Does wordpad.exe exist on all
> levels of windows ?


Wordpad is included with all versions of Windows, but that doesn't mean it's
installed.  It can be removed via Add/Remove Windows Components.  In fact, I
don't think it has any dependencies at all, and it's not ActiveX, so the EXE
can simply be deleted.  People who have MSWord or some other app that can
open/save .doc and .rtf files might very well have removed Wordpad.

Without knowing more details about how you're using Wordpad for your
reporting, editing, and printing, it's difficult to give you specifics as to
what else you could do.  I would assume you're creating plain text or
RichText files (since Wordpad doesn't support automation, I don't know what
else you could be doing) and just opening those in Wordpad.  You might want
to look into using the RichTextBox control so you can implement these
features directly in your app instead of having to shell to some other app.
Your best bet is to not have to rely on some other app for these things (and
it's also the "cleanest").  If you're creating files with any extension that
is associated with an app (.doc, .txt, and .rtf should all be associated
with some app), you might also just want to use the ShellExecute API
function to open/print the files in whatever that app is.

However, rather than search all hard drives for wordpad.exe, you should be
able to get its location from the Registry in the following key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
Paths\WORDPAD.EXE

This is likely to have a value such as '"%ProgramFiles%\Windows
NT\Accessories\WORDPAD.EXE"'.  This is what I have for WindowsXP and as far
as I know, it's the same for Windows 2000 and Windows Server 2003.  You'd
need to resolve "%ProgramFiles%" to the actual path. This is an environment
variable, so you can use VB's Environ$ function but you first need to remove
the 2 "%" signs.  After doing that, I'd still verify the existance of
wordpad.exe since that key could possibly exist and have a value even if
Wordpad is not installed.  This would be a lot quicker than searching a hard
drive (or drives).


--
Mike
Microsoft MVP Visual Basic
Author
5 Jun 2005 11:10 AM
Ken Uzzell
Show quote Hide quote
"MikeD" <nob***@nowhere.edu> wrote in message
news:emsr8vQaFHA.4020@TK2MSFTNGP09.phx.gbl...
>
> "Ken Uzzell" <kev***@pacific.net.au> wrote in message
> news:nc9oe.17342$Le2.110549@nasal.pacific.net.au...
> > Hello,
> >
> > I program with vb6 sp6 on win98se. I've always used windows write.exe
and
> > now use windows wordpad.exe to act as a report viewer, document editor
and
> > printer system for my vb apps.
> >
> > Windows 2000 and on up seem to have renamed or used a different path
> > system
> > for placing their windows document editor in.  In win98se the path is
> > usually on a default install "c:\program files\accessories\wordpad.exe"
> >
> > To get this feature I use to work on all levels of windows, I thought
I'd
> > write a routine that scans the HD looking for wordpad.exe so my app can
> > set
> > it into its config file.
> >
> > Before I commit to coding this function, I thought I'd just touch base
> > here
> > to see if there is a more robust way of doing this? I.E. in scanning the
> > HD
> > for wordpad.exe. My thoughts are to just open a directory, scan it, and
> > keep
> > doing this until my app found wordpad.exe. Does wordpad.exe exist on all
> > levels of windows ?
>
>
> Wordpad is included with all versions of Windows, but that doesn't mean
it's
> installed.  It can be removed via Add/Remove Windows Components.  In fact,
I
> don't think it has any dependencies at all, and it's not ActiveX, so the
EXE
> can simply be deleted.  People who have MSWord or some other app that can
> open/save .doc and .rtf files might very well have removed Wordpad.
>
> Without knowing more details about how you're using Wordpad for your
> reporting, editing, and printing, it's difficult to give you specifics as
to
> what else you could do.  I would assume you're creating plain text or
> RichText files (since Wordpad doesn't support automation, I don't know
what
> else you could be doing) and just opening those in Wordpad.  You might
want
> to look into using the RichTextBox control so you can implement these
> features directly in your app instead of having to shell to some other
app.
> Your best bet is to not have to rely on some other app for these things
(and
> it's also the "cleanest").  If you're creating files with any extension
that
> is associated with an app (.doc, .txt, and .rtf should all be associated
> with some app), you might also just want to use the ShellExecute API
> function to open/print the files in whatever that app is.
>
> However, rather than search all hard drives for wordpad.exe, you should be
> able to get its location from the Registry in the following key:
>
> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
> Paths\WORDPAD.EXE
>
> This is likely to have a value such as '"%ProgramFiles%\Windows
> NT\Accessories\WORDPAD.EXE"'.  This is what I have for WindowsXP and as
far
> as I know, it's the same for Windows 2000 and Windows Server 2003.  You'd
> need to resolve "%ProgramFiles%" to the actual path. This is an
environment
> variable, so you can use VB's Environ$ function but you first need to
remove
> the 2 "%" signs.  After doing that, I'd still verify the existance of
> wordpad.exe since that key could possibly exist and have a value even if
> Wordpad is not installed.  This would be a lot quicker than searching a
hard
> drive (or drives).
>
>
> --
> Mike
> Microsoft MVP Visual Basic
>

Thanks Mike for the suggestions. I have found some code in google search
that follows your direction regarding editing and printing from a
RichTextBox. This saves a lot of potential problems for my app.

Thanks
Ken
Author
5 Jun 2005 3:32 PM
Veign
Also, if you are creating a report in TXT format you could always use the
ShellExecute API to open the document for viewing or printing.

ShellExecute API:
http://vbnet.mvps.org/index.html?code/shell/shellexecute.htm

Much easier to just create your own Notepad type form and use this - this
will give you more control for future enhancements but wanted to show you
another option.

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/


Show quoteHide quote
"Ken Uzzell" <kev***@pacific.net.au> wrote in message
news:f8Boe.18232$Le2.111920@nasal.pacific.net.au...
>
> "MikeD" <nob***@nowhere.edu> wrote in message
> news:emsr8vQaFHA.4020@TK2MSFTNGP09.phx.gbl...
> >
> > "Ken Uzzell" <kev***@pacific.net.au> wrote in message
> > news:nc9oe.17342$Le2.110549@nasal.pacific.net.au...
> > > Hello,
> > >
> > > I program with vb6 sp6 on win98se. I've always used windows write.exe
> and
> > > now use windows wordpad.exe to act as a report viewer, document editor
> and
> > > printer system for my vb apps.
> > >
> > > Windows 2000 and on up seem to have renamed or used a different path
> > > system
> > > for placing their windows document editor in.  In win98se the path is
> > > usually on a default install "c:\program
files\accessories\wordpad.exe"
Show quoteHide quote
> > >
> > > To get this feature I use to work on all levels of windows, I thought
> I'd
> > > write a routine that scans the HD looking for wordpad.exe so my app
can
> > > set
> > > it into its config file.
> > >
> > > Before I commit to coding this function, I thought I'd just touch base
> > > here
> > > to see if there is a more robust way of doing this? I.E. in scanning
the
> > > HD
> > > for wordpad.exe. My thoughts are to just open a directory, scan it,
and
> > > keep
> > > doing this until my app found wordpad.exe. Does wordpad.exe exist on
all
> > > levels of windows ?
> >
> >
> > Wordpad is included with all versions of Windows, but that doesn't mean
> it's
> > installed.  It can be removed via Add/Remove Windows Components.  In
fact,
> I
> > don't think it has any dependencies at all, and it's not ActiveX, so the
> EXE
> > can simply be deleted.  People who have MSWord or some other app that
can
> > open/save .doc and .rtf files might very well have removed Wordpad.
> >
> > Without knowing more details about how you're using Wordpad for your
> > reporting, editing, and printing, it's difficult to give you specifics
as
> to
> > what else you could do.  I would assume you're creating plain text or
> > RichText files (since Wordpad doesn't support automation, I don't know
> what
> > else you could be doing) and just opening those in Wordpad.  You might
> want
> > to look into using the RichTextBox control so you can implement these
> > features directly in your app instead of having to shell to some other
> app.
> > Your best bet is to not have to rely on some other app for these things
> (and
> > it's also the "cleanest").  If you're creating files with any extension
> that
> > is associated with an app (.doc, .txt, and .rtf should all be associated
> > with some app), you might also just want to use the ShellExecute API
> > function to open/print the files in whatever that app is.
> >
> > However, rather than search all hard drives for wordpad.exe, you should
be
> > able to get its location from the Registry in the following key:
> >
> > HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
> > Paths\WORDPAD.EXE
> >
> > This is likely to have a value such as '"%ProgramFiles%\Windows
> > NT\Accessories\WORDPAD.EXE"'.  This is what I have for WindowsXP and as
> far
> > as I know, it's the same for Windows 2000 and Windows Server 2003.
You'd
> > need to resolve "%ProgramFiles%" to the actual path. This is an
> environment
> > variable, so you can use VB's Environ$ function but you first need to
> remove
> > the 2 "%" signs.  After doing that, I'd still verify the existance of
> > wordpad.exe since that key could possibly exist and have a value even if
> > Wordpad is not installed.  This would be a lot quicker than searching a
> hard
> > drive (or drives).
> >
> >
> > --
> > Mike
> > Microsoft MVP Visual Basic
> >
>
> Thanks Mike for the suggestions. I have found some code in google search
> that follows your direction regarding editing and printing from a
> RichTextBox. This saves a lot of potential problems for my app.
>
> Thanks
> Ken
>
>
Author
5 Jun 2005 11:47 PM
MikeD
"Veign" <NOSPAMinveign@veign.com> wrote in message
news:OKoHWReaFHA.2420@TK2MSFTNGP12.phx.gbl...
> Also, if you are creating a report in TXT format you could always use the
> ShellExecute API to open the document for viewing or printing.
>
> ShellExecute API:
> http://vbnet.mvps.org/index.html?code/shell/shellexecute.htm
>
> Much easier to just create your own Notepad type form and use this - this
> will give you more control for future enhancements but wanted to show you
> another option.


Uh....I *did* mention using ShellExecute.  Here's what I wrote:

"If you're creating files with any extension that
is associated with an app (.doc, .txt, and .rtf should all be associated
with some app), you might also just want to use the ShellExecute API
function to open/print the files in whatever that app is."

<g>

--
Mike
Microsoft MVP Visual Basic
Author
6 Jun 2005 12:10 AM
Veign
You found me out - I never read your posts<bg>

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/


Show quoteHide quote
"MikeD" <nob***@nowhere.edu> wrote in message
news:uCzgyjiaFHA.2736@TK2MSFTNGP12.phx.gbl...
>
> "Veign" <NOSPAMinveign@veign.com> wrote in message
> news:OKoHWReaFHA.2420@TK2MSFTNGP12.phx.gbl...
> > Also, if you are creating a report in TXT format you could always use
the
> > ShellExecute API to open the document for viewing or printing.
> >
> > ShellExecute API:
> > http://vbnet.mvps.org/index.html?code/shell/shellexecute.htm
> >
> > Much easier to just create your own Notepad type form and use this -
this
> > will give you more control for future enhancements but wanted to show
you
> > another option.
>
>
> Uh....I *did* mention using ShellExecute.  Here's what I wrote:
>
> "If you're creating files with any extension that
> is associated with an app (.doc, .txt, and .rtf should all be associated
> with some app), you might also just want to use the ShellExecute API
> function to open/print the files in whatever that app is."
>
> <g>
>
> --
> Mike
> Microsoft MVP Visual Basic
>
>
Author
14 Jun 2005 2:27 PM
Ken Uzzell
Thanks to everyone's help.

I ended up going with a RichTextBox and printing from there.

Much nicer!

Ken U

Show quoteHide quote
"MikeD" <nob***@nowhere.edu> wrote in message
news:emsr8vQaFHA.4020@TK2MSFTNGP09.phx.gbl...
>
> "Ken Uzzell" <kev***@pacific.net.au> wrote in message
> news:nc9oe.17342$Le2.110549@nasal.pacific.net.au...
> > Hello,
> >
> > I program with vb6 sp6 on win98se. I've always used windows write.exe
and
> > now use windows wordpad.exe to act as a report viewer, document editor
and
> > printer system for my vb apps.
> >
> > Windows 2000 and on up seem to have renamed or used a different path
> > system
> > for placing their windows document editor in.  In win98se the path is
> > usually on a default install "c:\program files\accessories\wordpad.exe"
> >
> > To get this feature I use to work on all levels of windows, I thought
I'd
> > write a routine that scans the HD looking for wordpad.exe so my app can
> > set
> > it into its config file.
> >
> > Before I commit to coding this function, I thought I'd just touch base
> > here
> > to see if there is a more robust way of doing this? I.E. in scanning the
> > HD
> > for wordpad.exe. My thoughts are to just open a directory, scan it, and
> > keep
> > doing this until my app found wordpad.exe. Does wordpad.exe exist on all
> > levels of windows ?
>
>
> Wordpad is included with all versions of Windows, but that doesn't mean
it's
> installed.  It can be removed via Add/Remove Windows Components.  In fact,
I
> don't think it has any dependencies at all, and it's not ActiveX, so the
EXE
> can simply be deleted.  People who have MSWord or some other app that can
> open/save .doc and .rtf files might very well have removed Wordpad.
>
> Without knowing more details about how you're using Wordpad for your
> reporting, editing, and printing, it's difficult to give you specifics as
to
> what else you could do.  I would assume you're creating plain text or
> RichText files (since Wordpad doesn't support automation, I don't know
what
> else you could be doing) and just opening those in Wordpad.  You might
want
> to look into using the RichTextBox control so you can implement these
> features directly in your app instead of having to shell to some other
app.
> Your best bet is to not have to rely on some other app for these things
(and
> it's also the "cleanest").  If you're creating files with any extension
that
> is associated with an app (.doc, .txt, and .rtf should all be associated
> with some app), you might also just want to use the ShellExecute API
> function to open/print the files in whatever that app is.
>
> However, rather than search all hard drives for wordpad.exe, you should be
> able to get its location from the Registry in the following key:
>
> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
> Paths\WORDPAD.EXE
>
> This is likely to have a value such as '"%ProgramFiles%\Windows
> NT\Accessories\WORDPAD.EXE"'.  This is what I have for WindowsXP and as
far
> as I know, it's the same for Windows 2000 and Windows Server 2003.  You'd
> need to resolve "%ProgramFiles%" to the actual path. This is an
environment
> variable, so you can use VB's Environ$ function but you first need to
remove
> the 2 "%" signs.  After doing that, I'd still verify the existance of
> wordpad.exe since that key could possibly exist and have a value even if
> Wordpad is not installed.  This would be a lot quicker than searching a
hard
> drive (or drives).
>
>
> --
> Mike
> Microsoft MVP Visual Basic
>
>
>