110,533
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Runtime.InteropServices;
public class TSCLIB_DLL
{
[DllImport("E:\\myWork\\TSCLIB.DLL-ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\bin\\TSCLIB.dll", EntryPoint = "about")]
//HttpContext.Current.Server.MapPath(".\\bin\\TSCLIB.dll
public static extern int about();
[DllImport("E:\\myWork\\TSCLIB.DLL-ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\bin\\TSCLIB.dll", EntryPoint = "openport")]
public static extern int openport(string printername);
[DllImport("E:\\myWork\\TSCLIB.DLL-ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\bin\\TSCLIB.dll", EntryPoint = "barcode")]
public static extern int barcode(string x, string y, string type,
string height, string readable, string rotation,
string narrow, string wide, string code);
[DllImport("E:\\myWork\\TSCLIB.DLL-ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\bin\\TSCLIB.dll", EntryPoint = "clearbuffer")]
public static extern int clearbuffer();
[DllImport("E:\\myWork\\TSCLIB.DLL-ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\bin\\TSCLIB.dll", EntryPoint = "closeport")]
public static extern int closeport();
[DllImport("E:\\myWork\\TSCLIB.DLL-ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\bin\\TSCLIB.dll", EntryPoint = "downloadpcx")]
public static extern int downloadpcx(string filename, string image_name);
[DllImport("E:\\myWork\\TSCLIB.DLL-ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\bin\\TSCLIB.dll", EntryPoint = "formfeed")]
public static extern int formfeed();
[DllImport("E:\\myWork\\TSCLIB.DLL-ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\bin\\TSCLIB.dll", EntryPoint = "nobackfeed")]
public static extern int nobackfeed();
[DllImport("E:\\myWork\\TSCLIB.DLL-ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\bin\\TSCLIB.dll", EntryPoint = "printerfont")]
public static extern int printerfont(string x, string y, string fonttype,
string rotation, string xmul, string ymul,
string text);
[DllImport("E:\\myWork\\TSCLIB.DLL-ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\bin\\TSCLIB.dll", EntryPoint = "printlabel")]
public static extern int printlabel(string set, string copy);
[DllImport("E:\\myWork\\TSCLIB.DLL-ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\bin\\TSCLIB.dll", EntryPoint = "sendcommand")]
public static extern int sendcommand(string printercommand);
[DllImport("E:\\myWork\\TSCLIB.DLL-ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\bin\\TSCLIB.dll", EntryPoint = "setup")]
public static extern int setup(string width, string height,
string speed, string density,
string sensor, string vertical,
string offset);
[DllImport("E:\\myWork\\TSCLIB.DLL-ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\bin\\TSCLIB.dll", EntryPoint = "windowsfont")]
public static extern int windowsfont(int x, int y, int fontheight,
int rotation, int fontstyle, int fontunderline,
string szFaceName, string content);
}
namespace ASP.NET_in_VCsharp_2008
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", "alert('Hello TSCLIB.DLL')", true);
//TSCLIB_DLL.about(); //Show the DLL version
Response.Write("1");
TSCLIB_DLL.openport("TSC TTP-244 Plus"); //Open specified printer driver
Response.Write("1");
TSCLIB_DLL.setup("100", "63.5", "4", "8", "0", "0", "0"); //Setup the media size and sensor type info
Response.Write("2");
TSCLIB_DLL.clearbuffer(); //Clear image buffer
Response.Write("3");
TSCLIB_DLL.barcode("100", "50", "128", "50", "1", "0", "2", "2", "11110001"); //Drawing barcode
//TSCLIB_DLL.printerfont("300", "250", "3", "0", "1", "1", "王海军"); //Drawing printer font
//TSCLIB_DLL.windowsfont(100, 200, 24, 0, 0, 0, "ARIAL", "wanghaijun"); //Draw windows font
//TSCLIB_DLL.downloadpcx("C:\\ASP.NET_in_VCsharp_2008\\ASP.NET_in_VCsharp_2008\\UL.PCX", "UL.PCX"); //Download PCX file into printer
//TSCLIB_DLL.downloadpcx("UL.PCX", "UL.PCX"); //Download PCX file into printer
//TSCLIB_DLL.sendcommand("PUTPCX 100,400,\"UL.PCX\""); //Drawing PCX graphic
Response.Write("4");
TSCLIB_DLL.printlabel("1", "1"); //(默认,打印张数) //Print labels
Response.Write("5");
TSCLIB_DLL.closeport();
Response.Write("6");
}
}
}