Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Win API to cofigure Application to use with an extensio
Message
 
To
25/12/2000 17:21:59
Peter Wagner
Point Informática Ltda.
Limeira, Brazil
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00456533
Message ID:
00456833
Views:
44
>Thanks for the help, but I tried manually to
>do the same in the Registry, but something
>didnt work as expected.
>Look:
>Wanted to search for file extension .RTF
>
>I Retrieved the default Value in the
>HKEY_CLASSES_ROOT hive.
>I this case: "Word.RTF.8"
>
>Executed a Search for "Word.RTF.8"
>I got this value in HKEY_CLASSES_ROOT\Word.RTF.8\shell\open\command:
>"C:\Arquivos de programas\Microsoft Office\Office\Winword.exe" /n
>
>Changed the value to this:
>"C:\ARQUIV~1\ACESSÓ~1\WORDPAD.EXE "%1""
>
>I closed Registry, started Windows again
>opened VFP in command window typed:
>
>ox= CREATEOBJECT("WSCRIPT.SHELL")
>ox.run("c:\TEST1.RTF",1,.F.)
>
>This opened Wordpad with the correct file but got this error message in VFP:
>
>OLE error code 0X80070002: The sistem couldnt find the specified file
>
>What im missing here ?
>I got the value that was changed in:
>HKEY_CLASSES_ROOT\Wordpad.Document.1\shell\open\command
>
>I never worked with Registry and I dont feel safe working with registry.
>
>PS:I looked at Solution and saw a sample in
>Get Application Information from the Windows Registry,
>but I havent found a sample to change the information in the Windows Registry
>
>Where could I find a lite sample to do this with VFP ??
>
>Thanks in advance

Peter,

The more I've thought about this the more it's bothered me.

First, I'm not for messing around with the setup of a machine. It's the user's, and, ultimately, they should be the one to decide this. I do, however, have a couple of alternatives to suggest.

Second, I'm not sure what the problem is here. It could be tied to the ProgID. If I were trying to figure this out, I'd right click while holding the shift key down and select "Open with..." from the context menu. From the Open With dialog, I'd select Wordpad and check the "Always use this program to open files of this type" check box. I'd then check the registry keys involved to see what values are there. This would mean both the default value of HKEY_CLASSES_ROOT\.rtf and that associated ProgID.

As I mentioned in the beginning, I'm not really in favor of changing these settings on someone else's machine, unless, of course, it was a temporary change that would be restored later. For example, on lengthy operations, I disable the user's screen saver and re-enable when I'm done. In this scenario, the programming has been set up so that even if the system has an error, this the screen saver is restored.

In this case, however, I'd suggest a simpler solution. Why not just use the WScript.Shell's run method to launch Wordpad, passing the file name as a parameter. It would simply be a matter of concatenating a string like this
oShell = CREATEOBJECT('WScript.Shell')
oFSO = CREATEOBJECT('Scripting.FileSystemObject')
oExe = oFSO.GetFile("C:\PROGRAM FILES\ACCESSORIES\WORDPAD.EXE")
* lcrtf is the Rich text format file of interest
oRTF = oFSO.GetFile(lcrtf)
lccmnd = oExe.ShortPath + SPACE(1) + oRTF.ShortPath
oShell.Run(lccmnd)
I've used the short paths in the above to avoid any problems associated with long file names. I've tested this and it works fine, plus it has the advantage of not messing around with the registry.

Will this work for you?
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform