Lookup MX record in C#

Thank you Peter A. Bromberg for great article "Build a C# DNS MX (Mail Exchange) Record Query Class
Original
MSDN


 
using System;
using System.Collections;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace DNS_MX
{
    public class DnsMx
    {
        public DnsMx()
        {
        }

        [DllImport("dnsapi"EntryPoint "DnsQuery_W"CharSet CharSet.UnicodeSetLastError trueExactSpelling =true)]
        private static extern int DnsQuery([MarshalAs(UnmanagedType.VBByRefStr)]ref string pszNameQueryTypes wType,QueryOptions optionsint aipServersref IntPtr ppQueryResultsint pReserved);

        [DllImport("dnsapi"CharSet CharSet.AutoSetLastError true)]
        private static extern void DnsRecordListFree(IntPtr pRecordListint FreeType);

        public static string[GetMXRecords(string domain)
        {

            IntPtr ptr1 IntPtr.Zero;
            IntPtr ptr2 IntPtr.Zero;
            MXRecord recMx;
            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
            {
                throw new NotSupportedException();
            }
            ArrayList list1 new ArrayList();
            try
            {

                int num1 DnsMx.DnsQuery(ref domainQueryTypes.DNS_TYPE_MXQueryOptions.DNS_QUERY_BYPASS_CACHE0refptr10);
                if (num1 != 0)
                {
                    if (num1 == 9003)
                    {
                        list1.Add("DNS record does not exist");
                    }
                    else
                    {
                        throw new Win32Exception(num1);
                    }
                }
                for (ptr2 ptr1!ptr2.Equals(IntPtr.Zero)ptr2 recMx.pNext)
                {
                    recMx (MXRecord)Marshal.PtrToStructure(ptr2typeof(MXRecord));
                    if (recMx.wType == 15)
                    {
                        string text1 Marshal.PtrToStringAuto(recMx.pNameExchange);
                        list1.Add(text1);
                    }
                }
            }
            finally
            {
                DnsMx.DnsRecordListFree(ptr10);
            }
            return (string[])list1.ToArray(typeof(string));
        }

        private enum QueryOptions
        {
            DNS_QUERY_ACCEPT_TRUNCATED_RESPONSE 1,
            DNS_QUERY_BYPASS_CACHE 8,
            DNS_QUERY_DONT_RESET_TTL_VALUES 0x100000,
            DNS_QUERY_NO_HOSTS_FILE 0x40,
            DNS_QUERY_NO_LOCAL_NAME 0x20,
            DNS_QUERY_NO_NETBT 0x80,
            DNS_QUERY_NO_RECURSION 4,
            DNS_QUERY_NO_WIRE_QUERY 0x10,
            DNS_QUERY_RESERVED -16777216,
            DNS_QUERY_RETURN_MESSAGE 0x200,
            DNS_QUERY_STANDARD 0,
            DNS_QUERY_TREAT_AS_FQDN 0x1000,
            DNS_QUERY_USE_TCP_ONLY 2,
            DNS_QUERY_WIRE_ONLY 0x100
        }

        private enum QueryTypes
        {
            DNS_TYPE_MX 15
        }

        [StructLayout(LayoutKind.Sequential)]
        private struct MXRecord
        {
            public IntPtr pNext;
            public string pName;
            public ushort wType;
            public ushort wDataLength;
            public int flags;
            public int dwTtl;
            public int dwReserved;
            public IntPtr pNameExchange;
            public ushort wPreference;
            public ushort Pad;
        }
    }
}

what is notepad 5.1

What is notepad++ ?
Definition of notepad is


Notepad++ is a free (as in "free speech" and also as in "free beer") source code editor and Notepad replacement that supports several languages. Running in the MS Windows environment, its use is governed by GPL License.
Based on the powerful editing component ScintillaNotepad++ is written in C++ and uses pure Win32 API and STL which ensures a higher execution speed and smaller program size. By optimizing as many routines as possible without losing user friendliness, Notepad++ is trying to reduce the world carbon dioxide emissions. When using less CPU power, the PC can throttle down and reduce power consumption, resulting in a greener environment.


Source: http://notepad-plus-plus.org/

Windows 7 autofill login ON OFF

HOWTO disable logon screen on Windows 7 or enable it again? Just type netplwiz in Start menu.
By default user must enter password on logon screen. If you want to remove it you should clean check box and click OK button and vice verse.


Enjoy it!

OTRS: hide -Move- dropdown with ACL

If you want to disable ticket move action for tickets in some states you can use ACL rules. Below you can see an example how to block movement of ticket if ticket is closed.

[Kernel/Config.pm]
        
# Ticket ACL - Disable move for closed
$Self->{TicketAcl}->{'ACL-dont-move'} = {
 # match properties
 Properties => {
  # all closed tickets
  Ticket => {
   State => ['closed', 'closed successful', 'closed unsuccessful', ], 
  },
  
  #disable on AgentTicketZoom page only
  Frontend => {
 Action => [
  'AgentTicketZoom',
 ],
  },
 },

# return possible options (white list)
 Possible => {
  # shouldn't be moved (0)
  Action => {
   AgentTicketMove =>  0,
  },
 }, 

};

Internet Information Services (IIS) 8.0 Express Release Candidate


IIS 8.0 Express is a simple and self-contained version of IIS 8.0 that is optimized for developers

Overview



IIS 8.0 Express enhances your ability to develop and test web applications on Windows by combining the power of IIS 8.0 with the convenience of a lightweight web server like the ASP.NET Development Server (also known as Cassini). IIS Express 8.0 is included with Microsoft WebMatrix, an integrated suite of tools designed to make developing web applications on Windows simple and seamless. IIS 8.0 Express can also be used with Microsoft Visual Studio as a powerful alternative to Cassini. The benefits of using IIS 8.0 Express include:
  • The same web server that runs on your production server is now available on your development computer.
  • Most tasks can be done without the need for administrative privileges.
  • IIS 8.0 Express runs on Windows Vista and all later versions of Windows.
  • Many users can work independently on the same computer.
This package installs only IIS 8.0 Express. For an integrated development experience, also install Microsoft WebMatrix or Microsoft Visual Studio.

more

Visual Studio 2012 RC is now available to download.

HOWTO: Repair Logitech M325 Mouse

FixIt says that you will find single screw under CE label. It isn't always true.