Shoutbox

Call2 function - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: Call2 function (/showthread.php?tid=67995)

Call2 function by smeuuh on 11-03-2006 at 03:38 PM

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


RE: Call2 function by Delphi Thunderbolt on 11-04-2006 at 05:13 AM

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.


RE: Call2 function by phalanxii on 11-04-2006 at 08:35 AM

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.


RE: Call2 function by smeuuh on 11-04-2006 at 02:13 PM

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);
}