Old 20th January 2002, 23:15   #1
hjhardly
Junior Member
 
Join Date: Jan 2002
Location: Houghton, South Australia.
Posts: 4
Running multiple instances?

I put this into Newbies, but was suggested this is the better forum.
(Further comment added today)

I have been developing an application which uses WinAmp V2.77 as
its MP3 output device. I want to be able to run up to 3 instances
of WinAmp at the same time and control each. I have been using
Alex Muzika's Delphi VCL (modified) to provide the interface.
No problems launching multiple instances, each playing its own
MP3, but when I try to pause/stop/read orset position, etc of ANY
instance it always refers to the last instance. Even after closing
the last instance, the earlier one(s) are not accessible from
Delphi, although they are separately controllable directly on the
WinAmp window.

I launch with a different /CLASS for each, so that is not the
problem. I've not yet checked to see if the same handle is coming
back.

Any ideas or is true multiple instances impossible?

TIA

Howard
hjhardly is offline   Reply With Quote
Old 23rd January 2002, 23:04   #2
GotRice
Junior Member
 
Join Date: Jan 2002
Posts: 6
Re: Running multiple instances?


I'm also new to Windows programming so bear with me

I'm not sure how your code looks like so I'll just take a stab at this...

Each Winamp Instance has its own unique window handle hwnd. You are on the right track by specifying /CLASS and provide different class names for the instances. Let say you want 3 instances running at at the same time. Obtain the handle of each instance by issueing FindWindow 3 times with different CLASSNAME in each FindWindow and save these 3 handles in three different hwnd variable. You can then use the hwnd to control each instances.

Sorry about my rusty English (it's not my native toungue )..

Hope this helps!!
GotRice is offline   Reply With Quote
Old 23rd January 2002, 23:59   #3
hjhardly
Junior Member
 
Join Date: Jan 2002
Location: Houghton, South Australia.
Posts: 4
That is where I'm at. I have multiple copies of the WinAmp Visual
Component in my Delphi Application (2 at present will still show
the problem quite well). The WinAmp VCL uses a different classname,
for each copy and verifies the handle after start by callback.
I know this works because my first attempt had it wrong and I got
the expected error message.

The problem is that I can launch several copies of WinAmp and
start each one with an MP3, but only the last instance gets
control via the VCL. It can be stopped, paused, etc. from the
buttons related to any other control, and only that last one
can be removed. If I then restart one of the other instances,
it then has the attention of any action supposedly associated
with one of the other instances. I agree it looks as though
the handle is the problem, so may have to put patch code to
monitor what handle is being used in each instance.

Is it possible that the use of the SendMessage with a Button
equate constant and WM_USER always references the last instance?

Howard
hjhardly is offline   Reply With Quote
Old 27th January 2002, 03:44   #4
hjhardly
Junior Member
 
Join Date: Jan 2002
Location: Houghton, South Australia.
Posts: 4
The problem has been resolved (nearly). The original VCL had
variables declared as public, rather than private, so they were
being overwritten under some circumstances. This solved the
problem, allowing me to have multiple, separately controlled
instances of WinAmp running under Delphi. There are still a
couple of minor problems to iron out but they are not critical,
such as how to preset the visibility of the EQ and PlayList
windows. At this stage, they can not be accessed until some
time after the main window is created, so there is the need
to put a delay into the code. There is also a niggling concern
where I'm seeing the same handle for different windows, yet
they are individually accessible.

A little off topic, but the root cause of the original problem:
My concern is how Delphi allowed the code to cross-reference
when the variables were declared in the interface area. Can
someone answer this? (Maybe it is because only one copy of the
code is present and these variables are not scoped separately?)

Howard
hjhardly 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