Shoutbox

What am I doing wrong? - 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)
+----- Forum: Plug-Ins (/forumdisplay.php?fid=28)
+------ Thread: What am I doing wrong? (/showthread.php?tid=51233)

What am I doing wrong? by sena on 10-01-2005 at 11:21 AM

Hi,

I am trying to make a plugin for Messenger Plus, but before I start developing it, I want to make sure I can successfully install it first, so I can test it.

I am using VB6.

This is my "Installer".  I am using the DLL that comes in the Messenger Plus! Plugins Documentation, Visual Basic 6 Samples section (MPPluginVB.dll)

Form 1:

code:
Private Sub Form_Load()
FileSystem.FileCopy App.Path & "\MPPluginVB.dll", GetPluginDirectory & "\MPPluginVB.dll"
MsgBox InstallPlugin("MPPluginVB.dll", "MPPluginVB.Sample")
ReloadPlus
End Sub


Module:
code:
Public Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const HWND_BROADCAST = &HFFFF&

Public Function GetPluginDirectory()
Dim Temp As String
Temp = GetKeyValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Patchou\MsgPlus2", "PluginDir")
If Temp = "" Then Temp = GetKeyValue(HKEY_CURRENT_USER, "SOFTWARE\Patchou\MsgPlus2", "PluginDir")
If Temp = "" Then Temp = "**ERROR** - Plugin Directory Not Found"
GetPluginDirectory = Temp
End Function

Public Function InstallPlugin(FileName As String, VBWord As String) As Boolean
UpdateKey HKEY_CURRENT_USER, "SOFTWARE\Patchou\MsgPlus2\RegisteredPlugins", FileName, VBWord
InstallPlugin = UpdateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Patchou\MsgPlus2\RegisteredPlugins", FileName, VBWord)
End Function

Public Function ReloadPlus()
Dim nMsg As Long
nMsg = RegisterWindowMessage("MessengerPlus_PluginChange")
PostMessage HWND_BROADCAST, nMsg, 0, 0
End Function


I have used the "RegAccess.bas" file that comes with VB6 to access the registry.

It doesn't work!!! What have I done wrong?!
RE: What am I doing wrong? by Plik on 10-01-2005 at 11:26 AM

dont forget you need to register the dll with regsvr32 <path to dll> if its a vb dll


RE: What am I doing wrong? by sena on 10-01-2005 at 02:33 PM

I have added that in, but it doesn't work.

Am I doing something in the wrong order?  What order do I need to do things in?  Call Plus Window, Copy file, registry keys, register dll?


RE: What am I doing wrong? by matty on 10-01-2005 at 02:47 PM

You do them in this order
   --> Copy File
   --> Register File
   --> Registry Entry
   --> Reload Plugins

The register file and Registry Entry dont matter their order.


RE: What am I doing wrong? by sena on 10-01-2005 at 02:49 PM

I have been looking at the registry, and I can't find where some of the more "popular" or "known" plugins have registered themselves.  Where are they registered?


RE: What am I doing wrong? by J-Thread on 10-01-2005 at 03:10 PM

C++ plugins don't need to be registered, they can just be placed in the plugin dir...


RE: What am I doing wrong? by sena on 10-01-2005 at 03:12 PM

Dammit... lucky bums :P


RE: What am I doing wrong? by matty on 10-01-2005 at 03:17 PM

in a form

code:
Dim PluginDir As String
Dim PluginFileName As String

Private Sub Form_Load()
    PluginDir = GetPluginDirectory()
    PluginFileName "MPPluginVB.dll"
    If CheckDirectory(PluginDir) = True Then
   
        CopyFile AppPath & PluginFileName, PluginDir & PluginFileName, False
        InstallPlugin "MPPluginVB", "MPPluginVB.Sample"
        RegisterPlugin PluginDir & PluginFileName
        ReloadPlus
       
    Else
        MsgBox "Plus! not installed, download from http://msgplus.net"
    End If

End Sub

in a module
code:
Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Public Declare Function IsNTAdmin Lib "advpack.dll" (ByVal dwReserved As Long, ByRef lpdwReserved As Long) As Long
Public Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const HWND_BROADCAST = &HFFFF&

Public Function GetPluginDirectory() As String

    If CBool(IsNTAdmin(0&, 0&)) = True Then
        GetPluginDirectory = GetKeyValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Patchou\MsgPlus2", "PluginDir")
    Else
        GetPluginDirectory = GetKeyValue(HKEY_CURRENT_USER, "SOFTWARE\Patchou\MsgPlus2", "PluginDir")
    End If

    If Right(GetPluginDirectory, 1) <> "\" Then GetPluginDirectory = GetPluginDirectory & "\"
   
End Function

