What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Call2 function

Call2 function
Author: Message:
smeuuh
New Member
*


Posts: 4
Joined: Apr 2006
O.P. Call2 function
Hello.
I'm currently trying to make a neat plugin which will get the song played from winamp, and change the avatar with the cover winamp is playing (using the folder.jpg files in each album's folder)
So the method i'm trying is the following :
- make a C++ DLL which, when called, will return the string containing the currently played song's filename
- call it by Interop.Call2, do some stuff and change the avatar

Looking in the plus scripting help, i found that the string returned must be a "bstr". I have a C-style string (char*) containing the file name (although it's not unicode, i wonder if it will prevent it from working ... well, will see later), I want to return it as a bstring.
I tried the following :

OLECHAR title2[1024];
   for(int i = 0;i<1024;i++) title2[i] = title[i];
   return SysAllocString(title2);
, as advised in the help, but it fails to compile ("  [Linker error] undefined reference to `SysAllocString@4' ")
I also tried return title2; It compiles, but i don't know if it works :/

Another thing that bothers me is : how to make my function "call2-visible" ?
My code is :
__declspec(dllexport) __stdcall BSTR GetTitle();
__stdcall BSTR GetTitle()
{
//do stuff, return the BSTR
}
BOOL APIENTRY DllMain(HANDLE hModule, DWORD dwReason, LPVOID lpReserved)
{
        return TRUE;
}


My script is :
function OnEvent_ChatWndSendMessage(ChatWnd,Message )
{
    return Interop.Call2("GetFileName.dll","GetTitle");
}
and it doesn't work :/

I have really little experience in writing C++ DLL, so excuse me if my questions seem stupid :$
Thanks in advance
Smeuuh

This post was edited on 11-03-2006 at 04:43 PM by smeuuh.
11-03-2006 03:38 PM
Profile E-Mail PM Find Quote Report
Delphi Thunderbolt
Junior Member
**

Avatar
The insane developer

Posts: 53
Reputation: 1
35 / Male / –
Joined: Sep 2004
RE: Call2 function
Is it absolutely necessary to write in C++?

It would probably easier to use a language thats a little more higher level ie. Visual Basic or Delphi.

-OR-

You could try getting a value from another WinAMP plugin and then working from that.
For Windows Media Player, just use the built in system.

Hope that helps.
[Image: thundtacuserbar.gif]

It's my freedom, it's my duty, it's my war.

The day will go dark and quiet as the mighty Thunderbolts announce the end of the world...
11-04-2006 05:13 AM
Profile E-Mail PM Web Find Quote Report
phalanxii
Full Member
***


Posts: 146
Reputation: 5
32 / Male / Flag
Joined: Aug 2006
Status: Away
RE: Call2 function
You should check out -dt-'s Music now playing script. It has a function to get Winamp's title from either the track's metadata, or from the string sent by Winamp. It can also get the album name as well (might be useful for you). This will probably save you a lot of time (no DLL needed)! (Y)

PS. You can also use this to get information from Windows Media Player and iTunes.
11-04-2006 08:35 AM
Profile PM Find Quote Report
smeuuh
New Member
*


Posts: 4
Joined: Apr 2006
O.P. RE: Call2 function
I can't believe i've been so stupid :)
In fact, the functions I use to retrieve the filename are in the windows API, and can be called directly by the script.
dt's Music now playing script helped me alot, and my plugin now works correctly. Thanks everybody.
If someone wants it, it's really simple, if using the Winamp class od dt's script :
function OnEvent_Initialize()
{
    MsgPlus.AddTimer("timer",100);
    win = new Winamp();
}
var win;
function OnEvent_Timer(TimerId)
{
    var filename;
    if(win.isOpen()) filename = win.CurrentFilename();
    var pos = filename.lastIndexOf("\\");
    Messenger.MyDisplayPicture = filename.substring(0,pos) + "\\folder.jpg";
   
   
   
    MsgPlus.AddTimer("timer",1000);
}


11-04-2006 02:13 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On