Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Retrieving installed component's version (Read 4293 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Retrieving installed component's version

Hi all,

I'm trying to grab the version info of the components in foobar2000's component folder, but am a bit lost on exactly how to do it. foosion has provided some insight into how to do it in this thread:

Quote
For future reference, this is how component DLLs are loaded:
1. The core loads the component DLL using LoadLibrary().
2. The core retrieves a pointer to the foobar2000_get_interface() function and calls it to obtain a pointer to the DLL's foobar2000_client object.
3. After checking that the component's version is compatible with the core, the core calls foobar2000_client::get_service_list(). It also sets the component DLL's path and sets the stored configuration data (if any).

So far I've got this, but am having problems compiling when foobar2000_client_impl is being used.

Code: [Select]
typedef foobar2000_client* (__cdecl *MYPROC)(foobar2000_api* p_api, HINSTANCE hIns); 
 
HINSTANCE hinstLib;
MYPROC fooProc;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
 
hinstLib = LoadLibrary(TEXT("components\\foo_bpm.dll"));
 
if (hinstLib != NULL)
{
    fooProc= (MYPROC) GetProcAddress(hinstLib, "foobar2000_get_interface");
 
    if (NULL != fooProc)
    {
        fRunTimeLinkSuccess = TRUE;
        console::formatter() << "Accessing foo_bpm.dll OK";

        // I'm not sure what to pass into foobar2000_get_interface here
        // foobar2000_client_impl causes a compiler error, even though the foobar2000_component_client project is included in the solution
        foobar2000_client_impl client* = (foobar2000_client_impl) (MYPROC) (NULL, NULL);
    }

    fFreeResult = FreeLibrary(hinstLib);
}

if (!fRunTimeLinkSuccess)
    console::formatter() << "Failed to access foo_bpm.dll";

Can anyone guide me in the right direction?
Also is it possible to access component versions through the foobar2000 core rather than me loading each dll at run time?

Retrieving installed component's version

Reply #1
See service_instance_array_t<T>. To enumerate the componentversion instances:
Code: [Select]
void somefunc()
{
  service_instance_array_t<componentversion> array;
  for (t_size index = 0; index < array.get_size(); ++index)
  {
    // use array[index]
  }
}

By the way, what exactly are you trying to accomplish?

Retrieving installed component's version

Reply #2
Awesome, thanks for that  I knew there had to be a simpler way.

I'm working on a component for managing the installation and updating of 3rd party foobar2000 components. I need to know the version info of the installed components so it knows whether or not to download new components. Hopefully with the info you've provided I'll be able to release it in the next couple of days

Retrieving installed component's version

Reply #3
Is it designed to work with limited user accounts?

Retrieving installed component's version

Reply #4
Cool!

If I can be cheeky, a feature I've often wanted is a way to identify included components versus separately downloaded, to aid in clearing out no longer wanted 3rd party components without accidentally removing core functions. If you think it's a good idea.

Retrieving installed component's version

Reply #5
That sounds like a darn fine idea. I shall add it to my to do list.

Retrieving installed component's version

Reply #6
That sounds like a darn fine idea. I shall add it to my to do list.

Many, many, many thanks!

I suppose I should now set up a Windows box again. A month with just gxine is wearing thin anyway.

Retrieving installed component's version

Reply #7
I'm working on a component for managing the installation and updating of 3rd party foobar2000 components.
Heh I have made an automatic updater too. Well it doesn't actually update anything and the process is far from automatic, so that's probably why it has been in alpha status for over half a year, despite friendly encouragement by the single person who liked the idea. Maybe I could produce some public release too, so you know how I tried to do it
Full-quoting makes you scroll past the same junk over and over.

Retrieving installed component's version

Reply #8
I've just released the component  http://www.hydrogenaudio.org/forums/index....showtopic=78708

Thanks again for your input foosion.

Yirkha, perhaps you could post in the thread with the ideas you had when coming up with your component updater? I'd be interested to see the approach you took to things