Old 17th January 2002, 16:20   #1
AndyW
Junior Member
 
Join Date: Nov 2001
Posts: 10
General Purpose COM Plug-in

I'm writing a plug-in to control WinAMP by COM so that I can use it from within ASP code. If anyone has already done something like this please let me know so I don't waste my time!
AndyW is offline   Reply With Quote
Old 18th January 2002, 13:13   #2
AndyW
Junior Member
 
Join Date: Nov 2001
Posts: 10
Ok, no replies so I guess I'm the only one!

I've made good progress - I can control Play, Pause, Back, Next, etc. from the browser.

I'm having trouble with the IDs in the 200s range. The API docs say that they can only be used from within a plug-in, so I made my COM component into a WinAMP plug-in by using GenWrapper. It shows up fine in WinAMP but doesn't seem to respond to messages in the 200s range. Any operation which involves returning a string just gives 4527620 which is probably an addresss or something, but even simple things like WAU_SETRANDOM and WAU_SETREPEAT don't seem to work. Other WMUser IDs outwith the 200s range work fine, e.g. WAU_PLCOUNT.

Any suggestions?
AndyW is offline   Reply With Quote
Old 18th January 2002, 14:19   #3
Pvs3
Senior Member
 
Pvs3's Avatar
 
Join Date: Jan 2002
Location: My Pc
Posts: 116
Send a message via ICQ to Pvs3 Send a message via Yahoo to Pvs3
Are you using Visual Basic ?
Pvs3 is offline   Reply With Quote
Old 18th January 2002, 14:30   #4
AndyW
Junior Member
 
Join Date: Nov 2001
Posts: 10
Yes, VB6.
AndyW is offline   Reply With Quote
Old 19th January 2002, 17:14   #5
DJ Egg
Techorator
Winamp & Shoutcast Team
 
Join Date: Jun 2000
Posts: 36,074
http://forums.winamp.com/showthread.php?threadid=70803
DJ Egg is offline   Reply With Quote
Old 20th January 2002, 19:54   #6
AndyW
Junior Member
 
Join Date: Nov 2001
Posts: 10
Thanks for the link. Only one of those is actually a COM plug-in in ActiveX terms, the others are for the COM port. But WinAmpCOM looks promising.
AndyW is offline   Reply With Quote
Old 21st January 2002, 09:49   #7
AndyW
Junior Member
 
Join Date: Nov 2001
Posts: 10
WinAmpCOM hasn't been updated for 2 years and doesn't seem to work in Windows 2000. I just get a time-out error from ASP and then this message in the event log.

The server {24EE5A39-091B-11D3-83BE-0008C782A257} did not register with DCOM within the required timeout.

(That class ID is the one for WinAmpCOM).

Last edited by AndyW; 21st January 2002 at 10:14.
AndyW is offline   Reply With Quote
Old 21st January 2002, 20:27   #8
Pvs3
Senior Member
 
Pvs3's Avatar
 
Join Date: Jan 2002
Location: My Pc
Posts: 116
Send a message via ICQ to Pvs3 Send a message via Yahoo to Pvs3
Maby

I belive it's best to make a pluging using a wrapper rather than WinampCom. See this thread for more info and this one .
Pvs3 is offline   Reply With Quote
Old 21st January 2002, 20:40   #9
AndyW
Junior Member
 
