Printer properties Dialog Saved changes
<p>Hi i want to save the changes i made in printer preferences but they are ignored . I am doing this in c# 
Please help me thanks</p>

<pre><code>public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }
    PrintDocument pd = new PrintDocument();

    [DllImport("kernel32.dll")]
    static extern IntPtr GlobalLock(IntPtr hMem);

    [DllImport("kernel32.dll")] 
    [return: MarshalAs(UnmanagedType.Bool)] static extern bool GlobalUnlock(IntPtr hMem);

    [DllImport("kernel32.dll")]
    static extern IntPtr GlobalFree(IntPtr hMem);

    [DllImport("winspool.Drv", EntryPoint = "DocumentPropertiesW", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)] 
    static extern int DocumentProperties(IntPtr hwnd, IntPtr hPrinter,[MarshalAs(UnmanagedType.LPWStr)] string pDeviceName,IntPtr pDevModeOutput, IntPtr pDevModeInput, int fMode);                                                                                                                                                           
    private const int DM_IN_BUFFER = 8;
    private const int DM_OUT_BUFFER = 2;
    private const int DM_IN_PROMPT = 4;

    private void ShowPrinterProperties(PrinterSettings settings)
    {
        IntPtr hDevMode = settings.GetHdevmode(settings.DefaultPageSettings);

        IntPtr pDevMode = GlobalLock(hDevMode);

        DocumentProperties(this.Handle, IntPtr.Zero, settings.PrinterName, pDevMode, pDevMode, DM_IN_PROMPT);

        GlobalUnlock(hDevMode);

        settings.SetHdevmode(hDevMode);

        settings.DefaultPageSettings.SetHdevmode(hDevMode);

        GlobalFree(hDevMode);
    }

    private void Form1_Load(object sender, EventArgs e)
    {  
            // Add list of installed printers found to the combo box.
           // The pkInstalledPrinters string will be used to provide the display string.
           String pkInstalledPrinters;
           for (int i = 0; i &lt; PrinterSettings.InstalledPrinters.Count; i++)
           {
               pkInstalledPrinters = PrinterSettings.InstalledPrinters[i];
               comboBox1.Items.Add(pkInstalledPrinters);
               //selectedPrinter = comboBox1.SelectedItem.ToString();
           }
    }

    private void button1_Click(object sender, EventArgs e)
    {
           if (pd.PrinterSettings.IsValid)
               ShowPrinterProperties(pd.PrinterSettings);
           else
               MessageBox.Show("Invalid printer name");
    }

    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {

        pd.PrinterSettings.PrinterName = comboBox1.Text;
       // selectedPrinter = comboBox1.SelectedItem.ToString();         

    }
}
</code></pre>
