当前位置: 首页 > 编程日记 > 正文

C#双面打印解决方法(打印word\excel\图片)

最近需要按顺序打印word、excel、图片,其中有的需要单面打印,有的双面。网上查了很多方法。主要集中在几个方式解决

1、word的print和excel的printout里设置单双面

2、printdocument里的printsettings的duplex设置单双面

试过之后效果都不好,昨天终于在MSDN上找到个直接设置打印机单双面的代码,非常管用。

using System.Runtime.InteropServices;
using System;namespace MyDuplexSettings
{
class DuplexSettings
{
#region Win32 API Declaration[DllImport("kernel32.dll", EntryPoint = "GetLastError", SetLastError = false, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern Int32 GetLastError();[DllImport("winspool.Drv", EntryPoint = "ClosePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool ClosePrinter(IntPtr hPrinter);[DllImport("winspool.Drv", EntryPoint = "DocumentPropertiesA", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern int DocumentProperties(IntPtr hwnd, IntPtr hPrinter, [MarshalAs(UnmanagedType.LPStr)]
string pDeviceNameg, IntPtr pDevModeOutput, IntPtr pDevModeInput, int fMode);[DllImport("winspool.Drv", EntryPoint = "GetPrinterA", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
public static extern bool GetPrinter(IntPtr hPrinter, Int32 dwLevel, IntPtr pPrinter, Int32 dwBuf, ref Int32 dwNeeded);[DllImport("winspool.drv", CharSet = CharSet.Auto, SetLastError = true)]
static extern int OpenPrinter(string pPrinterName, out IntPtr phPrinter, ref PRINTER_DEFAULTS pDefault);[DllImport("winspool.Drv", EntryPoint = "SetPrinterA", ExactSpelling = true, SetLastError = true)]
public static extern bool SetPrinter(IntPtr hPrinter, int Level, IntPtr pPrinter, int Command);[StructLayout(LayoutKind.Sequential)]
public struct PRINTER_DEFAULTS
{public IntPtr pDatatype;public IntPtr pDevMode;public int DesiredAccess;
}[StructLayout(LayoutKind.Sequential)]
public struct PRINTER_INFO_9
{public IntPtr pDevMode;// Pointer to SECURITY_DESCRIPTORpublic int pSecurityDescriptor;
}public const short CCDEVICENAME = 32;public const short CCFORMNAME = 32;[StructLayout(LayoutKind.Sequential)]
public struct DEVMODE
{[MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCDEVICENAME)]public string dmDeviceName;public short dmSpecVersion;public short dmDriverVersion;public short dmSize;public short dmDriverExtra;public int dmFields;public short dmOrientation;public short dmPaperSize;public short dmPaperLength;public short dmPaperWidth;public short dmScale;public short dmCopies;public short dmDefaultSource;public short dmPrintQuality;public short dmColor;public short dmDuplex;public short dmYResolution;public short dmTTOption;public short dmCollate;[MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCFORMNAME)]public string dmFormName;public short dmUnusedPadding;public short dmBitsPerPel;public int dmPelsWidth;public int dmPelsHeight;public int dmDisplayFlags;public int dmDisplayFrequency;
}public const Int64    DM_DUPLEX = 0x1000L;
public const Int64 DM_ORIENTATION = 0x1L;
public const Int64 DM_SCALE = 0x10L;
public const Int64 DMORIENT_PORTRAIT = 0x1L;
public const Int64 DMORIENT_LANDSCAPE = 0x2L;
public const Int32  DM_MODIFY = 8;
public const Int32 DM_COPY = 2;
public const Int32 DM_IN_BUFFER = 8;
public const Int32 DM_OUT_BUFFER = 2;
public const Int32 PRINTER_ACCESS_ADMINISTER = 0x4;
public const Int32 PRINTER_ACCESS_USE = 0x8;
public const Int32 STANDARD_RIGHTS_REQUIRED = 0xf0000;
public const int PRINTER_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | PRINTER_ACCESS_ADMINISTER | PRINTER_ACCESS_USE);//added this 
public const int CCHDEVICENAME = 32;//added this 
public const int CCHFORMNAME = 32;#endregion#region Public Methods/// <summary>
/// Method Name : GetPrinterDuplex 
/// Programmatically get the Duplex flag for the specified printer 
/// driver's default properties. 
/// </summary>
/// <param name="sPrinterName"> The name of the printer to be used. </param>
/// <param name="errorMessage"> this will contain error messsage if any. </param>
/// <returns> 
/// nDuplexSetting - One of the following standard settings: 
/// 0 = Error
/// 1 = None (Simplex)
/// 2 = Duplex on long edge (book) 
/// 3 = Duplex on short edge (legal) 
/// </returns>
/// <remarks>
/// </remarks>
public short GetPrinterDuplex(string sPrinterName, out string errorMessage)
{errorMessage = string.Empty;short functionReturnValue = 0;IntPtr hPrinter = default(IntPtr);PRINTER_DEFAULTS pd = default(PRINTER_DEFAULTS);DEVMODE dm = new DEVMODE();int nRet = 0;pd.DesiredAccess = PRINTER_ACCESS_USE;nRet = OpenPrinter(sPrinterName, out hPrinter, ref pd);if ((nRet == 0) | (hPrinter.ToInt32() == 0)) {if (GetLastError() == 5) {errorMessage = "Access denied -- See the article for more info.";} else {errorMessage = "Cannot open the printer specified " + "(make sure the printer name is correct).";}return functionReturnValue;}nRet = DocumentProperties(IntPtr.Zero, hPrinter, sPrinterName, IntPtr.Zero, IntPtr.Zero, 0);if ((nRet < 0)) {errorMessage = "Cannot get the size of the DEVMODE structure.";goto cleanup;}IntPtr iparg = Marshal.AllocCoTaskMem(nRet + 100);nRet = DocumentProperties(IntPtr.Zero, hPrinter, sPrinterName, iparg, IntPtr.Zero, DM_OUT_BUFFER);if ((nRet < 0)) {errorMessage = "Cannot get the DEVMODE structure.";goto cleanup;}dm = (DEVMODE)Marshal.PtrToStructure(iparg, dm.GetType());if (!Convert.ToBoolean(dm.dmFields & DM_DUPLEX)) {errorMessage = "You cannot modify the duplex flag for this printer " + "because it does not support duplex or the driver " + "does not support setting it from the Windows API.";goto cleanup;}functionReturnValue = dm.dmDuplex;cleanup:if ((hPrinter.ToInt32() != 0))ClosePrinter(hPrinter);    return functionReturnValue;
}/// <summary>
/// Method Name : SetPrinterDuplex     
/// Programmatically set the Duplex flag for the specified printer driver's default properties. 
/// </summary>
/// <param name="sPrinterName"> sPrinterName - The name of the printer to be used. </param>
/// <param name="nDuplexSetting"> 
/// nDuplexSetting - One of the following standard settings: 
/// 1 = None 
/// 2 = Duplex on long edge (book) 
/// 3 = Duplex on short edge (legal) 
/// </param>
///  <param name="errorMessage"> this will contain error messsage if any. </param>
/// <returns>
/// Returns: True on success, False on error.
/// </returns>
/// <remarks>
/// 
/// </remarks>
public bool SetPrinterDuplex(string sPrinterName, int nDuplexSetting, out string errorMessage)
{errorMessage = string.Empty;bool functionReturnValue = false;IntPtr hPrinter = default(IntPtr);PRINTER_DEFAULTS pd = default(PRINTER_DEFAULTS);PRINTER_INFO_9 pinfo = new PRINTER_INFO_9();DEVMODE dm = new DEVMODE();IntPtr ptrPrinterInfo = default(IntPtr);int nBytesNeeded = 0;int nRet = 0;Int32 nJunk = default(Int32);if ((nDuplexSetting < 1) | (nDuplexSetting > 3)) {errorMessage = "Error: dwDuplexSetting is incorrect.";return functionReturnValue;}pd.DesiredAccess = PRINTER_ACCESS_USE;nRet = OpenPrinter(sPrinterName, out hPrinter, ref pd);if ((nRet == 0) | (hPrinter.ToInt32() == 0)) {if (GetLastError() == 5) {errorMessage = "Access denied -- See the article for more info." ;} else {errorMessage = "Cannot open the printer specified " + "(make sure the printer name is correct).";}return functionReturnValue;}nRet = DocumentProperties(IntPtr.Zero, hPrinter, sPrinterName, IntPtr.Zero, IntPtr.Zero, 0);if ((nRet < 0)) {errorMessage = "Cannot get the size of the DEVMODE structure.";goto cleanup;}IntPtr iparg = Marshal.AllocCoTaskMem(nRet + 100);nRet = DocumentProperties(IntPtr.Zero, hPrinter, sPrinterName, iparg, IntPtr.Zero, DM_OUT_BUFFER);if ((nRet < 0)) {errorMessage = "Cannot get the DEVMODE structure.";goto cleanup;}dm = (DEVMODE)Marshal.PtrToStructure(iparg, dm.GetType());if (!Convert.ToBoolean(dm.dmFields & DM_DUPLEX)) {errorMessage = "You cannot modify the duplex flag for this printer " + "because it does not support duplex or the driver " + "does not support setting it from the Windows API.";goto cleanup;}dm.dmDuplex = (short) nDuplexSetting;Marshal.StructureToPtr(dm, iparg, true);nRet = DocumentProperties(IntPtr.Zero, hPrinter, sPrinterName, pinfo.pDevMode, pinfo.pDevMode, DM_IN_BUFFER | DM_OUT_BUFFER);if ((nRet < 0)) {errorMessage = "Unable to set duplex setting to this printer.";goto cleanup;}GetPrinter(hPrinter, 9, IntPtr.Zero, 0, ref nBytesNeeded);if ((nBytesNeeded == 0)) {errorMessage = "GetPrinter failed.";goto cleanup;}ptrPrinterInfo = Marshal.AllocCoTaskMem(nBytesNeeded + 100);nRet = GetPrinter(hPrinter, 9, ptrPrinterInfo, nBytesNeeded, ref nJunk)?1:0;if ((nRet == 0)) {errorMessage = "Unable to get shared printer settings.";goto cleanup;}pinfo = (PRINTER_INFO_9)Marshal.PtrToStructure(ptrPrinterInfo, pinfo.GetType());pinfo.pDevMode = iparg;pinfo.pSecurityDescriptor = 0;Marshal.StructureToPtr(pinfo, ptrPrinterInfo, true);nRet = SetPrinter(hPrinter, 9, ptrPrinterInfo, 0)?1:0;if ((nRet == 0)) {errorMessage = "Unable to set shared printer settings.";}functionReturnValue = Convert.ToBoolean(nRet);cleanup:if ((hPrinter.ToInt32() != 0))ClosePrinter(hPrinter);return functionReturnValue;
}
#endregion}
}

使用方法,以word为例:

public static void PrintWord(string FileName, PrintDocument pd){//0 check if there are any winword process exist//if is,kill itProcess[] wordProcess = Process.GetProcessesByName("WINWORD");for (int i = 0; i < wordProcess.Length; i++){wordProcess[i].Kill();}object missing = System.Reflection.Missing.Value;object objFileName = FileName;object objPrintName = pd.PrinterSettings.PrinterName;WORD.Application objApp = new WORD.Application();WORD.Document objDoc = null;try{objDoc = FrameWork.WordTool.OpenWord(objApp, FileName);objDoc.Activate();object copies = "1";object pages = "";object range = WORD.WdPrintOutRange.wdPrintAllDocument;object items = WORD.WdPrintOutItem.wdPrintDocumentContent;object pageType = WORD.WdPrintOutPages.wdPrintAllPages;object oTrue = true;object oFalse = false;objApp.Options.PrintOddPagesInAscendingOrder = true;objApp.Options.PrintEvenPagesInAscendingOrder = true;objDoc.PrintOut(ref oTrue, ref oFalse, ref range, ref missing, ref missing, ref missing,ref items, ref copies, ref pages, ref pageType, ref oFalse, ref oTrue,ref missing, ref oFalse, ref missing, ref missing, ref missing, ref missing);}catch (Exception ex){throw ex;}finally{if (objDoc != null){Marshal.ReleaseComObject(objDoc);Marshal.FinalReleaseComObject(objDoc);objDoc = null;}if (objApp != null){objApp.Quit(ref missing, ref missing, ref missing);Marshal.ReleaseComObject(objApp);Marshal.FinalReleaseComObject(objApp);objApp = null;}}}

使用方法,以excel为例,我这有两种表格,把打印页数固定了打印:

public static void PrintExcel(string excelFileName, PrintDocument pd, int iFlag){//0 check if there are any winword process exist//if is,kill itProcess[] wordProcess = Process.GetProcessesByName("EXCEL");for (int i = 0; i < wordProcess.Length; i++){wordProcess[i].Kill();}object Missing = System.Reflection.Missing.Value;object objExcel = null;object objWorkbooks = null;try{objExcel = ExcelTool.OpenExcel(excelFileName);if (iFlag == 1){objWorkbooks = ExcelTool.GetWorkSheets(objExcel);object[] parameters = null;try{parameters = new object[8];parameters[0] = 1;parameters[1] = 4;parameters[2] = 1;parameters[3] = Missing;parameters[4] = pd.PrinterSettings.PrinterName;parameters[5] = Missing;parameters[6] = true;parameters[7] = Missing;objWorkbooks.GetType().InvokeMember("PrintOut", System.Reflection.BindingFlags.InvokeMethod, null, objWorkbooks, parameters);}catch (Exception ex){throw ex;}}else{objWorkbooks = ExcelTool.GetWorkSheets(objExcel);object[] parameters = null;try{parameters = new object[8];parameters[0] = 5;parameters[1] = 5;parameters[2] = 1;parameters[3] = Missing;parameters[4] = pd.PrinterSettings.PrinterName;parameters[5] = Missing;parameters[6] = true;parameters[7] = Missing;objWorkbooks.GetType().InvokeMember("PrintOut", System.Reflection.BindingFlags.InvokeMethod, null, objWorkbooks, parameters);}catch (Exception ex){throw ex;}}}catch (Exception ex){throw ex;}finally{if (objWorkbooks != null){ExcelTool.ReleaseComObj(objWorkbooks);}if (objExcel != null){ExcelTool.ReleaseComObj(objExcel);}System.GC.Collect();}}

最后再说说图片打印A4纸的设置,这里省略其它代码,如果纠结这问题的人一下就看出来问题出哪里了。

如果要适应纸张尺寸的话:

 pd.PrintPage += (_, e) =>{var img = System.Drawing.Image.FromFile(FileName[i]);e.Graphics.DrawImage(img, 20, 20, e.PageSettings.PrintableArea.Width, e.PageSettings.PrintableArea.Height);if (i == FileName.Length - 1){e.HasMorePages = false;}else{e.HasMorePages = true;}i++;};

如果是固定大小的话:

pd.PrintPage += (_, e) =>{var img = System.Drawing.Image.FromFile(FileName[i]);int iWidth = 520;double hFactor = iWidth / (double)img.Width;int iHeight = Convert.ToInt32(img.Height * hFactor);Rectangle Rect = new Rectangle(170, 330, iWidth, iHeight);e.Graphics.DrawImage(img, Rect);if (i == FileName.Length - 1){e.HasMorePages = false;}else{e.HasMorePages = true;}i++;};

我辛苦了几天累的代码,分享给有用之人:)

自己在做独立开发,希望广结英豪,尤其是像我一样脑子短路不用react硬拼anroid、ios原生想干点什么的朋友。

App独立开发群533838427

微信公众号『懒文』-->lanwenapp<--

转载于:https://www.cnblogs.com/matoo/p/3680117.html

相关文章:

【leetcode】589. N-ary Tree Preorder Traversal

题目如下&#xff1a; 解题思路&#xff1a;凑数题1&#xff0c;话说我这个也是凑数博&#xff1f; 代码如下&#xff1a; class Solution(object):def preorder(self, root):""":type root: Node:rtype: List[int]"""if root None:return []re…

MSDN Visual系列:创建Feature扩展SharePoint列表项或文档的操作菜单项

原文&#xff1a;http://msdn2.microsoft.com/en-us/library/bb418731.aspx在SharePoint中我们可以通过创建一个包含CustomAction元素定义的Feature来为列表项或文档添加一个自定义操作菜单项(Entry Control Block Item)。我们可以添加自定义命令到默认的SharePoint用户界面中。…

评审过程中,A小组发现了5个缺陷,B小组发现了9个缺陷,他们发现的缺陷中有3个是相同的。请问:还有多少个潜在的缺陷没有发现?

分析&#xff1a;这一个“捉-放-捉”问题 背景&#xff1a; 求解&#xff1a; 可以将A看成是第一次捕捉&#xff0c;发现了5个缺陷&#xff0c;全部打上标记 B看成是第二次捕捉&#xff0c;发现了9个缺陷&#xff0c;其中有3个有标记 那么可以算出系统中一共存在的缺陷数量为…

Dell PowerVault TL4000 磁带机卡带问题

最近一段时间Dell PowerVault TL4000 磁带机故障频繁&#xff0c;昨天我在管理系统里面看到Library Status告警&#xff1a;HE: sled blocked, error during sled movement to rotation position Code: 8D 07 &#xff0c;Dell工程师根据Code: 8D 07判断是磁带卡带了&#xff0…

【git】git入门之把自己的项目上传到github

1. 首先当然是要有一个GIT账号&#xff1a;github首页 2. 然后在电脑上安装一个git&#xff1a;git首页 注册和安装这里我就不说了。我相信大家做这个都没有问题。 3. 上述两件事情做完了&#xff0c;就登陆到github页面 1&#xff09;首先我们点标注【1】的小三角&#xff0c;…

Java面试查漏补缺

一、基础 1、&和&&的区别。 【概述】 &&只能用作逻辑与&#xff08;and&#xff09;运算符&#xff08;具有短路功能&#xff09;&#xff1b;但是&可以作为逻辑与运算符&#xff08;是“无条件与”&#xff0c;即没有短路的功能&#xff09;&#xf…

selenium之frame操作

前言 很多时候定位元素时候总是提示元素定位不到的问题&#xff0c;明明元素就在那里&#xff0c;这个时候就要关注你所定位的元素是否在frame和iframe里面 frame标签包含frameset、frame、iframe三种&#xff0c;frameset和普通的标签一样&#xff0c;不会影响正常的定位&…

(C++)将整型数组所有成员初始化为0的三种简单方法

#include<cstdio> #include<cstring>int main(){//1.方法1 int a[10] {};//2.方法2 int b[10] {0};//3.方法3 注意&#xff1a;需要加 <cstring>头文件 int c[10];memset(c,0,sizeof(c));for(int i0;i<9;i){printf("a[%d]%d\n",i,a[i]);}prin…

(C++)对用户输入的整形数组进行冒泡排序

#include<cstdio>//冒泡排序的本质在于交换 //1.读入数组 //2.排序 //3.输出数组 int main(){int a[10];printf("%s","请依次输入数组的10个整型元素&#xff1a;\n");for(int i0;i<9;i){scanf("%d",&a[i]);} int temp 0;for(int …

U3D的Collider

被tx鄙视的体无完肤&#xff0c;回来默默的继续看书&#xff0c;今天看u3d&#xff0c;试了下collider,发现cube添加了rapidbody和boxcollider后落在terrain后就直接穿过去了... 找了一会原因&#xff0c;看到一个collider的参数说明&#xff1a; 分别选中立方体和树的模型&…

限制程序只打开一个实例(转载)

当我们在做一些管理平台类的程序&#xff08;比如Windows的任务管理器&#xff09;时&#xff0c;往往需要限制程序只能打开一个实例。解决这个问题的大致思路很简单&#xff0c;无非是在程序打开的时候判断一下是否有与自己相同的进程开着&#xff0c;如果有&#xff0c;则关闭…

dao.xml

<select id"selectItemkindByPolicyNo" resultMap"BaseResultMap" parameterType"java.util.List"> select * from prpcitemkind kind where kind.PolicyNo in <foreach collection"list" item"item&q…

(C++)字符数组初始化的两种方法

#include<cstdio> //字符数组的两种赋值方法 int main(){//1.方法一char str1[14] {I, ,l,o,v,e, ,m,y, ,m,o,m,.};for(int i 0;i<13;i){printf("%c",str1[i]);}printf("\n");//2.方法二&#xff0c;直接赋值字符串(注意&#xff0c;只有初始化…

SQL Server 中update的小计

update中涉及到多个表的&#xff1a; 1.update TableA set a.ColumnCb.ColumnC from TableA a inner join TableB b on a.ColumnDb.ColumnD 这样是不对的&#xff0c;报错如下&#xff1a; 消息 4104&#xff0c;无法绑定由多个部分组成的标识符 “xxxx” 虽然前面的TableA和后…

MFC中的字符串转换

在VC中有着一大把字符串类型。从传统的char*到std::string到CString&#xff0c;简直是多如牛毛。期间的转换相信也是绕晕了许多的人&#xff0c;我曾就是其中的一个。还好&#xff0c;MS还没有丧失功德心&#xff0c;msdn的一篇文章详细的解析了各种字符串的转换问题&#xff…

tf.nn.relu

tf.nn.relu(features, name None) 这个函数的作用是计算激活函数 relu&#xff0c;即 max(features, 0)。即将矩阵中每行的非最大值置0。 import tensorflow as tfa tf.constant([-1.0, 2.0]) with tf.Session() as sess:b tf.nn.relu(a)print sess.run(b) 以上程序输出的结…

(C++)字符数组的四种输入输出方式

scanf/printf%s getchar()/putchar() 前者不带参数后者带 gets()/puts() 二者都带参数&#xff0c;为一维字符数组或二维字符数组的一维 运用指针scanf/printf或getchar/putchar #include<cstdio> //字符数组的3种输入输出方式int main(){//1.scanf/printf%schar st…

css制作对话框

当你发现好多图都能用css画出来的时候&#xff0c;你就会觉得css很有魅力了。//我是这么觉得的&#xff0c;先不考虑什么兼容问题 像漫画里出现的对话框&#xff0c;往往都是一个对话框然后就加入一个箭头指向说话的那一方&#xff0c;来表示这个内容是谁述说的。 今天认真学了…

Git相关二三事(git reflog 和彩色branch)【转】

转自&#xff1a;https://www.jianshu.com/p/3622ed542c3b 背景 git太常用了&#xff0c;虽然&#xff0c;用起来不难&#xff0c;但也有很多小技巧的东西... 1. 后悔药 哪天不小心&#xff0c;写完代码&#xff0c;没commit,直接reset了或者checkout了&#xff0c;怎么办&…

MS SQL入门基础:备份和恢复系统数据库

系统数据库保存了有关SQL Server 的许多重要数据信息&#xff0c;这些数据的丢失将给系统带来极为严重的后果&#xff0c;所以我们也必须对系统数据库进行备份。这样一旦系统或数据库失败&#xff0c;则可以通过恢复来重建系统数据库。在SQL Server 中重要的系统数据库主要有ma…

(C++)输入输出字符矩阵(二维字符数组)的三种方法

想输出一个这样的字符矩阵 CSU ZJU PKUscanf和printf #include<cstdio> #include<cmath>int main(){char schools[3][3];printf("请输入&#xff1a;\n");for(int i0;i<2;i){scanf("%s",schools[i]);}printf("以下为输出&#xff1a…

C# async await 学习笔记2

C# async await 学习笔记1&#xff08;http://www.cnblogs.com/siso/p/3691059.html&#xff09; 提到了ThreadId是一样的&#xff0c;突然想到在WinForm中&#xff0c;非UI线程是无法直接更新UI线程上的控件的问题。 于是做了如下测试&#xff1a; using System; using System…

不走寻常路 设计ASP.NET应用程序的七大绝招

随着微软.NET的流行&#xff0c;ASP.NET越来越为广大开发人员所接受。作为ASP.NET的开发人员&#xff0c;我们不仅需要掌握其基本的原理&#xff0c;更要多多实践&#xff0c;从实践中获取真正的开发本领。在我们的实际开发中&#xff0c;往往基本的原理满足不了开发需求&#…

记录Linux下的钓鱼提权思路

参考Freebuf上的提权文章&#xff08;利用通配符进行Linux本地提权&#xff09;&#xff1a;http://www.freebuf.com/articles/system/176255.html 以两个例子的形式进行记录&#xff0c;作为备忘&#xff1a; 0x01 Chown的--reference特性 存在三个用户&#xff1a;root、yuns…

(C++)strlen(),strcmp(),strcpy(),strcat()用法

string.h中包含了许多用于字符数组的函数。使用前需要在程序开头加string.h©或cstring(C)头文件 strlen() 作用&#xff1a;得到字符数组第一个结束符\0前的字符的个数 #include<cstdio> #include<cstring>int main(){char str[50];gets(str);printf("…

springMvc+mybatis+spring 整合 包涵整合activiti 基于maven

2019独角兽企业重金招聘Python工程师标准>>> 最近自己独立弄一个activiti项目&#xff0c;写一下整合过程&#xff1a; 环境&#xff1a;jdk1.7 tomcat7.0 maven3.5 eclipse mysql5.5 --我的工程结构&#xff0c;怎么创建一个maven项目就不在这里写了&#xff1a; …

(原)Eclipse 字体过小问题

刚解压/安装的eclipse(或者myeclipse,sts等因为默认使用Consolas字体的原因,中文字会显得非常小 解决办法搜索网络无非两种:1.不想太麻烦去下字体的话,就将eclipse的字体改为Courier New,方法如下:A.进入eclipse配置,找到编辑字体的地方: window->perferences->General-&…

一个饼形图形报表

最近在做一个统计投票数量的图形报表,主要借鉴了一个51aspx中的一个例子,因为要在一页中显示多个图形,所以选择了在pannel中动态添加Image控件.效果图如下:/// <summary>/// 饼形图形报表/// </summary>/// <param name"target">Stream对象的实例&…

(C++)从字符串中取出整形、浮点型和字符串

目的&#xff1a;从字符串"330:20.20:yoyo"中取出整数330&#xff0c;浮点数20.20和字符串"yoyo" #include<cstdio> #include<cstring>int main(){char str[50]"330:20.20:yoyo";int n;double g;char sstr[40];sscanf(str,"%d…

[C#]网络编程系列专题二:HTTP协议详解

转自&#xff1a;http://www.cnblogs.com/zhili/archive/2012/08/18/2634475.html 我们在用Asp.net技术开发Web应用程序后&#xff0c;当用户在浏览器输入一个网址时就是再向服务器发送一个HTTP请求&#xff0c;此时就使用了应用层的HTTP协议&#xff0c;在上一个专题我们简单介…