What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » [C#] Write to MsgPlus Event Log

[C#] Write to MsgPlus Event Log
Author: Message:
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: [C#] Write to MsgPlus Event Log
Editted again (this one does work):
code:
    const int HWND_BROADCAST = 0xFFFF;
    [DllImport("user32", EntryPoint="RegisterWindowMessageA")] public static extern int RegisterWindowMessage([MarshalAs(UnmanagedType.LPStr)]string lpString);
    [DllImport("user32", EntryPoint="SendMessageA")] public static extern int SendMessage(int hwnd, int wMsg, int wParam, int lParam);
   
    private struct MPL_EVENTLOG_INFO
    {
        public int sUser;
        public int sEvent;
        public int nReserved;
    }
   
    public bool AddEventEntry(string sUser, string sEvent)
    {
        MPL_EVENTLOG_INFO info = new MPL_EVENTLOG_INFO();
        info.nReserved = 0;

        System.Runtime.InteropServices.GCHandle userPtr = new System.Runtime.InteropServices.GCHandle();
        if(sUser.Length < 1)
        {
            info.sUser = 0;
        }
        else
        {
            userPtr = System.Runtime.InteropServices.GCHandle.Alloc(sUser, System.Runtime.InteropServices.GCHandleType.Pinned);
            info.sUser = userPtr.AddrOfPinnedObject().ToInt32();
        }
       
        System.Runtime.InteropServices.GCHandle eventPtr = new System.Runtime.InteropServices.GCHandle();
        if(sEvent.Length < 1)
        {
            info.sEvent = 0;
        }
        else
        {
            eventPtr = System.Runtime.InteropServices.GCHandle.Alloc(sEvent, System.Runtime.InteropServices.GCHandleType.Pinned);
            info.sEvent = eventPtr.AddrOfPinnedObject().ToInt32();
        }

        int nMsg = RegisterWindowMessage("MessengerPlus_AddEventLog");
        System.Runtime.InteropServices.GCHandle infoPtr = System.Runtime.InteropServices.GCHandle.Alloc(info, System.Runtime.InteropServices.GCHandleType.Pinned);

        int nResult = SendMessage(HWND_BROADCAST, nMsg, infoPtr.AddrOfPinnedObject().ToInt32(), 1);

        if(info.sEvent != 0)
        {
            eventPtr.Free();
        }
        if(info.sUser != 0)
        {
            userPtr.Free();
        }
        infoPtr.Free();

        return true;
    }

This post was edited on 10-05-2005 at 09:30 AM by J-Thread.
10-03-2005 06:21 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[C#] Write to MsgPlus Event Log - by andersona91 on 10-03-2005 at 06:00 PM
RE: [C#] Write to MsgPlus Event Log - by J-Thread on 10-03-2005 at 06:21 PM
RE: [C#] Write to MsgPlus Event Log - by J-Thread on 10-04-2005 at 07:14 PM
RE: [C#] Write to MsgPlus Event Log - by Jedimark on 10-04-2005 at 09:50 PM
RE: [C#] Write to MsgPlus Event Log - by J-Thread on 10-05-2005 at 05:48 AM
RE: [C#] Write to MsgPlus Event Log - by CookieRevised on 10-05-2005 at 02:35 PM
RE: [C#] Write to MsgPlus Event Log - by Jedimark on 10-06-2005 at 07:12 PM
RE: [C#] Write to MsgPlus Event Log - by J-Thread on 10-06-2005 at 08:17 PM
RE: [C#] Write to MsgPlus Event Log - by Jedimark on 10-06-2005 at 08:48 PM
RE: [C#] Write to MsgPlus Event Log - by J-Thread on 10-07-2005 at 08:08 AM
RE: [C#] Write to MsgPlus Event Log - by Jedimark on 10-07-2005 at 04:03 PM
RE: [C#] Write to MsgPlus Event Log - by J-Thread on 10-07-2005 at 06:30 PM


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