Join Date: Nov 2001
Posts: 10
Let me clarify - I'm not using WinAmpCOM to write my plug-in, but the plug-in I'm writing is the same idea as WinAmpCOM (and I'm using GenWrapper). So, esentially I'm re-writing WinAmpCOM, but in VB, and trying to make it work in Windows 2000.

I don't know enough C++ to 'fix' WinAmpCOM, so it's easier to start from scratch.

Last edited by AndyW; 21st January 2002 at 20:56.
AndyW is offline   Reply With Quote
Old 12th February 2002, 20:40   #10
Phineas
Junior Member
 
Join Date: Feb 2002
Posts: 1
AndyW,

I was looking to do the same thing and I found this thread. How has your progress on the COM plug-in been? Are you going to publish anything soon?

-Phin
Phineas is offline   Reply With Quote
Old 13th February 2002, 14:39   #11
AndyW
Junior Member
 
Join Date: Nov 2001
Posts: 10
Phineas,

I've kind of given up because I never got past the problem described above - I can't send WMUser messages in the 200s range. I will try find the code which I've written so far and send it to you.

Andy.
AndyW is offline   Reply With Quote
Old 15th February 2002, 09:27   #12
IDispatch
Junior Member
 
Join Date: Feb 2002
Posts: 1
A couple (worthless?) suggestions...

How does Winamp determine whether messages are sent from a plugin?

I suspect that the answer is whether the message sender plugin is loaded from a Plugins\gen_*, which goes through a registration process.

Is this requirement being met? If so, are you making sure the messages arrive from the registered plugin's process rather than a COM server off in another process? Maybe the threading model you're using has something to do with this?

You might could possibly define the implementation of your interface in an appropriately named DLL. Or decouple it a bit further and write a stub that simply passes messages from your object to winamp. Even simpler, write a non-COM DLL that can trigger these messages, either by recieving its own messages or exposing a function you can call. This would, AFAIK, require you to dig into C++, but the tray control plugin has the registration and message pump code you'd need. (VC++6 can also generate a project to export symbols if that route appeals).

If none of this works (or if I just misunderstand the problem , I'd be interested to see if I can get your code working. I admit to not being familiar with the VB wrapper mentioned, as well as a little rusty on my COM, but it seems this problem is simple enough to have a feasible workaround.

Luck,
-I,Dispatch
IDispatch is offline   Reply With Quote
Old 16th February 2002, 14:25   #13
loungeroom
Junior Member
 
loungeroom's Avatar
 
Join Date: Oct 2001
Location: Melbourne, Australia
Posts: 25
yup,

sounds like winamp registration, IDispatch's first point. that's why your VB project and all the out of process messages work, but none of the internals ones do (200s range).

but why an exe module ? that's annoying. it only shows up in VB's references while it's running.

the author only has this to say on the topic:

Quote:
Q: How did you retrofit COM into a Exe using a Dll?
A: Using a frigged ATL app wizard exe, and messing about with the code to make a COM apartment from a Dll. You can get the source from my website.
I can think of no other benefit other than as IDispatch suggests, something to do with apartments.( sheeit, i can't even set a breakpoint in the tutorial APE, what do i know ?)

It might also explain the DCOM failure, since
</blunt assertion debatability=moderate >
exe modules are only registered for the lifetime of the object (as evidenced by the missing references in visual basic)
</blunt assertion>

could all this be resolved by porting the winampCOM code into a plain old ATL DLL ? let you know the results...

loungeroom
loungeroom is offline   Reply With Quote
Old 19th February 2002, 13:00   #14
loungeroom
Junior Member
 
loungeroom's Avatar
 
Join Date: Oct 2001
Location: Melbourne, Australia
Posts: 25
sorry, this is way ot, but I just had to get it out there....

ok,

so porting didn't take too long, thankfully. there was more taking out code than putting in. a (traditional) COM exe module has to register itself at startup, so most of this code got tossed (it's all wizard generated anyway...).

So once it was all compiling, a quick check in VB's object browser (F2) confirmed that I had the type library properly registered (tho' the IIDs and CLSIDs are still the same - this just means that the last server to register wins, i think).

i noticed in the sample app for winampCom (the playlist copier) that if you hit the button to copy the playlist and winamp isn't started, it will start winamp. The DLL version doesn't do this and could run into problems here depending on how the DLL is set up. A multi-instance DLL would be loaded in the application space of the VB app, starting winamp means another copy of the DLL is loaded as part of winamps plugin registration process (inprocess). subsequently the dll the vb app is communicating to is not the same as the winamp one loaded as a plugin. bzzzt, no internal messages. more to the point, even if winamp was started first, the vb app would still load it's own local copy of the DLL to fulfill object references. bzzt, still no internal messages.

so the upshot of all that means that the author probably intended winampCOM to act as a system wide COM singleton that would always be loaded by winamp in the event of plugin registration.

well that was fun...

loungeroom.
loungeroom is offline   Reply With Quote
Old 19th February 2002, 18:26   #15
engie
Junior Member
 
Join Date: Feb 2002
Posts: 2
Returned value from a 200+

Hi - when a 200+ api returns a value, it's a pointer to a strnig. use this code to get the actual string:

Public Function StringFromPointer(ByVal lPointer As Long) As String
'
Dim strTemp As String
Dim lRetVal As Long
'
'prepare the strTemp buffer
strTemp = String$(lstrlen(ByVal lPointer), 0)
'
'copy the string into the strTemp buffer
lRetVal = lstrcpy(ByVal strTemp, ByVal lPointer)
'
'return a string
If lRetVal Then StringFromPointer = strTemp
'
End Function

(I hit this problem yesterday :-))

Hope that helps

engie
engie is offline   Reply With Quote
Old 19th February 2002, 18:27   #16
engie
Junior Member
 
Join Date: Feb 2002
Posts: 2
D'OH

Forgot, you'll need these API declarations to make it work:

Private Declare Function lstrlen Lib "kernel32" Alias "lstrlenA" (ByVal lpString As Any) As Long
Private Declare Function lstrcpy Lib _
"kernel32" Alias "lstrcpyA" (ByVal lpString1 As String, _
ByVal lpString2 As Long) As Long
engie is offline   Reply With Quote
Old 15th April 2007, 09:20   #17
Synvb
Junior Member
 
Join Date: Jun 2003
Location: Arlington, TX
Posts: 12
Send a message via AIM to Synvb Send a message via Yahoo to Synvb
IT WORKS!

I've tried for months to do what your 5 lines of code does!!!

I am upset, but VERY excited at the same time!

P.S. THANK YOU SOOOOOOOOOOOOOOOOOOOOOOO MUCH!
Synvb 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