Page 1 of 1 1
Topic Options
#199282 - 2010-08-04 03:30 PM UserAccounts.CommonDialog vs BrowseForFile and BrowseForFolder
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
As the UserAccounts.CommonDialog object can no longer be used in any Windows version newer then XP I'm looking for a replacement.

The code below works fine for folders but I actually need it for files. I found something about BrowseForFile instead of BrowseForFolder but I don't seem to be able to find/get/make some working code.
What I need is something similar like below that returns the filename with the full path or the filename and the path separated.

Maybe I'm just not skilled enough in COM scripting.
Does anyone have a bright idea?


 Code:
Break on

Dim $oApp, $ofolder, $RootPath

$oApp = CreateObject("Shell.Application")
$ofolder = $oApp.BrowseForFolder(0, "Select folder", 16384)
$filename = $ofolder.Title
$RootPath = $ofolder.Self.Path

? @ERROR
? @SERROR

?$filename
? $RootPath

$oApp = ""

Sleep 5
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#199288 - 2010-08-04 04:09 PM Re: UserAccounts.CommonDialog vs BrowseForFile and BrowseForFolder [Re: Mart]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
If you have MSCOMDLG32.OCX, and registered it you can use the following code:
 Code:
Function BrowseForFile($strPath, $strFilter)
  Dim $objDialog, $intResult
  $objDialog = CreateObject("MSComDlg.CommonDialog")
  $objDialog.Filter = $strFilter
  $objDialog.InitDir = $strPath
  $objDialog.MaxFileSize = 256
  $objDialog.Flags = &80000+&4+&8
  $intResult = $objDialog.ShowOpen()
  $BrowseForFile = $objDialog.FileName
EndFunction

$FileName = BrowseForFile("c:","*.kix")

Top
#199289 - 2010-08-04 04:16 PM Re: UserAccounts.CommonDialog vs BrowseForFile and BrowseForFolder [Re: Arend_]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
No, do not have mscomdlg32.ocx. Sure I can download the VB 6.0 common controls package from the MS website but this requires me to install it on every machine that needs the small app I'm making.

BrowseForFile and BrowseForFolder seem to be native in Vista and 7.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#199292 - 2010-08-04 04:38 PM Re: UserAccounts.CommonDialog vs BrowseForFile and BrowseForFolder [Re: Mart]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
Hi Mart,

Man, I can get a file selected, just can't find the correct names. I'll keep looking.

Tough one!

Top
#199320 - 2010-08-05 08:00 AM Re: UserAccounts.CommonDialog vs BrowseForFile and BrowseForFolder [Re: Mart]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
 Originally Posted By: Mart
No, do not have mscomdlg32.ocx. Sure I can download the VB 6.0 common controls package from the MS website but this requires me to install it on every machine that needs the small app I'm making.

BrowseForFile and BrowseForFolder seem to be native in Vista and 7.


BrowseForFile doesn't exist. At least not in any Windows 6.x Common Controls.

Top
#199321 - 2010-08-05 09:15 AM Re: UserAccounts.CommonDialog vs BrowseForFile and BrowseForFolder [Re: Arend_]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Originally Posted By: apronk
 Originally Posted By: Mart
No, do not have mscomdlg32.ocx. Sure I can download the VB 6.0 common controls package from the MS website but this requires me to install it on every machine that needs the small app I'm making.

BrowseForFile and BrowseForFolder seem to be native in Vista and 7.


BrowseForFile doesn't exist. At least not in any Windows 6.x Common Controls.


Yeah, I know. At first I found some posts saying that it did but that turned out to be bad intel.
I found some custom made stuff when Googling but no luck yet. I'll keep trying and searching.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#199324 - 2010-08-05 11:29 AM Re: UserAccounts.CommonDialog vs BrowseForFile and BrowseForFolder [Re: Mart]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
Well, browseforfolder can search for a file if you put in hex 4000. I just couldn't figure out how to get the data out of the object. I was searching all over. \:\(
Top
#199325 - 2010-08-05 01:49 PM Re: UserAccounts.CommonDialog vs BrowseForFile and BrowseForFolder [Re: BradV]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
For now I went with what Arend suggested.
Besides the fact that every wksta requires some attention it works great.

I'll incorporate a check for the dll and stuff at startup of the app.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 456 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.059 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org