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

打印自定义纸张大小

长江支流说的办法保留太多了,结果不行,很多类都是他在程序集里自定义的,源码又没公开

不过还是要感谢他的提示

今天和小陈搞了一天,他在国外的论坛上看到了一篇文章得到了启示,最后我们在凌晨3点终于把自定义纸张的代码给写出来了,看来必须用API,微软的.NET对打印的支持太菜了

现公开我们工作室实现此功能的部分代码

using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Security;
using System.ComponentModel;
using System.Drawing.Printing;

namespace MCCustomPrintForm
{
 /// <summary>
 /// 成都微创工作室(电子科技大学微创工作室)
 /// Tell 028-82853098
 /// Email zyspipi@163.com  , you680@gmail.com
 /// 打印机纸张的真正自定义部分代码
 /// 2006-1-2
 /// </summary>
 public class MCCustomPrintForm
 {
  // Make a static class
  private MCCustomPrintForm()
  {
  }
 
  [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
   internal struct structPrinterDefaults
  {
   [MarshalAs(UnmanagedType.LPTStr)] public String pDatatype;
   public IntPtr pDevMode;
   [MarshalAs(UnmanagedType.I4)] public int DesiredAccess;
  };

[DllImport("winspool.Drv", EntryPoint="OpenPrinter", SetLastError=true,
    CharSet=CharSet.Unicode, ExactSpelling=false,CallingConvention=CallingConvention.StdCall),
  SuppressUnmanagedCodeSecurityAttribute()]
  internal static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPTStr)]
   string printerName,
   out IntPtr phPrinter,
   ref structPrinterDefaults pd);
 
  [DllImport("winspool.Drv", EntryPoint="ClosePrinter", SetLastError=true,
    CharSet=CharSet.Unicode, ExactSpelling=false,
    CallingConvention=CallingConvention.StdCall),SuppressUnmanagedCodeSecurityAttribute()]
  internal static extern bool ClosePrinter(IntPtr phPrinter);

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
   internal struct structSize
  {
   public Int32 width;
   public Int32 height;
  }

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
   internal struct structRect
  {
   public Int32 left;
   public Int32 top;
   public Int32 right;
   public Int32 bottom;
  }

[StructLayout(LayoutKind.Explicit, CharSet=CharSet.Unicode)]
   internal struct FormInfo1
  {
   [FieldOffset(0), MarshalAs(UnmanagedType.I4)] public uint Flags;
   [FieldOffset(4), MarshalAs(UnmanagedType.LPWStr)] public String pName;
   [FieldOffset(8)] public structSize Size;
   [FieldOffset(16)] public structRect ImageableArea;
  };

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi/* changed from CharSet=CharSet.Auto */)]
   internal struct structDevMode
  {
   [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public String
    dmDeviceName;
   [MarshalAs(UnmanagedType.U2)] public short dmSpecVersion;
   [MarshalAs(UnmanagedType.U2)] public short dmDriverVersion;
   [MarshalAs(UnmanagedType.U2)] public short dmSize;
   [MarshalAs(UnmanagedType.U2)] public short dmDriverExtra;
   [MarshalAs(UnmanagedType.U4)] public int dmFields;
   [MarshalAs(UnmanagedType.I2)] public short dmOrientation;
   [MarshalAs(UnmanagedType.I2)] public short dmPaperSize;
   [MarshalAs(UnmanagedType.I2)] public short dmPaperLength;
   [MarshalAs(UnmanagedType.I2)] public short dmPaperWidth;
   [MarshalAs(UnmanagedType.I2)] public short dmScale;
   [MarshalAs(UnmanagedType.I2)] public short dmCopies;
   [MarshalAs(UnmanagedType.I2)] public short dmDefaultSource;
   [MarshalAs(UnmanagedType.I2)] public short dmPrintQuality;
   [MarshalAs(UnmanagedType.I2)] public short dmColor;
   [MarshalAs(UnmanagedType.I2)] public short dmDuplex;
   [MarshalAs(UnmanagedType.I2)] public short dmYResolution;
   [MarshalAs(UnmanagedType.I2)] public short dmTTOption;
   [MarshalAs(UnmanagedType.I2)] public short dmCollate;
   [MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)] public String dmFormName;
   [MarshalAs(UnmanagedType.U2)] public short dmLogPixels;
   [MarshalAs(UnmanagedType.U4)] public int dmBitsPerPel;
   [MarshalAs(UnmanagedType.U4)] public int dmPelsWidth;
   [MarshalAs(UnmanagedType.U4)] public int dmPelsHeight;
   [MarshalAs(UnmanagedType.U4)] public int dmNup;
   [MarshalAs(UnmanagedType.U4)] public int dmDisplayFrequency;
   [MarshalAs(UnmanagedType.U4)] public int dmICMMethod;
   [MarshalAs(UnmanagedType.U4)] public int dmICMIntent;
   [MarshalAs(UnmanagedType.U4)] public int dmMediaType;
   [MarshalAs(UnmanagedType.U4)] public int dmDitherType;
   [MarshalAs(UnmanagedType.U4)] public int dmReserved1;
   [MarshalAs(UnmanagedType.U4)] public int dmReserved2;
  }

