Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string ip = "192.168.1.109";
- protected void Button_click(object sender, EventArgs e)
- {
- try
- {
- bool status = sbxpc.SBXPCDLL.ConnectTcpip(1, ip, 5005, 0);
- if (status)
- {
- bool ss = sbxpc.SBXPCDLL.GetSerialNumber(1, out ip);
- Button1.Text = "connected";
- Response.Write("success" + ip);
- }
- }
- catch (Exception ee)
- {
- Response.Write(ee);
- }
- }
- [DllImport("SBXPCDLL.dll", CallingConvention = CallingConvention.Winapi)]
- static extern byte _ConnectTcpip(Int32 dwMachineNumber, ref IntPtr lpszIPAddress, Int32 dwPortNumber, Int32 dwPassWord);
- public static bool ConnectTcpip(Int32 dwMachineNumber, string lpszIPAddress, Int32 dwPortNumber, Int32 dwPassWord)
- {
- if (lpszIPAddress == null)
- return false;
- IntPtr string_in = Marshal.StringToBSTR(lpszIPAddress);
- try
- {
- byte ret = _ConnectTcpip(dwMachineNumber, ref string_in, dwPortNumber, dwPassWord);
- return ret > 0;
- }
- catch (Exception)
- {
- return false;
- }
- finally
- {
- Marshal.FreeBSTR(string_in);
- }
- }
Add Comment
Please, Sign In to add comment