LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic pathname?

Hallo,

in my program I have to use about 50 audiofiles. (playing with sndPlaySound())
They are all in one folder. I used for playing the audiofile the direct pathname.
But this will be a problem, when I want to run the program on another computer.
My idea is to install always the audiofiles in the same folder as the *.exe.

1. Is there a way to use not the direct pathname, something like a dynamic pathname?
2. Is there a way to read out the pathname of the *.exe, so that I can say where my program will find the audiofiles?

thank you
Florian
0 Kudos
Message 1 of 3
(2,647 Views)
The running program directory can be obtained with GetProjectDir () function.

As per dynamic pathnames, you could set the current working directory with CurDir () function to the files directory, this should permit sndPlaySound to find your sounds.

The directory of the files could be stored in a configration file to update on every machine to the actual directory: the program could read the configuration file when starting and set the current working directory to the pathname stored in it.

But on winSDK is specified that sndPlaySound is present only for backward compatibility and that PalySound function should be used instead. PlaySound documentation refers to OpenFile function for details on directory searching order, and in that function it is stated:

"If the lpFileName parameter specifies a file name and extension only, this function searches for a matching file in the following directories, in the order shown:

1. The directory from which the application loaded.
2. The current directory.
3. Windows 95: The Windows system directory. Use the GetSystemDirectory function to get the path of this directory.
Windows NT/2000: The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is SYSTEM32.

4. Windows NT/2000: The 16-bit Windows system directory. There is no Win32 function that obtains the path of this directory, but it is searched. The name of this directory is SYSTEM.
5. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
6. The directories that are listed in the PATH environment variable. "


That is: if you store the files in the executable's directory you should find them without any other specification.

Hope this helps
Roberto


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 3
(2,642 Views)
Yes you helped me again very much.
I will try this...

kind regards
Florian
0 Kudos
Message 3 of 3
(2,639 Views)