Results 1 to 5 of 5

Thread: GetDefaultPrinter API

  1. #1

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Unhappy

    Hi! I juz read this API GetDefaultPrinter from the MSDN library, but I can not get this API declaration from the API Viewer that come with visual Basic

    GetDefaultPrinter
    The GetDefaultPrinter function retrieves the printer name of the default printer for the current user on the local computer.

    BOOL GetDefaultPrinter(
    LPTSTR pszBuffer, // printer name buffer
    LPDWORD pcchBuffer // size of name buffer
    );
    Parameters
    pszBuffer
    [in] Pointer to a buffer that receives a null-terminated character string containing the default printer name. If this parameter is NULL, the function fails and the variable pointed to by pcchBuffer returns the required buffer size, in characters.
    pcchBuffer
    [in/out] On input, specifies the size, in characters, of the pszBuffer buffer. On output, receives the size, in characters, of the printer name string, including the terminating null character.
    Return Values
    If the function succeeds, the return value is a nonzero value and the variable pointed to by pcchBuffer contains the number of characters copied to the pszBuffer buffer, including the terminating null character.

    If the function fails, the return value is zero. To get extended error information, call GetLastError, which can return one of the following error codes.
    Or is there any alternative way to perform this function?

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Hi, this should get all installed printers in a combobox and highlight the default one... No API needed!

    Code:
    Dim x&
    For x = 0 To Printers.Count - 1
        Combo1.AddItem Printers(x).DeviceName
    Next x
    Combo1.AddItem Printer.DeviceName
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Unhappy

    Yes it does return all the installed printer, But I need the Default Printer instead all the installed printer.

    Hope you can help me.

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Hi, this should get all installed printers in a combobox and highlight the default one...
    Oh I made a typo in the code

    It should be like

    Code:
    Dim x&
    For x = 0 To Printers.Count - 1
        Combo1.AddItem Printers(x).DeviceName
    Next x
    Combo1.Text = Printer.DeviceName 'Selects Default printer!
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Thanks, Job. I got it.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width