欢迎访问!
您的支持是我们不断前行的动力!

C# 调用系统默认图片打印向导打印图片

C# 调用系统默认图片打印向导打印图片,见下方代码

internal class ImagePrinter
    {
        [ComImport]
        [Guid("00000122-0000-0000-C000-000000000046")]
        [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
        public interface IDropTarget
        {
            int DragEnter(
                [In] System.Runtime.InteropServices.ComTypes.IDataObject pDataObj,
                [In] int grfKeyState,
                [In] Point pt,
                [In, Out] ref int pdwEffect);

            int DragOver(
                [In] int grfKeyState,
                [In] Point pt,
                [In, Out] ref int pdwEffect);

            int DragLeave();

            int Drop(
                [In] System.Runtime.InteropServices.ComTypes.IDataObject pDataObj,
                [In] int grfKeyState,
                [In] Point pt,
                [In, Out] ref int pdwEffect);
        }

        internal static void PrintPhotosWizard(string p_FileName)
        {
            IDataObject v_DataObject = new DataObject(DataFormats.FileDrop, new string[] { p_FileName });
            MemoryStream v_MemoryStream = new MemoryStream(4);
            byte[] v_Buffer = new byte[] { (byte)5, 0, 0, 0 };
            v_MemoryStream.Write(v_Buffer, 0, v_Buffer.Length);
            v_DataObject.SetData("Preferred DropEffect", v_MemoryStream);
            Guid CLSID_PrintPhotosDropTarget = new Guid("60fd46de-f830-4894-a628-6fa81bc0190d");
            Type v_DropTargetType = Type.GetTypeFromCLSID(CLSID_PrintPhotosDropTarget, true);
            IDropTarget v_DropTarget = (IDropTarget)Activator.CreateInstance(v_DropTargetType);
            v_DropTarget.Drop((System.Runtime.InteropServices.ComTypes.IDataObject)v_DataObject, 0, new Point(), 0);
        }
    }

 

赞(0) 打赏
转载请注明出处,未注明出处不得转载,蜘蛛侠 » C# 调用系统默认图片打印向导打印图片
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!

 

蜘蛛侠,您身边的爬虫专家!

觉得文章有用就打赏一下文章作者吧

支付宝扫一扫打赏

微信扫一扫打赏