[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)] 
         internal struct PRINTER_INFO_9 
      {
         public IntPtr pDevMode;
      }

[DllImport("winspool.Drv", EntryPoint="AddFormW", SetLastError=true,
    CharSet=CharSet.Unicode, ExactSpelling=true,
    CallingConvention=CallingConvention.StdCall), SuppressUnmanagedCodeSecurityAttribute()]
  internal static extern bool AddForm(
         IntPtr phPrinter,
   [MarshalAs(UnmanagedType.I4)] int level, 
         ref FormInfo1 form);

/*    This method is not used
  [DllImport("winspool.Drv", EntryPoint="SetForm", SetLastError=true,
    CharSet=CharSet.Unicode, ExactSpelling=false,
    CallingConvention=CallingConvention.StdCall), SuppressUnmanagedCodeSecurityAttribute()]
  internal static extern bool SetForm(IntPtr phPrinter, string paperName,
   [MarshalAs(UnmanagedType.I4)] int level, ref FormInfo1 form);
*/
  [DllImport("winspool.Drv", EntryPoint="DeleteForm", SetLastError=true,
    CharSet=CharSet.Unicode, ExactSpelling=false,CallingConvention=CallingConvention.StdCall),
  SuppressUnmanagedCodeSecurityAttribute()]
  internal static extern bool DeleteForm(
         IntPtr phPrinter,
   [MarshalAs(UnmanagedType.LPTStr)] string pName);

[DllImport("kernel32.dll", EntryPoint="GetLastError", SetLastError=false,
    ExactSpelling=true, CallingConvention=CallingConvention.StdCall),
  SuppressUnmanagedCodeSecurityAttribute()]
  internal static extern Int32 GetLastError();

[DllImport("GDI32.dll", EntryPoint="CreateDC", SetLastError=true,
    CharSet=CharSet.Unicode, ExactSpelling=false,
    CallingConvention=CallingConvention.StdCall),
  SuppressUnmanagedCodeSecurityAttribute()]
  internal static extern IntPtr CreateDC([MarshalAs(UnmanagedType.LPTStr)]
   string pDrive,
   [MarshalAs(UnmanagedType.LPTStr)] string pName,
   [MarshalAs(UnmanagedType.LPTStr)] string pOutput,
   ref structDevMode pDevMode);

[DllImport("GDI32.dll", EntryPoint="ResetDC", SetLastError=true,
    CharSet=CharSet.Unicode, ExactSpelling=false,
    CallingConvention=CallingConvention.StdCall),
  SuppressUnmanagedCodeSecurityAttribute()]
  internal static extern IntPtr ResetDC(
         IntPtr hDC, 
         ref structDevMode
   pDevMode);

[DllImport("GDI32.dll", EntryPoint="DeleteDC", SetLastError=true,
    CharSet=CharSet.Unicode, ExactSpelling=false,
    CallingConvention=CallingConvention.StdCall),
  SuppressUnmanagedCodeSecurityAttribute()]
  internal static extern bool DeleteDC(IntPtr hDC);

[DllImport("winspool.Drv", EntryPoint="SetPrinterA", SetLastError=true,
          CharSet=CharSet.Auto, ExactSpelling=true,
          CallingConvention=CallingConvention.StdCall), SuppressUnmanagedCodeSecurityAttribute()]
      internal static extern bool SetPrinter(
         IntPtr hPrinter,
         [MarshalAs(UnmanagedType.I4)] int level, 
         IntPtr pPrinter, 
         [MarshalAs(UnmanagedType.I4)] int command);

