You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.9 KiB
C#

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 PcgDrawR
{
public partial class FormTestLic : Form
{
//[STAThread]
//static void Main(string[] args)
//{
// Application.EnableVisualStyles();
// Application.SetCompatibleTextRenderingDefault(false);
// Application.Run(new FormTestLic());
//}
public FormTestLic()
{
InitializeComponent();
try
{
Initialize();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
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 = 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
FormTestLic.CheckIn("polygel");
pictureBoxF1.BackColor = Color.LightGray;
labelFlexMsgs.Text = "polygel checked in.";
}
}
const string SIGMALIB = "FlexDll.dll";
// prototypes from DLL
//[DllImport("FlexDll.dll", CharSet = CharSet.Ansi)]
[DllImport(SIGMALIB, EntryPoint = "Initialize", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int Initialize();
//[DllImport("FlexDll.dll", CharSet = CharSet.Ansi)]
[DllImport(SIGMALIB, EntryPoint = "CheckOut", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CheckOut(String FeatureName, StringBuilder OutMsg);
//[DllImport("FlexDll.dll", CharSet = CharSet.Ansi)]
[DllImport(SIGMALIB, EntryPoint = "CheckIn", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CheckIn(String FeatureName);
//[DllImport("FlexDll.dll", CharSet = CharSet.Ansi)]
[DllImport(SIGMALIB, EntryPoint = "CleanUp", ExactSpelling = false, CallingConvention = CallingConvention.Cdecl)]
public static extern int CleanUp();
}
}