Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I open and display a folder on the desktop from VFP? 4

Status
Not open for further replies.

kazl

Programmer
Dec 9, 2002
68
GB
Hello everybody.

Is there an easy way in VFP6 to open/display a folder on the desktop as though it had been opened via My Computer?

I am creating a set of PDF files which will be attached to an email, but not with Outlook automation.

I want to generate the reports in a new folder and then programmatically (sp!?) open/display this folder in Win98 or XP so the files can be selected from outside VFP.

Thanks in advance for any ideas.

Karen
 
set defa to "C:\Documents and Settings\Owner\Desktop"
xfile = getfile()
set defa to "c:\original default"

Jim
 
The following is modified from a FAQ I wrote awhile back...take the code below and cut-n-paste it into a prg and run it from within VFP to see how it works. Make sure you have a folder called SomeFolder on your desktop or modify the code to the name of the folder you are trying to open. You will notice at the end that I am using commandline switches to make Explorer open the way we want it to...more information on these can be found at
Get Path To Windows Special Folders (such as Desktop)
faq184-4264


Code:
#DEFINE CSIDL_DESKTOP 0x0000
*!*   The virtual folder representing the Windows desktop, the root of the namespace.

LOCAL cFolderPath, cDesktopPath, cDesiredFolder
cFolderPath = space(255)

DECLARE SHORT SHGetFolderPath IN SHFolder.dll ;
    INTEGER hwndOwner, INTEGER nFolder, INTEGER hToken, ;
    INTEGER dwFlags, STRING @pszPath

SHGetFolderPath(0, CSIDL_DESKTOP, 0, 0, @cFolderPath)

cDesktopPath = Alltrim(cFolderPath)

cDesktopPath = ADDBS(SubStr(cDesktopPath,1, Len(cDesktopPath)-1))
cDesiredFolder = cDesktopPath + "SomeFolder"
RUN /N7 explorer.exe /e,/root, &cDesiredFolder

boyd.gif

craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Karen,

If you know the full path to the folder in question, the easiest way is simply to ShellExecute() it. If you don't know how to use ShellExecute(), see:

If you don't know the path to the folder, you can obtain it as follows:

ow = createobject("wscript.shell")
cdesk = ow.SpecialFolders("desktop")
cmyfolder = addbs(cdesk) + "MyFolder"

You can then ShellExecute() cmyfolder to get the desired result.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
To use the solution that Mike proposed with Windows 98 you'll need to make sure that the user has the Windows Script Host installed on there machine...it doesn't come stock with Windows 98.

boyd.gif

craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Craig,

you'll need to make sure that the user has the Windows Script Host installed on there machine...it doesn't come stock with Windows 98.

I might be wrong (again), but my understanding is that WSH is installed with IE 3.0 and above. And so will always be present in Win 98, but not necessarily in 95.

However, it is possible to disable it in all versions of Windows, so my solution would not work if the user had done that.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
I stand corrected, thanks Mike. I went out and did a quick look to see what was with what and Windows 98 does come with WSH 1.0...it's included in the accessories area of the windows components but is not installed by default.

Windows 98 (WSH 1.0)
Windows NT 4 Option Pack (WSH 1.0)
Windows ME (WSH 5.5)
Windows 2000 (WSH 2.0) also known as WSH 5.1 - confusing right?
Windows XP (WSH 5.6.0.6626)
Windows 2003 Server (WSH 5.6.0.8515)

Windows 95 users would need to download/install it from:
but, it should be noted that WSH 5.6 is not officially supported on Win95

Also...
MSDN said:
The minimum requirement for WSH
to function is Internet Explorer version 3.0 or later.
..so it is just like you said Mike

IE 3 comes with WSH 1.0
IE 4 comes with WSH 2.0
IE 5 comes with WSH 2.0 (perhaps where the 5.1 comes from?)
IE 6 comes with WSH 5.6

boyd.gif

craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Navigate to a directory in Explorer
thread184-797392

Brian
 
Wow. Thanks very much everyone.

I'll try these out on Monday.

Kaz
 
Hello.

I have used the solution suggested by baltman. It's perfect for what I need. All of your posts are useful though and I will look into ShellExecute a bit more when I've time.

Thanks again for the help. Have a star from me.

Karen
 
Thank you for the star, and I'm glad you found something perfect for your needs.

boyd.gif

craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
I didn't deserve a star. I didn't read the whole question.

Jim
 
If I may pick up on Karen's thread - is there a way of opening Exlorer in a particular folder and have the folder list open on the left side of the Explorer window?

Thanks,

Stewart
 
Hi Stewart

=== quote - Baltmans code with a change ===
DECLARE INTEGER ShellExecute IN shell32.dll ;
INTEGER hndWin, ;
STRING cAction, ;
STRING cFileName, ;
STRING cParams, ;
STRING cDir, ;
INTEGER nShowWin
cFileName = "explorer"
cAction = "open"
cPath=[C:\Program Files]
** The above line is the one I changed for a sample...
** I believe this is clear.. if not please ask again..
ShellExecute(0,cAction,cFileName,cPath,"",1)

I think your question is answered.

GETDIR() will also do your job.
:)

____________________________________________
ramani - (Subramanian.G) :)
 
Hi Ramani, good to see your name again.

Thanks for your reply. I think I may not have explained what I wanted properly.

I know about using ShellExecute to open Windows Explorer but if, after I have called ShellExecute, I want to see the folder list, I have to click the Folders button in the toolbar.

What I'd like to know is if there is a way of calling up Windows Explorer with the Folders list already in place.

Thanks,

Stewart
 
StewartUK,

Please run the code I have provided at the top of this thread. The /e switch is used to bring up explorer in multipane view just like you want.

boyd.gif

craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top