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

registry install location 2

Status
Not open for further replies.

JJ1

Programmer
Apr 19, 2001
104
GB
Hi All,

My app needs to play some sounds using the "Playsound" method in "winmm.dll" as follows:

lngRetVal = PlaySound("D:\WebbIE0.6\Icons\start.WAV", 0, 0)

Problem is that the location of "start.wav" will change, depending on which location the user installs the software to. (They might use the C: drive instead of D:, for example)

I'm sure there must be some way of fixing this by storing a registry entry during installation.

Could anyone advise me on this please? Any help would be much appreciated.

Thanks in advance,


James.
 
there is a variable called App.Path this is the path of your application after it has been installed.

Hope this helps.
 
I only came across this problem recently. The way I looked at it is installing the wav file in the same directory as the application. That way you can find the application Name which includes the directory and all you have to do is remove the application name and add the wav name instead. There maybe better ways to do this.
Here is some code that may help you.

Dim App As Application
Dim StrFilePath As String

Set App = CurrentApplication
StrFilePath = App.Name
App.Close
Do
StrFilePath = Left(StrFilePath, Len(StrFilePath) - 1)
Loop Until Right(StrFilePath, 1) = "\"
StrFilePath = StrFilePath & "SoundFile.wav"

StrFilePath contains the directory and name of you wave file. All you have to do is in the setup wizard store the wav file in the $(AppPath) same as your application.
 
Thanks guys, this was very helpful. :)


James
 
BTW, I only needed to use 'App.Path', rather than lefting the string until you get the '\'. Perhaps because I'm using the latest service pack of VB 6?

Also, there seems to be no need to use:
'Set App = CurrentApplication', 'App.Close'

James.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top