Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Win32 Printing Status Check

Win32 Printing Status Check

Scheduled Pinned Locked Moved C#
help
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tiger456
    wrote on last edited by
    #1

    I am using below code to check printing status but it always returns 0. It would be great if you can help me . i think there is some problem in the way i am using GetPrinter method

    [DllImport("winspool.Drv", EntryPoint = "OpenPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
    private static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPStr)] string szPrinter, out IntPtr hPrinter, Int32 pDefault);

        /// <summary>
        /// Close Win32 printer
        /// </summary>
        /// <param name="printer"></param>
        /// <returns></returns>
        \[DllImport("winspool.Drv", EntryPoint = "ClosePrinter", SetLastError = true, ExactSpelling = true,
                                                                    CallingConvention = CallingConvention.StdCall)\]
        public static extern bool ClosePrinter(IntPtr printer);
    
    
    
        \[DllImport("winspool.Drv", EntryPoint = "GetPrinterDataA", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)\]
        public static extern uint GetPrinterData(
                                                    \[In\] IntPtr hPrinter,
                                                    \[In, MarshalAs(UnmanagedType.LPWStr)\] string pValueName,
                                                    \[Out, Optional\] uint pType,
                                                    \[Out, Optional\] IntPtr pData,
                                                    uint nSize,
                                                    \[Out\] uint pcbNeeded
                                                );
    
        \[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\*/
                                            );
    

    [StructLayout(LayoutKind.Sequ

    ential)]
    internal struct PRINTER_INFO
    {
    public IntPtr pServerName;
    public IntPtr pPrinterName;
    public In

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups