namespace getCom //独立的Exe程序
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[MTAThread]
static int Main( string[] a)
{
if (a.Length < 2)
{
return - 1;
}
ulong btaddr = ulong.Parse(a[ 0]);
string pass = a[ 1];
//System.Windows.Forms.MessageBox.Show(btaddr.ToString());
return (zp.get_com(btaddr, "0000"));
}
static NoComWince5Test.zp_sdk zp = new NoComWince5Test.zp_sdk();
}
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[MTAThread]
static int Main( string[] a)
{
if (a.Length < 2)
{
return - 1;
}
ulong btaddr = ulong.Parse(a[ 0]);
string pass = a[ 1];
//System.Windows.Forms.MessageBox.Show(btaddr.ToString());
return (zp.get_com(btaddr, "0000"));
}
static NoComWince5Test.zp_sdk zp = new NoComWince5Test.zp_sdk();
}
}
private void btnEscPrint_Click( object sender, EventArgs e) //第二个exe程序 去执行第一个exe
{
int numYouSelected = listbox.SelectedIndex;
string btKey = "0000";
if (numYouSelected < 0)
{
MessageBox.Show( "请选择你要打印机");
return;
}
/* if (zp.bt_open(BTAddrArry[numYouSelected], btKey))
{
myLongBtAdd = BTAddrArry[numYouSelected];
string selectBtName = btsNames[numYouSelected];
save_bt_info(selectBtName, myLongBtAdd);
MessageBox.Show("打开成功蓝牙");
}*/
ProcessStartInfo processInfo = new System.Diagnostics.ProcessStartInfo();
processInfo.FileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\getCom.exe";
// MessageBox.Show(processInfo.FileName.ToString());
//return;
processInfo.Arguments =BTAddrArry[numYouSelected].ToString() + " " + "0000";
System.Diagnostics.Process process = System.Diagnostics.Process.Start(processInfo);
process.WaitForExit();
comNum = process.ExitCode;
}}
private void btnEscPrint_Click( object sender, EventArgs e) //第二个exe程序 去执行第一个exe
{
int numYouSelected = listbox.SelectedIndex;
string btKey = "0000";
if (numYouSelected < 0)
{
MessageBox.Show( "请选择你要打印机");
return;
}
/* if (zp.bt_open(BTAddrArry[numYouSelected], btKey))
{
myLongBtAdd = BTAddrArry[numYouSelected];
string selectBtName = btsNames[numYouSelected];
save_bt_info(selectBtName, myLongBtAdd);
MessageBox.Show("打开成功蓝牙");
}*/
ProcessStartInfo processInfo = new System.Diagnostics.ProcessStartInfo();
processInfo.FileName = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\getCom.exe";
// MessageBox.Show(processInfo.FileName.ToString());
//return;
processInfo.Arguments =BTAddrArry[numYouSelected].ToString() + " " + "0000";
System.Diagnostics.Process process = System.Diagnostics.Process.Start(processInfo);
process.WaitForExit();
comNum = process.ExitCode;
}}
第一个exe用于获取 com口第二个exe获得com口后,连接打印机打印(wince)
附件程序下载地址:http://download.csdn.net/detail/lixiaodaoaaa/4261804