Advertisement
Guest User

Untitled

a guest
May 10th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. using ASSET_API;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Asset
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. try
  15. {
  16. Console.WriteLine("Hello");
  17.  
  18. Console.WriteLine("Before startup");
  19. aamapi93 a = new aamapi93();
  20. var v1 = a.amStartup();
  21. Console.WriteLine("After startup " + v1);
  22.  
  23. Console.WriteLine("username");
  24. var username = Console.ReadLine();
  25. Console.WriteLine("password");
  26. var password = Console.ReadLine();
  27.  
  28. var v2 = a.amOpenConnection("TEST ACCEPT", username, password);
  29. Console.WriteLine("After amOpenConnection " + v2);
  30.  
  31. var v3 = a.amIsConnected(v2);
  32. Console.WriteLine("After amIsConnected " + v3);
  33. }
  34. catch (Exception ex)
  35. {
  36. Console.WriteLine("ERREUR : " + ex.Message);
  37. }
  38.  
  39. Console.Read();
  40. }
  41. }
  42. }
  43.  
  44. using System;
  45. using System.Collections.Generic;
  46. using System.Linq;
  47. using System.Text;
  48. using System.Threading.Tasks;
  49. using System.Runtime.InteropServices;
  50.  
  51. namespace ASSET_API
  52. {
  53. public sealed class aamapi93
  54. {
  55. [DllImport(@"C:AssetManagerbinaamapi93.dll", EntryPoint = "AmStartup", CallingConvention = CallingConvention.StdCall)]
  56. private static extern IntPtr _AmStartupW();
  57.  
  58. public IntPtr amStartup()
  59. {
  60. return _AmStartupW();
  61. }
  62.  
  63.  
  64. [DllImport(@"C:AssetManagerbinaamapi93.dll", EntryPoint = "AmOpenConnectionW", CallingConvention = CallingConvention.StdCall)]
  65. private static extern IntPtr _AmOpenConnectionW([InAttribute()] [MarshalAsAttribute(UnmanagedType.LPWStr)] string pszDataSource,
  66. [InAttribute()] [MarshalAsAttribute(UnmanagedType.LPWStr)] string pszUser,
  67. [InAttribute()] [MarshalAsAttribute(UnmanagedType.LPWStr)] string pszPwd);
  68.  
  69. public IntPtr amOpenConnection(string datasource, string username, string password)
  70. {
  71. IntPtr i = IntPtr.Zero;
  72. i = _AmOpenConnectionW(datasource, username, password);
  73. //yourlog.debug(string.Format("amOpenConnection executed. Cnx {0} opened.", i.ToString()));
  74. return i;
  75. }
  76.  
  77. [DllImport(@"C:AssetManagerbinaamapi93.dll", EntryPoint = "AmIsConnectedW", CallingConvention = CallingConvention.StdCall)]
  78. private static extern IntPtr _AmIsConnectedW(IntPtr hApiCnxBase);
  79.  
  80. public IntPtr amIsConnected(IntPtr CnxBase)
  81. {
  82. IntPtr i = IntPtr.Zero;
  83. i = _AmIsConnectedW(CnxBase);
  84. //yourlog.debug(string.Format("amOpenConnection executed. Cnx {0} opened.", i.ToString()));
  85. return i;
  86. }
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement