|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Scanning for Wordpad.exe programI 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 ?
Show quote
Hide quote
"Ken Uzzell" <kev***@pacific.net.au> wrote in message Wordpad is included with all versions of Windows, but that doesn't mean it's 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 ? 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
Show quote
Hide quote
"MikeD" <nob***@nowhere.edu> wrote in message Thanks Mike for the suggestions. I have found some code in google searchnews: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 > that follows your direction regarding editing and printing from a RichTextBox. This saves a lot of potential problems for my app. Thanks Ken 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. -- Show quoteHide quoteChris 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/ "Ken Uzzell" <kev***@pacific.net.au> wrote in message files\accessories\wordpad.exe"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 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 > > "Veign" <NOSPAMinveign@veign.com> wrote in message Uh....I *did* mention using ShellExecute. Here's what I wrote: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. "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 You found me out - I never read your posts<bg>
-- Show quoteHide quoteChris 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/ "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 > > 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 > > > |
|||||||||||||||||||||||