Load and unload modules with the context menu Thread last updated on 2004-08-28 17:23:41

Posted by member 5575 on 2004-08-28 01:24:12

Ever want to try loading or unloading modules from your file manager - assuming you have some reason to do that, of course? Just place shortcuts to the necessary scripts (or batch files, if you're a rabidcow) in your "Send To" folder, and you can. You can place the scripts wherever you'd like, as long as the shortcuts point to them, and name the shortcuts however you'd like - I use DLL_reload and DLL_unload. The following script does module reloading - just make a second copy and change "!Reloadmodule" to "!Unloadmodule" and it'll do the unloading. (Duh.) The script could be much shorter if you skip error and sanity checking, of course.
'-----
' Set the following variable to the name of the executable you wish to
' use to execute bang commands, e.g., litestep.exe, bang.exe. The
' executeable must be:
' 1) Fully qualified, e.g., C:\liteStep\tools\bang.exe, or
' 2) In your path (I think that'll do it).
'-----

LoadCommand = ""
BangExe = "C:\Shells\LiteStep\litestep.exe"
Set FSO = CreateObject("Scripting.FileSystemObject")
Set wShell = CreateObject("WScript.Shell")

'--- See if a DLL file has been selected by dragging it onto the script, or
'--- onto a shortcut to the script.

If (WScript.Arguments.Count = 0) Then
msgstr = "You didn't feed me a DLL!"
dummy = wShell.Popup(msgstr,3,"Error!",64)
WScript.Quit
ElseIf (WScript.Arguments.Count = 1) Then
DLLPath = WScript.Arguments.Item(0)
If (FSO.FileExists(DLLPath)) Then
If (LCase(Right(DLLPath,3)) "dll") Then
msgstr = "That was *NOT* a DLL!"
dummy = wShell.Popup(msgstr,3,"Error!",64)
WScript.Quit
End If
'--- Construct bang command sequence
LoadCommand = "!ReloadModule "&DLLPath
End If
End If

Set FSO = Nothing

'--- Execute the bang? Uncomment lines to prompt first.

If (Len(LoadCommand) > 0) Then
' msgstr = "LoadModule command is:"&vblf&vblf&_
' LoadCommand&vblf&vblf&"Continue?"
' If (MsgBox(msgstr,1) = 1) Then
Retval = wShell.Run(BangExe & " " & LoadCommand,0,true)
' End If
Else
msgstr = "Original text was:"&vblf&sClipText&vblf&vblf&_
"Load Command is:"&vblf&LoadCommand&vblf&vblf&_
"Bang executable is:"&vblf&BangExe
dummy = wShell.Popup(msgstr,5,"Error extracting parameters:",64)
End If

Set wShell = Nothing

'--- That'll do

WScript.Quit

Posted by member 5575 on 2004-08-28 01:30:29 link

And once again, there should be a "less than" immediately followed by a "greater than" in this line, right before the "dll":

If (LCase(Right(DLLPath,3)) "dll") Then

Those keep getting eaten by the html tag sanitizer monster, I suppose.

Posted by member 99 on 2004-08-28 01:46:40 link

hehehe, actually I'd use a registry entry. ;)
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\dllfile\shell\Load in LiteStep]

[HKEY_CLASSES_ROOT\dllfile\shell\Load in LiteStep\command]
@="c:\\LiteStep\\litestep.exe !reloadmodule "%1""

The quotes around %1 both need backslashes in front of them, it seems I'm not allowed to post it with the correct syntax.

Posted by member 5575 on 2004-08-28 01:51:58 link

Sorry - that's just too easy. Besides, I can't send obnoxious error messages when you try to load something that's not a DLL with that method. =) (It's great for the "command prompt here" item though.)

As long as we're at it though, can you go ahead and show me the easiest way to do all the other things I haven't even *thought* of yet? It'd save me a lot of time... =P

Posted by member 5575 on 2004-08-28 01:58:19 link

I suppose you *could* rewrite the core to send the obnoxious error messages, though, couldn't you? I don't even know what it does right now, to tell the truth (scurries off to do !reloadmodule somethingstupid.txt). Pretty lame, actually:
---------------------------
C:\Shells\LiteStep\logs\litestep.log
---------------------------
Error: Could not locate module.
Please check your configuration.
---------------------------
OK
---------------------------

Surely we can do better than that?

As long as you're here, do you know why the LSLogMaxSize setting seems to be ignored? Is it because:
1) There really isn' any such setting
2) I'm just doing it wrong
3) It's not really implemented yet
4) None of the above

I just trimmed mine down from 7+ MBytes...

Posted by member 99 on 2004-08-28 05:15:35 link

If you add the key under "dllfile", you can't use it to load anything but .dll files... Of course you still get errors if it's not an LS module, but I don't think there's a simple way to check for exports from there. :P I wouldn't be surprised if VBScript could do that, though.

Posted by member 99 on 2004-08-28 05:29:09 link

and LSLogMaxSize doesn't exist, at least not in 0.24.7 RC3. Might've been an indiestep thing, or just wishful thinking.

Posted by member 5575 on 2004-08-28 17:23:41 link

I'll just have to keep my eye on the logfile, then - or write a script to trim it. =P

I'd rather keep special functions like the load/unload module hooks in the "send to" menu, though, so as not to clutter up the regular right click menu. OTOH, I'm not likely to richt-click on a DLL for any reason *except* to do the load/unload thing = so I guess you win. =)