Shoutbox

[?] MediaMonkey scripting ActiveXObject... - 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: [?] MediaMonkey scripting ActiveXObject... (/showthread.php?tid=97884)

[?] MediaMonkey scripting ActiveXObject... by whiz on 06-27-2011 at 06:50 PM

I've recently switched from iTunes to MediaMonkey, after iTunes kept crashing and refusing to close and stuff.  Seems MediaMonkey also has a scripting system, so I thought I'd experiment with it a bit.

Unfortunately, I can't get any further than this:

Javascript code:
var SDB = new ActiveXObject("SongsDB.SDBApplication");

...which causes Messenger to hang for about 30 seconds, before showing an error.
code:
Error: Automation server can't create object (code: -2146827859)

I have MediaMonkey installed as a portable app (at C:\Portable Apps\MediaMonkey with the config files in the same directory).  Is it possible that is the problem?
RE: [?] MediaMonkey scripting ActiveXObject... by CookieRevised on 06-28-2011 at 08:01 PM

quote:
Originally posted by whiz
I have MediaMonkey installed as a portable app (at C:\Portable Apps\MediaMonkey with the config files in the same directory).  Is it possible that is the problem?
quite...

In order for an ActiveX object to work you need to register the DLL (or OCX, or EXE) files (with regsvr32.exe). And those registry settings need to be in the computer's own real registry (not in a file only used by the portable app as the computer's registry replacement to make it 'portable') so that any application can access it if needed.


RE: [?] MediaMonkey scripting ActiveXObject... by whiz on 06-29-2011 at 06:57 PM

quote:
Originally posted by CookieRevised
In order for an ActiveX object to work you need to register the DLL (or OCX, or EXE) files (with regsvr32.exe). And those registry settings need to be in the computer's own real registry (not in a file only used by the portable app as the computer's registry replacement to make it 'portable') so that any application can access it if needed.
Thing is, though...  to make MediaMonkey portable, you just move the config file from the user's AppData folder to the application folder - it always writes to a file, regardless of being portable or not.  And I ran it once first before making it portable, so surely the DLL should already be registered (I am running it from the PC, not off a memory stick or anything)?

Perhaps also something to do with using an x64 version of Windows?
RE: [?] MediaMonkey scripting ActiveXObject... by matty on 06-29-2011 at 07:02 PM

quote:
Originally posted by whiz
Perhaps also something to do with using an x64 version of Windows?
Try using %windir%\SysWOW64\regsvr32.exe to register the DLL
RE: [?] MediaMonkey scripting ActiveXObject... by whiz on 06-29-2011 at 07:09 PM

quote:
Originally posted by matty
Try using %windir%\SysWOW64\regsvr32.exe to register the DLL
Yeah, just did a few searches and found something telling me to do that...  Seems to be working now, thanks.
RE: [?] MediaMonkey scripting ActiveXObject... by matty on 06-29-2011 at 07:44 PM

quote:
Originally posted by whiz
quote:
Originally posted by matty
Try using %windir%\SysWOW64\regsvr32.exe to register the DLL
Yeah, just did a few searches and found something telling me to do that...  Seems to be working now, thanks.
This was also the culprit for SendTo not properly working on x64. Unfortunately a new version hasn't been released yet that resolves the issue.
RE: [?] MediaMonkey scripting ActiveXObject... by whiz on 07-03-2011 at 01:02 PM

Turns out those instructions only fixed it temporarily...  the problem appears to be back after about a week or so of it working.  I'll have to experiment with it and see what I can find.


RE: [?] MediaMonkey scripting ActiveXObject... by whiz on 07-26-2011 at 12:21 PM

I have managed to make a workaround, although not a very good one.  By running the command line stuff as a batch file on system startup, it makes sure the next startup will have the libraries available...  for some reason, they don't seem to stay after a restart.


RE: [?] MediaMonkey scripting ActiveXObject... by matty on 07-26-2011 at 12:34 PM

What if you registered the DLL through your code? Calling DLLRegisterServer (I think it is) from the DLL.


Javascript code:
function RegisterDLL(DLLPATH) {
    var iLib = Interop.Call('kernel32', 'LoadLibraryW', DLLPATH);
    if (iLib) {
        var iProcAddr = Interop.Call('kernel32', 'GetProcAddress', iLib, 'DllRegisterServer');
        if (iProcAddr) {
            if (Interop.Call('user32', 'CallWindowProcW', iProcAddr, 0, 0, 0, 0) === 0 /* ERROR_SUCCESS */) {
                // DLL has been registered
            }
            else {
                // DLL failed to register...
                var buffer = Interop.Allocate(1024);
                Interop.Call('kernel32', 'FormatMessageW', 0x1000, 0, Interop.GetLastError(), 0, buffer, 1024, 0);
                Debug.Trace(buffer.ReadString(0));
                buffer.Size = 0;
            }
        }
        else
            Debug.Trace('Could not find ProcAddress for DllRegisterServer');
    }
    else
        Debug.Trace('Could not load the DLL');
 
    Interop.Call('kernel32', 'FreeLibrary', iLib);
}


RE: [?] MediaMonkey scripting ActiveXObject... by whiz on 07-26-2011 at 01:41 PM

I'll give it a go, but I don't think it'll work (in the sense that by doing it, the ActiveXObject will work), since I seem to need to restart before I can use the ActiveX...

Edit: always prints "Could not find ProcAddress for DLLRegisterServer".  Tried with DLL names and full paths.


RE: [?] MediaMonkey scripting ActiveXObject... by matty on 07-26-2011 at 02:07 PM

quote:
Originally posted by whiz
Edit: always prints "Could not find ProcAddress for DLLRegisterServer".  Tried with DLL names and full paths.
I don't have anything to test on at the moment however I am not sure if the function name is case sensitive. If it is then it should be DllRegisterServer not DLLRegisterServer.
RE: [?] MediaMonkey scripting ActiveXObject... by whiz on 07-26-2011 at 04:39 PM

Doesn't appear to be case-sensitive, changing it doesn't seem to have any effect...

Looking at MSDN, it says lpProcName can take an ordinal value.  Don't know the exact effects of this, but it shows that the DLL can be accessed for some actions.

For example, using jscript.dll, the following debug outputs are received:
0: Could not find ProcAddress for DLLRegisterServer
1: The operation completed successfully.
2: <crashes Messenger>
3: The operation completed successfully.
4: Invalid window handle.
5+: Could not find ProcAddress for DLLRegisterServer


RE: [?] MediaMonkey scripting ActiveXObject... by Mnjul on 07-26-2011 at 04:52 PM

lcProcName is an ANSI string (LPCSTR instead of LPCTSTR) so you need to somehow convert your unicode 'DllRegisterServer' string to ANSI first.


RE: [?] MediaMonkey scripting ActiveXObject... by matty on 07-26-2011 at 05:08 PM

quote:
Originally posted by Mnjul
lcProcName is an ANSI string (LPCSTR instead of LPCTSTR) so you need to somehow convert your unicode 'DllRegisterServer' string to ANSI first.
Couldn't you write the string to a DataBloc and then use ReadString(0, false) to read it as ANSI?