Esempio n. 1
0
    //[System.Diagnostics.Conditional( "DEBUG" )]  // When needed, uncomment this line to remove debug logging from Release builds
    static public void Log(string sText)
    {
        int iWnd = FindWindow(null, "DebugHost V2");

        if (iWnd != 0)
        {
            sText += "\n";
            tagCOPYDATASTRUCT cds = new tagCOPYDATASTRUCT();
            cds.pData  = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(sText);
            cds.cbData = (IntPtr)(sText.Length + 1);
            cds.dwData = IntPtr.Zero;

            System.IntPtr iPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(typeof(tagCOPYDATASTRUCT)));

            System.Runtime.InteropServices.Marshal.StructureToPtr(cds, iPtr, true);

            SendMessage(iWnd, 0x04a, 0, (int)iPtr);

            System.Runtime.InteropServices.Marshal.FreeHGlobal(iPtr);
            System.Runtime.InteropServices.Marshal.FreeHGlobal(cds.pData);
        }
        else
        {
            System.Diagnostics.Trace.WriteLine(sText);
        }
    }
Esempio n. 2
0
        static public void Log(string sText)
        {
            int iWnd = FindWindow(null, "DebugHost V2");

            if (iWnd != 0)
            {
                sText += "\n";
                tagCOPYDATASTRUCT cds = new tagCOPYDATASTRUCT();
                cds.pData  = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(sText);
                cds.cbData = sText.Length + 1;
                cds.dwData = 0;

                System.IntPtr iPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(20);

                System.Runtime.InteropServices.Marshal.StructureToPtr(cds, iPtr, true);

                SendMessage(iWnd, 0x04a, 0, iPtr.ToInt32());

                System.Runtime.InteropServices.Marshal.FreeHGlobal(iPtr);
                System.Runtime.InteropServices.Marshal.FreeHGlobal(cds.pData);
            }
        }