title: Error in lineDevSpecific (login in the phone)
body: <p>I am trying to do <code>login</code> in the phone. I am developing in <code>c#</code> and the library is in <code>C++</code>. The function <strong>"lineDevSpecific" returns the value "-2147483595"</strong>, but it must to be positive.</p>
  
  <pre><code>[DllImport("Tapi32.dll", SetLastError = true)]
      unsafe private static extern int lineDevSpecific(IntPtr hLine, IntPtr lpParams);
  
      [StructLayout(LayoutKind.Sequential)]
      public struct UserRec
      {
          //[MarshalAs(UnmanagedType.I4)]
          public int dwMode=8;
          public int dwParam1=201;
          public int dwParam2=0;
      }
  
      unsafe static void Iniciar()
      {
  
          string vline = "Ip Office Phone: 201";
          IntPtr hline = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(vline);
  
          var sizeUserRec = Marshal.SizeOf(typeof(UserRec));
          var userRec = Marshal.AllocHGlobal(sizeUserRec);
          int result=lineDevSpecific(hline, userRec);
          var x = (UserRec)Marshal.PtrToStructure(userRec, typeof(UserRec));
          Marshal.FreeHGlobal(userRec);
      }
  </code></pre>
  
  <p>Version 2:</p>
  
  <p>I have modified the initial post adding the lineInitializeEx method and lineOpen. 
  These methods returns a positive value, after this lineDevSpecific continues returning the same value.  </p>
  
  <pre><code>[DllImport("Tapi32.dll", CharSet = CharSet.Auto)]
      unsafe private static extern long lineInitializeEx(ref uint lphLineApp, uint hInstance, uint lpfnCallback, uint lpszFriendlyAppName, ref uint lpdwNumDevs, ref uint lpdwAPIVersion, ref uint lpLineInitializeExParams);
      [DllImport("Tapi32.dll", SetLastError = true)]
      internal static extern long lineOpen(ref uint hLineApp, uint dwDeviceID, uint lphLine, uint dwAPIVersion, uint dwExtVersion, uint dwCallbackInstance, uint dwPrivileges, uint dwMediaModes, ref uint lpCallParams);
      [DllImport("Tapi32.dll", CharSet = CharSet.Auto)]
      unsafe private static extern int lineDevSpecific(uint hLine, IntPtr lpParams);
          uint lineApp = 0;
          uint numdevs = 0;
          uint apiversion = 0;
          uint exparams = 0;
          uint lpcallparams = 0;
          string sParams = "";
          long lSize = 0;
          long inicio = lineInitializeEx(ref lineApp, 0, 0, 0, ref numdevs, ref apiversion, ref exparams);
          if (inicio &gt; 0)
          {
              long open = lineOpen(ref lineApp, 0, 0, 0, 0, 0, 0, 0, ref lpcallparams);
              //string vline = "Ip Office Phone: 201";
              //IntPtr hline = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(vline);
  
              var sizeUserRec = Marshal.SizeOf(typeof(UserRec));
              var userRec = Marshal.AllocHGlobal(sizeUserRec);
              int result = lineDevSpecific(lineApp, userRec);
              var x = (UserRec)Marshal.PtrToStructure(userRec, typeof(UserRec));
              Marshal.FreeHGlobal(userRec);
          }
  </code></pre>
  
  <p>Solution: I have called to Julmar Atapi.</p>
  
  <pre><code>string extension = "201";
              char[] c = new char[extension.Length + 2];
              c[0] = (char)0x08; //login character
  
              int i = 1;
              foreach (char s in extension)
              {
                  c[i] = s;
                  i++;
              }
              c[i] = (char)0x00; //null terminator
              CurrentAddress.DeviceSpecific(Encoding.ASCII.GetBytes(c));
  </code></pre>