/*
       LONG DocumentProperties(
         HWND hWnd,               // handle to parent window 
         HANDLE hPrinter,         // handle to printer object
         LPTSTR pDeviceName,      // device name
         PDEVMODE pDevModeOutput, // modified device mode
         PDEVMODE pDevModeInput,  // original device mode
         DWORD fMode              // mode options
         );
       */
      [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 pDeviceName /* changed from String to string */,
         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, 
         int dwLevel /* changed type from Int32 */,
         IntPtr pPrinter,
         int dwBuf /* chagned from Int32*/, 
         out int dwNeeded /* changed from Int32*/
         );

// SendMessageTimeout tools
      [Flags] public enum SendMessageTimeoutFlags : uint
      {
         SMTO_NORMAL         = 0x0000,
         SMTO_BLOCK          = 0x0001,
         SMTO_ABORTIFHUNG    = 0x0002,
         SMTO_NOTIMEOUTIFNOTHUNG = 0x0008
      }
      const int WM_SETTINGCHANGE = 0x001A;
      const int HWND_BROADCAST = 0xffff;

[DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Auto)]
      public static extern IntPtr SendMessageTimeout(
         IntPtr windowHandle, 
         uint Msg, 
         IntPtr wParam, 
         IntPtr lParam, 
         SendMessageTimeoutFlags flags, 
         uint timeout, 
         out IntPtr result
         );
      //打印纸张长宽设置
      public static void AddMC80MmPaperSizeToDefaultPrinter()
      {
         AddCustomPaperSizeToDefaultPrinter("MC 80mm * Receipt Length", 80.1f, 4003.9f);
      }

public static void AddMC104MmPaperSizeToDefaultPrinter()
      {
         AddCustomPaperSizeToDefaultPrinter("MC 104mm * Receipt Length", 104.1f, 4003.9f);
      }

/// <summary>
      /// Adds the printer form to the default printer
      /// </summary>
      /// <param name="paperName">Name of the printer form</param>
      /// <param name="widthMm">Width given in millimeters</param>
      /// <param name="heightMm">Height given in millimeters</param>
      public static void AddCustomPaperSizeToDefaultPrinter(string paperName, float widthMm, float heightMm)
      {
         PrintDocument pd = new PrintDocument();
         string sPrinterName = pd.PrinterSettings.PrinterName;
         AddCustomPaperSize(sPrinterName, paperName, widthMm, heightMm);
      }

/// <summary>
      /// Add the printer form to a printer 
      /// </summary>
      /// <param name="printerName">The printer name</param>
      /// <param name="paperName">Name of the printer form</param>
      /// <param name="widthMm">Width given in millimeters</param>
      /// <param name="heightMm">Height given in millimeters</param>
  public static void AddCustomPaperSize(string printerName, string paperName, float
   widthMm, float heightMm)
  {
   if (PlatformID.Win32NT == Environment.OSVersion.Platform)
   {
    // The code to add a custom paper size is different for Windows NT then it is
    // for previous versions of windows

const int PRINTER_ACCESS_USE = 0x00000008;
    const int PRINTER_ACCESS_ADMINISTER = 0x00000004;
    const int FORM_PRINTER =   0x00000002;
   
    structPrinterDefaults defaults = new structPrinterDefaults();
    defaults.pDatatype = null;
    defaults.pDevMode = IntPtr.Zero;
    defaults.DesiredAccess = PRINTER_ACCESS_ADMINISTER | PRINTER_ACCESS_USE;

IntPtr hPrinter = IntPtr.Zero;

// Open the printer.
    if (OpenPrinter(printerName, out hPrinter, ref defaults))
    {
     try
     {
                  // delete the form incase it already exists
      DeleteForm(hPrinter, paperName);
                  // create and initialize the FORM_INFO_1 structure
      FormInfo1 formInfo = new FormInfo1();
      formInfo.Flags = 0;
      formInfo.pName = paperName;
                  // all sizes in 1000ths of millimeters
      formInfo.Size.width = (int)(widthMm * 1000.0); 
      formInfo.Size.height = (int)(heightMm * 1000.0);
      formInfo.ImageableArea.left = 0;
      formInfo.ImageableArea.right = formInfo.Size.width;
      formInfo.ImageableArea.top = 0;
      formInfo.ImageableArea.bottom = formInfo.Size.height;
      if (!AddForm(hPrinter, 1, ref formInfo))
      {
       StringBuilder strBuilder = new StringBuilder();
       strBuilder.AppendFormat("Failed to add the custom paper size {0} to the printer {1}, System error number: {2}",
        paperName, printerName, GetLastError());
       throw new ApplicationException(strBuilder.ToString());
      }

// INIT
                  const int DM_OUT_BUFFER = 2;
                  const int DM_IN_BUFFER = 8;
                  structDevMode devMode = new structDevMode();
                  IntPtr hPrinterInfo, hDummy;
                  PRINTER_INFO_9 printerInfo;
                  printerInfo.pDevMode = IntPtr.Zero;
                  int iPrinterInfoSize, iDummyInt;


                  // GET THE SIZE OF THE DEV_MODE BUFFER
                  int iDevModeSize = DocumentProperties(IntPtr.Zero, hPrinter, printerName, IntPtr.Zero, IntPtr.Zero, 0);

if(iDevModeSize < 0)
                     throw new ApplicationException("Cannot get the size of the DEVMODE structure.");

// ALLOCATE THE BUFFER
                  IntPtr hDevMode = Marshal.AllocCoTaskMem(iDevModeSize + 100);

// GET A POINTER TO THE DEV_MODE BUFFER 
                  int iRet = DocumentProperties(IntPtr.Zero, hPrinter, printerName, hDevMode, IntPtr.Zero, DM_OUT_BUFFER);

if(iRet < 0)
                     throw new ApplicationException("Cannot get the DEVMODE structure.");

// FILL THE DEV_MODE STRUCTURE
                  devMode = (structDevMode)Marshal.PtrToStructure(hDevMode, devMode.GetType());

// SET THE FORM NAME FIELDS TO INDICATE THAT THIS FIELD WILL BE MODIFIED
                  devMode.dmFields = 0x10000; // DM_FORMNAME 
                  // SET THE FORM NAME
                  devMode.dmFormName = paperName;

// PUT THE DEV_MODE STRUCTURE BACK INTO THE POINTER
                  Marshal.StructureToPtr(devMode, hDevMode, true);

// MERGE THE NEW CHAGES WITH THE OLD
                  iRet = DocumentProperties(IntPtr.Zero, hPrinter, printerName, 
                           printerInfo.pDevMode, printerInfo.pDevMode, DM_IN_BUFFER | DM_OUT_BUFFER);

if(iRet < 0)
                     throw new ApplicationException("Unable to set the orientation setting for this printer.");

// GET THE PRINTER INFO SIZE
                  GetPrinter(hPrinter, 9, IntPtr.Zero, 0, out iPrinterInfoSize);
                  if(iPrinterInfoSize == 0)
                     throw new ApplicationException("GetPrinter failed. Couldn't get the # bytes needed for shared PRINTER_INFO_9 structure");

// ALLOCATE THE BUFFER
                  hPrinterInfo = Marshal.AllocCoTaskMem(iPrinterInfoSize + 100);

// GET A POINTER TO THE PRINTER INFO BUFFER
                  bool bSuccess = GetPrinter(hPrinter, 9, hPrinterInfo, iPrinterInfoSize, out iDummyInt);

if(!bSuccess)
                     throw new ApplicationException("GetPrinter failed. Couldn't get the shared PRINTER_INFO_9 structure");

// FILL THE PRINTER INFO STRUCTURE
                  printerInfo = (PRINTER_INFO_9)Marshal.PtrToStructure(hPrinterInfo, printerInfo.GetType());
                  printerInfo.pDevMode = hDevMode;

// GET A POINTER TO THE PRINTER INFO STRUCTURE
                  Marshal.StructureToPtr(printerInfo, hPrinterInfo, true);

// SET THE PRINTER SETTINGS
                  bSuccess = SetPrinter(hPrinter, 9, hPrinterInfo, 0);

if(!bSuccess)
                     throw new Win32Exception(Marshal.GetLastWin32Error(), "SetPrinter() failed.  Couldn't set the printer settings");

// Tell all open programs that this change occurred.
                  SendMessageTimeout(
                     new IntPtr(HWND_BROADCAST), 
                     WM_SETTINGCHANGE, 
                     IntPtr.Zero, 
                     IntPtr.Zero, 
                     MCCustomPrintForm.SendMessageTimeoutFlags.SMTO_NORMAL, 
                     1000, 
                     out hDummy);
     }
     finally
     {
      ClosePrinter(hPrinter);
     }
    }
    else
    {
     StringBuilder strBuilder = new StringBuilder();
     strBuilder.AppendFormat("Failed to open the {0} printer, System error number: {1}",
      printerName, GetLastError());
     throw new ApplicationException(strBuilder.ToString());
    }
   }
   else
   {
    structDevMode pDevMode = new structDevMode();
    IntPtr hDC = CreateDC(null, printerName, null, ref pDevMode);
    if (hDC != IntPtr.Zero)
    {
     const long DM_PAPERSIZE = 0x00000002L;
     const long DM_PAPERLENGTH = 0x00000004L;
     const long DM_PAPERWIDTH = 0x00000008L;
     pDevMode.dmFields = (int)(DM_PAPERSIZE | DM_PAPERWIDTH | DM_PAPERLENGTH);
     pDevMode.dmPaperSize = 256;
     pDevMode.dmPaperWidth = (short)(widthMm * 1000.0);
     pDevMode.dmPaperLength = (short)(heightMm * 1000.0);
     ResetDC(hDC, ref pDevMode);
     DeleteDC(hDC);
    }
   }
  }
 }
}

相关文章:

看完 50000 张专辑封面,AI 设计师开始疯狂输出

西班牙艺术家利用 StyleGAN2 打造了一个 AI 设计师&#xff0c;借助 50000 张图像自学成才&#xff0c;没想到培养一个印象派设计师这么简单。作者 | 三羊来源 | HyperAI超神经头图 | 网友整理抄袭事件的对比图也许是有些设计太经典出挑&#xff0c;总是让人情不自禁地模仿。日…

XenApp_XenDesktop_7.6实战篇之八:申请及导入许可证

1. 申请许可证Citrix XenApp_XenDesktop7.6和XenServer 6.5申请许可证的步骤是一致的&#xff0c;由于之前我已经申请过XenApp_XenDesktop的许可证&#xff0c;本次以XenServer6.5的许可证申请为例。1.1 在申请试用或购买Citrix产品时&#xff0c;收到相应的邮件&#xff0c;其…

使用Windows操作系统的13个窍门

Windows操作系统的13个使用窍门&#xff0c;很适用。 1.删除Windows下不让删除的文件 有时想删除某个文件&#xff0c;系统会告诉无法删除&#xff0c;换到DOS下或是安全模式虽然可以删除&#xff0c;但是有点麻烦。这时可以用鼠标右键点击回收站&#xff0c;选择“属性”将“回…

如何让机器像人一样多角度思考?协同训练来帮你

作者 | 宁欣头图 | 下载于视觉中国出品 | AI科技大本营&#xff08;ID:rgznai100&#xff09;本文目录0. 摘要1. 引言2. 协同训练介绍3. 协同训练改进3.1 基于视图划分的协同训练3.2 基于学习器差异化的协同训练3.3 基于标签置信度的协同训练4. 协同训练应用5. 总结与展望摘要协…

PHP设计模式(4)命令链模式

命令链 模式以松散耦合主题为基础&#xff0c;发送消息、命令和请求&#xff0c;或通过一组处理程序发送任意内容。每个处理程序都会自行判断自己能否处理请求。如果可以&#xff0c;该请求被处理&#xff0c;进程停止。您可以为系统添加或移除处理程序&#xff0c;而不影响其他…

MFC界面库BCGControlBar v25.3新版亮点:Gauge Controls

2019独角兽企业重金招聘Python工程师标准>>> 亲爱的BCGSoft用户&#xff0c;我们非常高兴地宣布BCGControlBar Professional for MFC和BCGSuite for MFC v25.3正式发布&#xff01;新版本添加了对Visual Studio 2017的支持、增强对Windows 10的支持等。接下来几篇文…

如何使用 ASP.NET 实用工具加密凭据和会话状态连接字符串

文章编号:329290最后修改:2006年4月10日修订:8.0 重要说明&#xff1a;本文包含有关如何修改注册表的信息。修改注册表之前&#xff0c;一定要先进行备份&#xff0c;并且一定要知道在发生问题时如何还原注册表。有关如何备份、还原和修改注册表的更多信息&#xff0c;请单击下…

16款小米新品,刚刚雷军只发了5款

会前&#xff0c;雷军在微博上提前疯狂剧透小米即将发布的新品信息。要发布的产品实在太多了&#xff0c;整合提前发布的信息来看&#xff0c;此次发布会可能会是小米有史以来时间跨度最长、新品数量最多的新品发布会&#xff0c;包括小米11 Pro/Ultra、小米MIX新机、小米11青春…

windows下使用aspell开启emacs的单词拼写检查功能

第一步,你需要下载aspell安装文件和至少一个字典,下载地址为http://aspell.net/win32/. 下载之后,分别安装aspell和字典. 需要注意的是,在64位的WIN7下,“C:\Program Files (x86)”是32位安装程序的默认安装目录,而“C:\Program Files"是64位安装程序的默认安装目录,因此a…

老板来了:人脸识别 + 手机推送,老板来了你立刻知道!

背景介绍 学生时代&#xff0c;老师站在窗外的阴影挥之不去。大家在玩手机&#xff0c;看漫画&#xff0c;看小说的时候&#xff0c;总是会找同桌帮忙看着班主任有没有来。 一转眼&#xff0c;曾经的翩翩少年毕业了&#xff0c;新的烦恼来了&#xff0c;在你刷知乎&#xff0c;…

在C#中使用COM+实现事务控制

.NET技术是微软大力推广的下一代平台技术&#xff0c;自从.NET技术架构的正式发布&#xff0c;此项技术也逐渐走向成熟和稳定。按照微软的平台系统占有率&#xff0c;我们不难想象得到&#xff0c;在未来的一两年内.NET技术必定会势如破竹一般的登上主流的技术平台&#xff0c;…

深入理解 JavaScript 中的 replace 方法

2019独角兽企业重金招聘Python工程师标准>>> 字符串替换字符串 1 I am loser! .replace( loser , hero ) //I am hero! 直接使用字符串能让自己从loser变成hero&#xff0c;但是如果有2个loser就不能一起变成hero了。 1 I am loser,You are loser .replace( loser ,…

透过计算机视觉,看看苏伊士运河堵船

作者 | Edison_G来源 | 计算机视觉研究院头图 | 下载于视觉中国3月29日&#xff0c;长赐号终于重新上浮。船运代理公司Inchcape和苏伊士运河管理局皆证实&#xff0c;长赐号已经重新漂浮在水面上&#xff0c;但目前还不清楚需要多少时间重启运河。这张图片&#xff0c;相信大家…

泼点冷水,P2P借款限额是不是想的太美好?

8月24日等待了大半年的P2P网贷监管规则《网络借贷信息中介机构业务活动管理暂行办法&#xff08;评估稿&#xff09;》终于出现。办法中最引人注意的是对借款上限的规定&#xff1a; 同一自然人在同一网络借贷信息中介机构平台的借款余额上限不超过人民币20万元&#xff0c;在不…

SQL语句优化技术分析

SQL语句优化技术分析 操作符优化 IN 操作符 用IN写出来的SQL的优点是比较容易写及清晰易懂&#xff0c;这比较适合现代软件开发的风格。 但是用IN的SQL性能总是比较低的&#xff0c;从ORACLE执行的步骤来分析用IN的SQL与不用IN的SQL有以下区别&#xff1a; ORACLE试图将…

官方抓虫,PyTorch 新版本修复 13 项 Bug

整理 | 寇雪芹头图 | 下载于视觉中国出品 | AI科技大本营&#xff08;ID&#xff1a;rgznai100&#xff09;近日&#xff0c;PyTorch 发布了新版本 PyTorch 1.8.1&#xff0c;相比3月4日从 PyTorch 1.7 到 1.8 的重要更新&#xff08; 1.8 版本主要包括编译器和分布式训练更新&…

开发webpart时建立图像文件夹和CSS,js文件夹

如图所示&#xff1a;是通过添加映射来完成&#xff0c;做好之后&#xff0c;把图像拷到文件夹时&#xff0c;当ascx文件里需要用到图像时&#xff0c;直接把图像拖到ascx文件里的位置。这样就知道该图像的路径 了。转载于:https://www.cnblogs.com/oymx/p/3490175.html

AI金融若不解决这些问题,等于在制造新的不可解问题

人们对新事物总是充满恐惧。就在大家担心无人驾驶汽车是否弊大于利的时候&#xff0c;AI重塑金融规律的创新也引起许多人对其中的法律和道德问题的顾虑。 让一个软件程序来决定&#xff0c;谁拥有投资开户的资格&#xff0c;谁能够获得贷款&#xff08;征信&#xff09;&#x…

Java 领域 offer 收割:程序员黄金 5 年进阶心得!

