Old 5th May 2007, 19:05   #1
XStatic
Junior Member
 
Join Date: May 2007
Posts: 4
Detect Winamp Installation Directory via Registry

I'm writing an application which will be controlling winamp via the command line. The problem I'm running into is that the registry keys I'm using to locate the Winamp installation directory aren't the same on 64 bit installations of Windows (I understand why they aren't, that's not an issue) so I was wondering if there were any registry keys that are both A) the same on both 32 and 64 bit versions of Windows which B) point to the Winamp installation directory.

If not, I can always detect the bitness of the installed version of Windows to get at the correct registry key, but it'd be cleaner if there was one registry key to get me to the Winamp installation directory.

Thanks
XStatic is offline   Reply With Quote
Old 5th May 2007, 19:18   #2
DrO
 
Join Date: Sep 2003
Posts: 27,873
there is no direct registry key to point to the installation directory. the only location is that of the last install via the uninstall option (HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp). i don't know how that varies between the 64 and 32-bit registry hives so is something you'd have to find out yourself. as a general rule, winamp doesn't use the registry apart from required file association aspects and the uninstall section

-daz
DrO is offline   Reply With Quote
Old 5th May 2007, 19:56   #3
XStatic
Junior Member
 
Join Date: May 2007
Posts: 4
Quote:
Originally posted by DrO
there is no direct registry key to point to the installation directory. the only location is that of the last install via the uninstall option (HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp). i don't know how that varies between the 64 and 32-bit registry hives so is something you'd have to find out yourself. as a general rule, winamp doesn't use the registry apart from required file association aspects and the uninstall section

-daz
Wow, fast response...very nice. The difference is that Windows 64 bit creates a new key under HKLM\Software called WOW6432node which is where 32bit app info is stored when running on a 64bit OS, so I'd be required to make a call into the Win32 API to find out if the OS is 64 bit so I can retrieve the correct key...the uninstall key above becomes HKLM\Software\WOW6432node\Microsoft\Windows\CurrentVersion\Uninstall\Winamp

I realize that Winamp is virtually registration free (which has its own pluses and minuses)...regardless, what is the standard way of retrieving the Winamp installation directory? How do the theme/plugin/etc writers retrieve this value?

There is a concept known as registry redirection included in Windows x64 that I'm looking into...if that solves my issue I'll post the answer here.

Thanks again for the reply.
XStatic is offline   Reply With Quote
Old 5th May 2007, 21:23   #4
DrO
 
Join Date: Sep 2003
Posts: 27,873
for the moment (or indefinitely - just not sure on if x64 OSes will be handled any differently for such things in future), the winamp installer hasn't been altered in anyway to make use of the redirection (since the latest version of nsis now supports that but the winamp installer doesn't use any of that at the moment)

Quote:
what is the standard way of retrieving the Winamp installation directory? How do the theme/plugin/etc writers retrieve this value?
basically is just from using the registry key i refered to and as needed letting the OS do the redirection as needed on it (with that key being the only hackish way to get the install directory which obviously goes wrong for multiple installs like i have here)

-daz
DrO is offline   Reply With Quote
Old 5th May 2007, 21:50   #5
XStatic
Junior Member
 
Join Date: May 2007
Posts: 4
Fair enough. For now I'll just figure out the bitness of the OS during the installation of my app and get the correct reg key.

Thanks for your help!
XStatic is offline   Reply With Quote
Old 7th May 2007, 21:52   #6
XStatic
Junior Member
 
Join Date: May 2007
Posts: 4
This may come in handy for any C# developers out there attempting to automate Winamp via the command line...here is how to get the installation directory via the registry keys mentioned above for both 32 bit and 64 bit versions of Windows:

RegistryKey _winampKey;
string _winampPath = string.Empty;

_winampKey = Registry.LocalMachine.OpenSubKey(@"\Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp") != null
? Registry.LocalMachine.OpenSubKey(@"\Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp") // 32 bit
: Registry.LocalMachine.OpenSubKey(@"\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Winamp"); // 64 bit

if (_winampKey != null)
{
_winampPath = (string)_winampKey.GetValue(@"UninstallString");
_winampPath = _winampPath.Remove(_winampPath.LastIndexOf(@"\"));
_winampPath += @"\winamp.exe";
_winampPath = _winampPath.Insert(_winampPath.Length, new string(new char[] {'"'}));

Maybe there is a cleaner way to do it, but this is what worked for me.
XStatic is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Winamp > Winamp Technical Support

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump