Ejemplo n.º 1
0
        public static RasError Connect(out RasEntry entry)
        {
            MakeReg(); // int adında bir bağlantı yaratır.

            entry = ExistingEntry("int");

            if (entry == null)
            {
                return RasError.DeviceNameNotFound;
            }

            // entry.RasStatus += new RasNotificationHandler(entry_RasStatus);

            return entry.Dial(false);
        }
Ejemplo n.º 2
0
 public MessageHook(RasEntry entry)
 {
     this.entry = entry;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new RasEntry (phone-book entry).
        /// </summary>
        /// <param name="newEntry">RasEntry that contains all phone-book entry information.</param>
        /// <param name="dialParams">RasDialParams that contains dial parameters.</param>
        public static RasEntry CreateEntry(RasEntry newEntry, RasDialParams dialParams)
        {
            Native.Error ret = Native.Error.Success;
            int cbEntry = 0, cbDevCfg = 0;

            if (newEntry.DeviceType == "" || newEntry.DeviceName == "")
            {
                throw new Exception("DeviceName and DeviceType must be populated in the RasEntry.");
            }
            //validate entry first
            ret = Native.RasValidateEntryName(null, newEntry.Name);
            if (ret != Native.Error.AlreadyExists)
            {
                if (ret != 0)
                {
                    throw new Exception("Invalid EntryName format.");

                }
            }

            //get the size for a RASENTRY
            ret = Native.RasGetEntryProperties(null, string.Empty, null, ref cbEntry, null, ref cbDevCfg);
            byte[] buffer = new byte[cbEntry];

            // get a default set of properties
            ret = Native.RasGetEntryProperties(null, string.Empty, buffer, ref cbEntry, null, ref cbDevCfg);

            RasEntry entry = new RasEntry(buffer);

            entry.CountryCode = newEntry.CountryCode;
            entry.Name = newEntry.Name;
            entry.Options = newEntry.Options;
            entry.DeviceType = newEntry.DeviceType;
            entry.DeviceName = newEntry.DeviceName;
            entry.AreaCode = newEntry.AreaCode;
            entry.PhoneNumber = newEntry.PhoneNumber;
            entry.IPAddress = newEntry.IPAddress;
            entry.IPAddressDns = newEntry.IPAddressDns;
            entry.IPAddressDnsAlt = newEntry.IPAddressDnsAlt;
            entry.IPAddressWins = newEntry.IPAddressWins;
            entry.IPAddressWinsAlt = newEntry.IPAddressWinsAlt;

            ret = Native.RasSetEntryProperties(null, entry.Name, entry.Data, cbEntry, null, 0);
            if (ret == Native.Error.Success)
            {
                if (dialParams != null)
                {
                    entry.SetDialParams(dialParams);
                }
                return newEntry;
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Deletes a RasEntry (phone-book entry).
 /// </summary>
 /// <param name="entry">RasEntry structure.</param>
 public static bool DeleteEntry(RasEntry entry)
 {
     Native.RasDeleteEntry(null, entry.Name);
     return true;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new RasEntry (phone-book entry).
        /// </summary>
        /// <param name="Name">The name of the RasEntry</param>
        /// <param name="devInfo">valid DeviceInfo structure</param>
        public static RasEntry CreateEntry(string Name, DeviceInfo devInfo)
        {
            RasEntry newEntry = new RasEntry();
            newEntry.Name = Name;
            newEntry.DeviceName = devInfo.DeviceName;
            newEntry.DeviceType = devInfo.DeviceType;

            return CreateEntry(newEntry, null);
        }