怎样才能拿到大厂的offer&#xff1f;没有掌握绝对的技术&#xff0c;那么就要不断的学习。如何拿下阿里等大厂的offer的呢&#xff0c;今天分享一个秘密武器&#xff0c;资深架构师整理的Java核心知识点&#xff0c;面试时面试官必问的知识点&#xff0c;篇章包括了很多知识点…

TCP连接的状态转换图深度剖析

在TCP/IP协议中&#xff0c;TCP协议提供可靠的连接服务&#xff0c;采用三次握手建立一个连接&#xff0c;如图1所示。&#xff08;1&#xff09;第一次握手&#xff1a;建立连接时&#xff0c;客户端A发送SYN包&#xff08;SYNj&#xff09;到服务器B&#xff0c;并进入SYN_SE…

ASP.Net中的TreeView控件中对节点的上移和下移操作

Web中的TreeView中的没有PreNode和NextNode属性。 但它的集合属性中有一个IndexOf属性&#xff0c;从而能够找到它的前一个节点知后一个节点。 TreeView中要么只有一个根节点&#xff1b;要么没有根节点&#xff0c;都是并列排的&#xff0c;这个要判断。 这里主要是用了递归&a…

大数据流通存隐忧 产业信任体系亟待建立

就在今年10月&#xff0c;始于美国东部的“DDoS攻击”席卷了整个美国&#xff0c;引起了人们对数据安全的恐慌&#xff0c;大数据安全问题逐渐暴露。在第三届世界互联网大会的大数据分论坛上&#xff0c;中国科学院秘书长邓麦村在致辞中指出&#xff0c;如何突破大数据关键技术…

ImageNet十年,AI数据标注如何蓬勃发展?

2016 年&#xff0c;AlphaGo 战胜李世石&#xff0c;成为新一代 AI 浪潮的重要里程碑事件。 经此一役&#xff0c;很多人都认识到了算法和算力对 AI 发展的重要性&#xff0c;确忽略了另一个重要因素&#xff1a;数据。 2009 年&#xff0c;时任斯坦福大学任助理教授的李飞飞…

关于webservice的异步调用简单实例

于webservice的异步调用简单实例无论在任何情况下&#xff0c;被调用方的代码无论是被异步调用还是同步调用的情况下&#xff0c;被调用方的代码都是一样的&#xff0c; 下面&#xff0c;我们就以异步调用一个webservice 为例作说明。这是一个webservice <WebMethod(Descrip…

理解NSAttributedString

An NSAttributedString object manages character strings and associated sets of attributes (for example, font and kerning) that apply to individual characters or ranges of characters in the string. 这句话就是对这个类的一个最简明扼要的概括。NSAttributedString…

Redis集群两种配置方式

2019独角兽企业重金招聘Python工程师标准>>> 第一种使用&#xff1a;JedisCluster <bean id"jedisPoolConfig" class"redis.clients.jedis.JedisPoolConfig"><property name"maxTotal" value"30" /><proper…

调用API弹出打印机属性对话框

调用api弹出打印机属性对话框 Author:vitoriatangFrom:Internet.NET Framework封装了很多关于打印的对话框&#xff0c;比如说PrintDialog, PageSetupDialog. 但是有的时候我们还需要关心打印机属性对话框&#xff0c;那么就可以调用API来解决这个问题。有几个API函数与之相关P…

Oracle DBA学习互联网化的内容

搞了多年的Oracle数据库维护&#xff0c;近几年来&#xff0c;个人感觉基本都在舒适区&#xff0c;技术上没啥进步。而且由于个人资料或者学习方法的限制&#xff0c;Oracle数据库技术上再想精进感觉事倍功半。2013年开始&#xff0c;去IOE的声势搞得轰轰烈烈&#xff0c;mysql…

离不开深度学习的自动驾驶

作者 | 小白来源 | 小白学视觉头图 | 下载于视觉中国深度学习在整个自动驾驶技术的各个部分中进行了应用&#xff0c;例如在感知&#xff0c;预测和计划中都有应用。同时&#xff0c;深度学习也可以用于制图&#xff0c;这是高级自动驾驶的关键组成部分。拥有准确的地图对于自动…

IOS -- base64编码

在iOS7以后可以用NSData自带的base64EncodedStringWithOptions进行编解码&#xff1a; 方法如下&#xff1a; - (NSString *)encodeToBase64String:(UIImage *)image {return [UIImagePNGRepresentation(image) base64EncodedStringWithOptions:NSDataBase64Encoding64Charact…