Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8512199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:12:58+00:00 2026-06-11T04:12:58+00:00

Googled a lot but returned empty hand.. I would like to know if anyone

  • 0

Googled a lot but returned empty hand..

I would like to know if anyone used AddPrinterDriver or AddPrinterDriverEx API using winspool.drv in c#.

Please provide me the code that does initialising and using this API Call.

Urgent..!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:12:59+00:00Added an answer on June 11, 2026 at 4:12 am

    I have been working on this same issue for some time, and have something to start with, though I am still running into issues. I believe my real issue now is creating the list of dependent files properly. Perhaps you know how to fill in these blanks for me?

    Thanks,
    Stephen

        private const uint APD_COPY_NEW_FILES = 0x00000008;
        private const uint APD_COPY_ALL_FILES = 0x00000004;
    
        [DllImport("winspool.drv", CharSet = CharSet.Unicode, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern bool AddPrinterDriverExW([In, Optional, MarshalAs(UnmanagedType.LPWStr)] string pName, uint Level, [In] IntPtr pPrinter, uint Flags);
    
        public static void InstallPrinterDriver2(string configFile, string dataFile, string[] dependentFiles, string driverPath, string driverName, string helpFile = null,      string monitorName = null, string defaultDataType = "RAW", bool is32Bit = false)
        {
            DRIVER_INFO_3 di3 = new DRIVER_INFO_3();
            di3.cVersion = 0x03;
            di3.pConfigFile = configFile;
            di3.pDataFile = dataFile;
            di3.pDependentFiles = string.Join(",", dependentFiles);
            di3.pDriverPath = driverPath;
            di3.pEnvironment = is32Bit ? @"Windows NT x86" : @"Windows x64";
            di3.pHelpFile = helpFile;
            di3.pMonitorName = monitorName;
            di3.pName = driverName;
            di3.pDefaultDataType = defaultDataType;
    
            IntPtr intPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DRIVER_INFO_3)));
            try
            {
                Marshal.StructureToPtr(di3, intPtr, false);
                if (!AddPrinterDriverExW(null, 3, intPtr, APD_COPY_NEW_FILES))
                {
                    int w32Error = Marshal.GetLastWin32Error();
                    throw new Win32Exception(w32Error);
                }
            }
            finally
            {
                if (IntPtr.Zero != intPtr) Marshal.FreeHGlobal(intPtr);
            }
        }
    
        [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
        private struct DRIVER_INFO_3
        {
            public uint cVersion;
            [MarshalAs(UnmanagedType.LPWStr)]
            public string pName; // QMS 810
            [MarshalAs(UnmanagedType.LPWStr)]
            public string pEnvironment; // Win32 x86
            [MarshalAs(UnmanagedType.LPWStr)]
            public string pDriverPath; // c:\drivers\pscript.dll
            [MarshalAs(UnmanagedType.LPWStr)]
            public string pDataFile; // c:\drivers\QMS810.PPD
            [MarshalAs(UnmanagedType.LPWStr)]
            public string pConfigFile; // c:\drivers\PSCRPTUI.DLL
            [MarshalAs(UnmanagedType.LPWStr)]
            public string pHelpFile; // c:\drivers\PSCRPTUI.HLP
            [MarshalAs(UnmanagedType.LPWStr)]
            public string pDependentFiles; // PSCRIPT.DLL\0QMS810.PPD\0PSCRIPTUI.DLL\0PSCRIPTUI.HLP\0PSTEST.TXT\0\0
            [MarshalAs(UnmanagedType.LPWStr)]
            public string pMonitorName; // "PJL monitor"
            [MarshalAs(UnmanagedType.LPWStr)]
            public string pDefaultDataType; // "EMF"
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've googled a lot but it seems to be rather difficult to find complete
I've have gone through stackoverflow for days and googled a lot but can still
I have Googled a lot and found a lot of solutions, but none of
I have googled an serached a lot here about background runnin aps but have
I know there's a lot of resource for this via google, but I just
I know that there are a few similar questions and I googled a lot
I've seen a lot of posts returned from a Google search about this, but
I googled lot but failed actually I need to list all my products of
I tried, googled a lot but still finding for a solution. My problem is
Im having difficulties creating a query. I have googled a lot but did not

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.