using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace FlexenabledLic { public partial class Form1 : Form { [STAThread] static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } public Form1() { InitializeComponent(); Form1.Initialize(); } private void checkBoxF1_CheckedChanged(object sender, EventArgs e) { if (checkBoxF1.Checked) { // try to check out F1 this.Cursor = Cursors.WaitCursor; StringBuilder str = new StringBuilder(200); int stat = Form1.CheckOut("GDFOcx", str); if (stat == 0) { pictureBoxF1.BackColor = Color.Lime; labelFlexMsgs.Text = str.ToString(); } else { pictureBoxF1.BackColor = Color.Red; checkBoxF1.Checked = false; labelFlexMsgs.Text = "GDFOcx not checked out."; } this.Cursor = Cursors.Default; } else { // check in F1 Form1.CheckIn("polygel"); pictureBoxF1.BackColor = Color.LightGray; labelFlexMsgs.Text = "polygel checked in."; } } /// prototypes from DLL [DllImport("FlexDll.dll", CharSet = CharSet.Ansi)] public static extern int Initialize(); [DllImport("FlexDll.dll", CharSet = CharSet.Ansi)] //[DllImport("FlexDll.dll", EntryPoint = "CheckOut", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)] public static extern int CheckOut(String FeatureName, StringBuilder OutMsg); [DllImport("FlexDll.dll", CharSet = CharSet.Ansi)] public static extern int CheckIn(String FeatureName); [DllImport("FlexDll.dll", CharSet = CharSet.Ansi)] public static extern int CleanUp(); } }