This content has been marked as final. Show 9 replies
On Mon, 04 Dec 2006 21:19:14 GMT, Applied CD posted in
> I?d like to close the directory window containing file ABC.ini. I?ve got
> the full path to my ini file but the window title/caption may have been
> changed by the user (it?s a flash drive so the media is r/w). Anyone
> know an easy way to close this window?
It may depend on which program was used to open the file. I just ran a test
with baWindowList where I had start.ini opened in UltraEdit (my default .ini
app) and in Notepad. It returned both window handles:
-- [76743226, 67646]
Now, when I opened a another file in UE (uses tabbed document interface) and
had it as the front-most tab, I only got one result.
So if the user has done something similar, this method won't work all that
However, if you're using Buddy API to open that file, you can get the window
handle via other means. Possibly using baWaitForWindow in conjunction with
baRunProgram or some combination. I did something like this in the distant
past, so I can't give details, but it can be done.
baRunProgram with the wait state set to true
baWaitForWindow to get the WinHandle
If that doesn't quite get it, dig around in the other Window functions.
Mark A. Boyd
On Mon, 04 Dec 2006 21:55:24 GMT, Mark A. Boyd posted in
>> I?d like to close the directory window containing file ABC.ini. I?ve got
Upon re-reading this, I think you're asking about Windows Explorer or
whatever the Mac equivanent is (finder?).
Again, if using baRunProgram and baWaitForWindow to open that window, it
might work. However, if my guess above is correct, I wouldn't mess with it at
all. Leave it up to the user to determine when they're done with file
Just my $.02
Mark A. Boyd
Thanks Mark, but yeah, it’s a directory window so it would be owned by Windows Explorer. Actually I’m not really closing it on the user, Windows automatically opens the root directory when the flash media is mounted, I would like to close it to reduce desktop clutter when my autorun app starts*. My app has a button to open the drive or the user can do it on their own, I just don’t want Windows opening the directory automatically before my app has run.
*Actually, this is a bit of an understatement. I'm using a special type of flash media that has two mountable partitions, a conventional r/w storage partition and a "virtual CD-ROM" partition that is r/o. My app launches from the CD partition however there is a chance the storage partition will mount second and end up on top of my app ... I could probably use Buddy API to just keep pushing my app forward but even then I don't want to give users access to the storage partition until my app has made it available.
This is going to be tedious, but I think it can work.
Somehow, you are going to need to know the drive letter of the drive you
are trying to close.
Once you know which drive letter it is, you can use baFindWindow to get
the handle of the one that one. To get the handle of a Windows Explorer
window that has the g:\ drive open, for instance, you could do this:
Or, to make it all in one line, this will close the 1st Windows Explorer
window it can find that has "g:\" in the title. Since it is a freshly
mounted drive, there should not be more than one open at this time.
So the tricky bit is finding out the drive letter.
The next step depends on how your drive appears to Windows. In a test
environment, mount the drives and find out what drive letter it is on
your computer. In my example I assume it is the g:\ drive. Do this:
Hopefully it comes up with something unique and controllable. If you
know you can always make the volume name something distinct, then you
are golden. If you can guarantee that all the drives will go out and
they will be named "Whoopiee", then you can find the drive that has that
repeat with i in ["a","b","c","d","e","f","g"] --make this go up until z
if baDiskInfo(i,"name")="Whoopiee" then
If you can't guarantee the name of the partition, perhaps you can use
the free space or size options? Since it is read only, it should be
If all else fails, you can try using baFindNextFile to search for that
ABC.ini you referred to, but that may take way too long.
On Mon, 04 Dec 2006 23:29:45 GMT, Mike Blaustein posted in
> So the tricky bit is finding out the drive letter.
theDrive = (the moviePath).char[1..3]
Mark A. Boyd
That only works if the projector is running off that partition. He had
mentioned that the drive has 2 partitions, so if the exe is on the other
partition, you'll need to use the long version. If not, then yours
certainly sames some time and typing!
I’ve got the drive letter, so baCloseWindow(baFindWindow("CabinetWClass",myDriveLetter)) should be the solution.
For anyone that’s curious, the exe runs from the r/o CD partition, the ini file is a hidden file on the root level of the r/w storage partition. I’ve included my code for finding the ini file (and hence, the drive letter) below but it’s not rocket science. I know it’s possible that even though hidden, the end user may have deleted the ini file, my app uses a fall back plan if the ini file can’t be located (getIniPath returns “”)
On Tue, 05 Dec 2006 01:14:04 GMT, Mike Blaustein posted in
> That only works if the projector is running off that partition. He had
> mentioned that the drive has 2 partitions, so if the exe is on the other
> partition, you'll need to use the long version.
Right, you are.
Mark A. Boyd