Public Function InstallPlugin(FileName As String, VBWord As String) As Boolean

    If CBool(IsNTAdmin(0&, 0&)) = True Then
        InstallPlugin = UpdateKey(HKEY_CURRENT_USER, "SOFTWARE\Patchou\MsgPlus2\RegisteredPlugins", FileName, VBWord)
    Else
        InstallPlugin = UpdateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Patchou\MsgPlus2\RegisteredPlugins", FileName, VBWord)
    End If

End Function

Public Function ReloadPlus()
    Dim nMsg As Long
    nMsg = RegisterWindowMessage("MessengerPlus_PluginChange")
    PostMessage HWND_BROADCAST, nMsg, 0, 0
End Function

Public Function FileExists(strFile As String) As Boolean
On Error GoTo e
    FileLen (strFile)
    FileExists = True
    Exit Function
e:
    FileExists = False
End Function

Public Function RegisterPlugin(strPath As String)
   
    Shell "regsvr32.exe " & Chr(34) & strPath & Chr(34)
   
End Function

Public Function CheckDirectory(strDir As String) As Boolean
On Error GoTo e
    Dim CurrentDir As String
    CurrentDir = CurDir
    ChDir strDir
    CheckDirectory = True
    ChDir CurrentDir
    Exit Function
e:
    ChDir CurrentDir
    CheckDirectory = False
End Function


RE: What am I doing wrong? by sena on 10-01-2005 at 03:21 PM

OK, i'll try that later on... g2g sleep now...


RE: What am I doing wrong? by Stigmata on 10-01-2005 at 03:23 PM

HKEY_LOCAL_MACHINE\SOFTWARE\Patchou\MsgPlus2\RegisteredPlugins

is that what you mean :S


RE: What am I doing wrong? by sena on 10-01-2005 at 03:33 PM

what do i mean what?!


RE: What am I doing wrong? by Stigmata on 10-01-2005 at 04:09 PM

quote:
Originally posted by sena
I have been looking at the registry, and I can't find where some of the more "popular" or "known" plugins have registered themselves.  Where are they registered?

RE: What am I doing wrong? by sena on 10-01-2005 at 04:54 PM

quote:
Originally posted by sena
Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Public Declare Function IsNTAdmin Lib "advpack.dll" (ByVal dwReserved As Long, ByRef lpdwReserved As Long) As Long
Public Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Const HWND_BROADCAST = &HFFFF&

Public Function GetPluginDirectory() As String

    If CBool(IsNTAdmin(0&, 0&)) = True Then
        GetPluginDirectory = GetKeyValue(HKEY_LOCAL_MACHINE, "SOFTWARE\Patchou\MsgPlus2", "PluginDir")
    Else
        GetPluginDirectory = GetKeyValue(HKEY_CURRENT_USER, "SOFTWARE\Patchou\MsgPlus2", "PluginDir")
    End If

    If Right(GetPluginDirectory, 1) <> "\" Then GetPluginDirectory = GetPluginDirectory & "\"
   
End Function

Public Function InstallPlugin(FileName As String, VBWord As String) As Boolean

    If CBool(IsNTAdmin(0&, 0&)) = True Then
        InstallPlugin = UpdateKey(HKEY_CURRENT_USER, "SOFTWARE\Patchou\MsgPlus2\RegisteredPlugins", FileName, VBWord)
    Else
        InstallPlugin = UpdateKey(HKEY_LOCAL_MACHINE, "SOFTWARE\Patchou\MsgPlus2\RegisteredPlugins", FileName, VBWord)
    End If

End Function

Public Function ReloadPlus()
    Dim nMsg As Long
    nMsg = RegisterWindowMessage("MessengerPlus_PluginChange")
    PostMessage HWND_BROADCAST, nMsg, 0, 0
End Function

Public Function FileExists(strFile As String) As Boolean
On Error GoTo e
    FileLen (strFile)
    FileExists = True
    Exit Function
e:
    FileExists = False
End Function

Public Function RegisterPlugin(strPath As String)
   
    Shell "regsvr32.exe " & Chr(34) & strPath & Chr(34)
   
End Function

Public Function CheckDirectory(strDir As String) As Boolean
On Error GoTo e
    Dim CurrentDir As String
    CurrentDir = CurDir
    ChDir strDir
    CheckDirectory = True
    ChDir CurrentDir
    Exit Function
e:
    ChDir CurrentDir
    CheckDirectory = False
End Function


I have tried this.  Although it's much neater and tidier than my version, it still doesn't work! :S:S:S  What's wrong?!
RE: What am I doing wrong? by matty on 10-03-2005 at 05:49 PM

What problems happen? Does it put the file into the Plugin directory?
Are you adding the proper registry settings to the registry? Does it give you an error for registering the file?

What exactly are you having a problem with? If you don't tell us whats wrong there wont be much we can do.


RE: What am I doing wrong? by sena on 10-03-2005 at 06:54 PM

im sorry i meant to get back to you.

the problem was, the VB word.  the word they were asking for was MSVB6 or something similar, so it's all good now :)