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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Explorer 1

Status
Not open for further replies.

Bryan - Gendev

Programmer
Jan 9, 2011
408
AU
I give my users a chance to look in a folder before my app writes more files there.

I use

ShellExecute (0,"", Getenv("SystemRoot") + "\explorer.exe", "/n, /e, " + lcCurDir, "", 1)

My question is - how can I close this folder after I've finished writing to it?


Thanks

GenDev
 
You can't directly, as ShellExecute doesn't give you something you can refer to later.

You should instead embed a folder display, for example via embedding an activex (olecontrol) webbrowser control, which you navigate to "file://"+lcCurDir.

I think I've also seen display of an explorer directory embedded via olecontrol.

Bye, Olaf.
 
m.lcTempFolder = Getenv("SystemRoot")
OpenFolder(m.lcTempFolder)

FUNCTION OpenFolder && Public Code From Foxpro Forums. I did not take the note author.
PARAMETERS tcFolderName As String
LOCAL loObject As Object
m.lcFileName = m.tcFolderName
m.loObject = CREATEOBJECT("Shell.Application")
m.loObject.Open(m.lcFileName)
ENDFUNC
 
ugurlu,

OK, and now back to the original demand: Close that new window you open programmatically, after you've finished writing to it.

Code:
m.lcTempFolder =  Getenv("SystemRoot")
m.loFolder = OpenFolder(m.lcTempFolder)
Wait ' TimeOut 4 
m.loFolder.Windows(m.loFolder.Windows.Count-1).Quit()

FUNCTION OpenFolder() 
    PARAMETERS tcFolderName As String
    LOCAL loObject As Object
    m.lcFileName = m.tcFolderName
    m.loObject = CREATEOBJECT("Shell.Application")
    m.loObject.Open(m.lcFileName)

    Return m.loObject
ENDFUNC

Bye, Olaf.
 
Yes, I agree. When I first saw this question, I also thought of suggesting CREATEOBJECT("Shell.Application"), but as far as I can see, there's no way to get an object reference to the folder, so no way to close it.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top