LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Set Windows XP Default File Dialog Directory

Anyone know how to set the default directory that shows when a file dialog box is opened in Windows XP? I am using a subVI from the NI website that allows multiple files to be selected from a file dialog box, BUT there is no start directory input into the VI, and the VI is based on DLL calls for which the code was not provided. Ideally I was hoping I could set the default directory for XP in Labview, so that each time this Select Multiple Files subVI is called I can read the directory of the files selected, then set the default directory to that directory, so it is updated every time.
 
Michael
0 Kudos
Message 1 of 5
(3,295 Views)

"miguelc" <x@no.email> wrote in message news:1174489813402-495153@exchange.ni.com...
Anyone know how to set the default directory that shows when a file dialog box is opened in Windows XP? I am using a subVI from the NI website that allows multiple files to be selected from a file dialog box, BUT there is no start directory input into the VI, and the VI is based on DLL calls for which the code was not provided. Ideally I was hoping I could set the default directory for XP in Labview, so that each time this Select Multiple Files subVI is called I can read the directory of the files selected, then set the default directory to that directory, so it is updated every time.
&nbsp;
Michael



Try the windows api SetCurrentDirectory (kernel32.dll). It has only one input, the new path as a string. Return value 0 means there was an error.


Regards,


Wiebe.
Message 2 of 5
(3,291 Views)
I have tried implementing the SetCurrentDirectory but it doesn't seem to work as wanted. I run the Select Multiple Files VI, and take the first file, strip the path of the file, and call the kernel32.dll to SetCurrentDirectory. If you select more than one file, the Open File dialog box will not default to that directory the next time you run the program.
I read on msdn2 (http://msdn2.microsoft.com/en-us/library/ms646839.aspx) about OPENFILENAME struct, and how it is used to determine the initial directory for an open file dialog box, but I'm not sure how to access that struct. Maybe this is what I need to change, or maybe I have to use the SetCurrentDirectory somehow in conjuction with the other DLL call (which I don't know how to do since I don't have the code for it). Any ideas?
 
I don't have experience with .llb's, so I'm having a problem attaching. I've attached the modified File Dialog (Windows API) VI, the rest of the files can be found at http://zone.ni.com/devzone/cda/epd/p/id/4737
 
Michael

Message Edited by miguelc on 03-21-2007 01:22 PM

0 Kudos
Message 3 of 5
(3,287 Views)

Aha! So I've learned a little since my last post... OPENFILENAME is a struct that you create and pass to the GetOpenFileName method to work with Open File dialog boxes. I happened across an example (of Wiebe's http://forums.ni.com/ni/board/message?board.id=170&message.id=75652&requireLogin=False) that implemented this in Labview, and didn't hide things in an unknown DLL like the Select Multiple Files example I found on the NI website. I modified Wiebe's example with the SetCurrentDirectory after each run of the Multi File Dialog VI, then each time it runs I use the GetCurrentDirectory to pass that as the default directory. Works great. Great example Wiebe. I think it should replace the one on the NI website.

Michael

0 Kudos
Message 4 of 5
(3,268 Views)

Hi Miguel,

If you want to submit the example please do so here:

http://community.ni.com/

An example is worth a million words!!!!!

Brian K.
0 Kudos
Message 5 of 5
(3,247 Views)