SilverScreen Solid Modeler

printer_get_name_s

printer_get_name_s

Previous topic Next topic  

printer_get_name_s

Previous topic Next topic JavaScript is required for the print function  

 

SilverScreenAPI

 

void printer_get_name_s ( char *buffer, int buffer_len )

 

char *bufffer;    // Character buffer that will contain printer name

int  buffer_len;  // Length of the buffer in characters

 

 




Synopsis

#include "silver.h"

 

The printer_get_name_s function obtains a name for the currently selected Windows printer. This name may be saved and used in a subsequent call to printer_set_name.

 

Parameters

buffer is a character buffer which is to receive the printer name.

buffer_len is the length of the character buffer

 

Return Value

printer_get_name_s returns -2 if the buffer is too small to hold the device name, -1 if a current printer could not be obtained (i.e. perhaps none is selected), and a number > 0 which is the length of the printer name.

 

Remarks

To determine the minimal buffer size, call printer_get_name_s with buffer = NULL, and/or buffer_len = 0. If the buffer is too small to hold the printer name, then buffer is not modified.

 

See Also

printer_set_name

 

Example

The following example demonstrates how to use printer_get_name_s to obtain a buffer size, then how to call it again with an appropriately-sized buffer.

 

C / C++ Code

 

#include "silver.h

 

. . .

 

char *buffer = NULL;

int  buffer_len = 0;

int  minimal_len = 0;

 

minimal_len = printer_get_name_s(NULL, 0);

 

if ( minimal_len > 0 )

  {

  buffer_len = minimal_len;

  buffer     = malloc(minimal_len);

 

  if ( buffer )

     printer_get_name_s(buffer, buffer_len);

  }

 

 

if ( buffer )

  {

  // Use buffer

 

  . . .

 

  free(buffer);

  }