当前位置: 首页>>代码示例>>C++>>正文


C++ ClosePrinter函数代码示例

本文整理汇总了C++中ClosePrinter函数的典型用法代码示例。如果您正苦于以下问题:C++ ClosePrinter函数的具体用法?C++ ClosePrinter怎么用?C++ ClosePrinter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ClosePrinter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: localui_DeletePortUI

/*****************************************************
 *   localui_DeletePortUI [exported through MONITORUI]
 *
 * Delete a specific Port
 *
 * PARAMS
 *  pName     [I] Servername or NULL (local Computer)
 *  hWnd      [I] Handle to parent Window
 *  pPortName [I] Name of the Port, that should be deleted
 *
 * RETURNS
 *  Success: TRUE
 *  Failure: FALSE
 *
 * NOTES
 *  Native localui does not allow to delete a COM / LPT - Port (ERROR_NOT_SUPPORTED)
 *
 */
static BOOL WINAPI localui_DeletePortUI(PCWSTR pName, HWND hWnd, PCWSTR pPortName)
{
    HANDLE  hXcv;
    DWORD   dummy;
    DWORD   needed;
    DWORD   status;

    TRACE("(%s, %p, %s)\n", debugstr_w(pName), hWnd, debugstr_w(pPortName));

    if ((!pPortName) || (!pPortName[0])) {
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    if (open_monitor_by_name(XcvPortW, pPortName, &hXcv)) {
        /* native localui tests here for LPT / COM - Ports and failed with
           ERROR_NOT_SUPPORTED. */
        if (XcvDataW(hXcv, cmd_DeletePortW, (LPBYTE) pPortName,
            (lstrlenW(pPortName)+1) * sizeof(WCHAR), (LPBYTE) &dummy, 0, &needed, &status)) {

            ClosePrinter(hXcv);
            if (status != ERROR_SUCCESS) SetLastError(status);
            return (status == ERROR_SUCCESS);
        }
        ClosePrinter(hXcv);
        return FALSE;
    }
    SetLastError(ERROR_UNKNOWN_PORT);
    return FALSE;
}
开发者ID:Barrell,项目名称:wine,代码行数:48,代码来源:localui.c

示例2: Erro

//---------------------------------------------------------------------------
bool __fastcall TRawPrint::FechaDispositivo(void)
{
 bool Retorno = true;

 try
  {
   if (DispAberto)
    {
     if (PaginaAberta)
      {
       if(!EndPagePrinter(hPrinter))
        Erro("Erro ao Finalizar Página");

       if(!EndDocPrinter(hPrinter))
        Erro("Erro ao Finalizar Documento");
       else
        {
         if(!ClosePrinter(hPrinter))
          {
           Erro("Erro ao Fechar a Impressora");
           Retorno = false;
          }
          DispAberto = false;
        }
      }
    }
  }
 catch(Exception & E)
  {
   Erro("Erro ao Fechar a Impressora.\r\n\r\n" + E.Message + "\r\n");
  }
 return Retorno;
};
开发者ID:fboscato,项目名称:escrituracao-fiscal-g1,代码行数:34,代码来源:TRawPrint1.cpp

示例3: OpenPrinterW

bool PrinterUtil::initDeviceSettings( QString printerName, QByteArray& devModeA )
{
	bool done;
	uint size;
	LONG result = IDOK+1;
	Qt::HANDLE handle = NULL;
	// Get the printer handle
	done = OpenPrinterW( (LPWSTR) printerName.utf16(), &handle, NULL );
	if(!done)
		return false;
	// Get size of DEVMODE structure (public + private data)
	size = DocumentPropertiesW( ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), NULL, NULL, 0);
	// Compare size with DevMode structure size
	if( devModeA.size() == size )
	{
		// Merge printer settings
		result = DocumentPropertiesW( ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), (DEVMODEW*) devModeA.data(), (DEVMODEW*) devModeA.data(), DM_IN_BUFFER | DM_OUT_BUFFER);
	}
	else
	{
		// Retrieve default settings
		devModeA.resize( size );
		result = DocumentPropertiesW( ScCore->primaryMainWindow()->winId(), handle, (LPWSTR) printerName.utf16(), (DEVMODEW*) devModeA.data(), NULL, DM_OUT_BUFFER);
	}
	done = ( result == IDOK);
	// Free the printer handle
	ClosePrinter( handle );
	return done;
}
开发者ID:AlterScribus,项目名称:ece15,代码行数:29,代码来源:util_printer.cpp

示例4: gtk_print_win32_devnames_from_printer_name

/*
 * Used to get printer device information from a printer name.  This
 * can fail if the user has no right to read printer properties, so
 * this function can return NULL.
 */
GtkPrintWin32Devnames *
gtk_print_win32_devnames_from_printer_name (const char *printer_name)
{
  HANDLE hprinter;
  gunichar2* win32_printer_name;
  GtkPrintWin32Devnames *devnames;

  win32_printer_name = g_utf8_to_utf16 (printer_name, -1, NULL, NULL, NULL);
  if (OpenPrinterW (win32_printer_name, &hprinter, NULL))
    {
      DWORD needed;
      PRINTER_INFO_2W* printer_info;

      GetPrinterW (hprinter, 2, NULL, 0, &needed);
      printer_info = (PRINTER_INFO_2W* )g_malloc ((gsize) needed);
      GetPrinterW (hprinter, 2, (LPBYTE) printer_info, needed, &needed);
      devnames = g_new (GtkPrintWin32Devnames, 1);
      devnames->driver = g_utf16_to_utf8 (printer_info->pDriverName, -1, NULL, NULL, NULL);
      devnames->device = g_strdup (printer_name);
      devnames->output = g_utf16_to_utf8 (printer_info->pPortName, -1, NULL, NULL, NULL);
      devnames->flags  = 0;
      ClosePrinter (hprinter);
      g_free (printer_info);
    }
  else
    {
      /* Could not open printer */
      devnames = NULL;
    }
  g_free (win32_printer_name);

  return devnames;
}
开发者ID:Aridna,项目名称:gtk2,代码行数:38,代码来源:gtkprint-win32.c

示例5: DEBUG_UNUSED

OSStatus
CPrinterSetupWizardSheet::InstallPrinterIPP(Printer * printer, Service * service)
{
	DEBUG_UNUSED( service );

	HANDLE			hPrinter = NULL;
	PRINTER_INFO_2	pInfo;
	OSStatus		err;
	
	//
	// add the printer
	//
	ZeroMemory(&pInfo, sizeof(PRINTER_INFO_2));
	
	pInfo.pPrinterName		= printer->actualName.GetBuffer();
	pInfo.pPortName			= printer->portName.GetBuffer();
	pInfo.pDriverName		= printer->model.GetBuffer();
	pInfo.pPrintProcessor	= L"winprint";
	pInfo.pLocation			= service->location.GetBuffer();
	pInfo.Attributes		= PRINTER_ATTRIBUTE_NETWORK | PRINTER_ATTRIBUTE_LOCAL;
	
	hPrinter = AddPrinter(NULL, 2, (LPBYTE)&pInfo);
	err = translate_errno( hPrinter, errno_compat(), kUnknownErr );
	require_noerr( err, exit );

exit:

	if ( hPrinter != NULL )
	{
		ClosePrinter(hPrinter);
	}

	return err;
}
开发者ID:HQarroum,项目名称:android-mdns,代码行数:34,代码来源:PrinterSetupWizardSheet.cpp

示例6: localui_ConfigurePortUI

/*****************************************************
 *   localui_ConfigurePortUI [exported through MONITORUI]
 *
 * Display the Configuration-Dialog for a specific Port
 *
 * PARAMS
 *  pName     [I] Servername or NULL (local Computer)
 *  hWnd      [I] Handle to parent Window for the Dialog-Box or NULL
 *  pPortName [I] Name of the Port, that should be configured
 *
 * RETURNS
 *  Success: TRUE
 *  Failure: FALSE
 *
 */
static BOOL WINAPI localui_ConfigurePortUI(PCWSTR pName, HWND hWnd, PCWSTR pPortName)
{
    HANDLE  hXcv;
    DWORD   res;

    TRACE("(%s, %p, %s)\n", debugstr_w(pName), hWnd, debugstr_w(pPortName));
    if (open_monitor_by_name(XcvPortW, pPortName, &hXcv)) {

        res = get_type_from_name(pPortName);
        switch(res)
        {

        case PORT_IS_COM:
            res = dlg_configure_com(hXcv, hWnd, pPortName);
            break;

        case PORT_IS_LPT:
            res = dlg_configure_lpt(hXcv, hWnd);
            break;

        default:
            dlg_nothingtoconfig(hWnd);
            SetLastError(ERROR_CANCELLED);
            res = FALSE;
        }

        ClosePrinter(hXcv);
        return res;
    }
    return FALSE;

}
开发者ID:Barrell,项目名称:wine,代码行数:47,代码来源:localui.c

示例7: ClosePrinter

void RawPrinter::close()
{
    if (opened) {
        ClosePrinter(hPrinter);
        opened = false;
    }
}
开发者ID:dylan-evans,项目名称:VerticalStripes,代码行数:7,代码来源:rawprinter.cpp

示例8: smalloc

printer_job *printer_start_job(char *printer)
{
    printer_job *ret = smalloc(sizeof(printer_job));
    DOC_INFO_1 docinfo;
    int jobstarted = 0, pagestarted = 0;

    ret->hprinter = NULL;
    if (!OpenPrinter(printer, &ret->hprinter, NULL))
	goto error;

    docinfo.pDocName = "PuTTY remote printer output";
    docinfo.pOutputFile = NULL;
    docinfo.pDatatype = "RAW";

    if (!StartDocPrinter(ret->hprinter, 1, (LPSTR)&docinfo))
	goto error;
    jobstarted = 1;

    if (!StartPagePrinter(ret->hprinter))
	goto error;
    pagestarted = 1;

    return ret;

    error:
    if (pagestarted)
	EndPagePrinter(ret->hprinter);
    if (jobstarted)
	EndDocPrinter(ret->hprinter);
    if (ret->hprinter)
	ClosePrinter(ret->hprinter);
    sfree(ret);
    return NULL;
}
开发者ID:rdebath,项目名称:sgt,代码行数:34,代码来源:printing.c

示例9: PSDRV_EndDoc

/************************************************************************
 *           PSDRV_EndDoc
 */
INT PSDRV_EndDoc( PHYSDEV dev )
{
    PSDRV_PDEVICE *physDev = get_psdrv_dev( dev );
    INT ret = 1;

    if(!physDev->job.id) {
        FIXME("hJob == 0. Now what?\n");
	return 0;
    }

    if(!physDev->job.OutOfPage) {
        WARN("Somebody forgot an EndPage\n");
	PSDRV_EndPage( dev );
    }

    if (physDev->job.PageNo)
        PSDRV_WriteFooter( dev );

    ret = EndDocPrinter(physDev->job.hprinter);
    ClosePrinter(physDev->job.hprinter);
    physDev->job.hprinter = NULL;
    physDev->job.id = 0;
    HeapFree( GetProcessHeap(), 0, physDev->job.doc_name );
    physDev->job.doc_name = NULL;

    return ret;
}
开发者ID:bdidemus,项目名称:wine,代码行数:30,代码来源:escape.c

示例10: mswin_printer_thread

void mswin_printer_thread(void *arg)
{
    int fd = (int)arg;
    char pname[gp_file_name_sizeof];
    char data[4096];
    HANDLE hprinter = INVALID_HANDLE_VALUE;
    int count;
    DWORD written;
    DOC_INFO_1 di;

    /* Read from pipe and write to Windows printer.
     * First gp_file_name_sizeof bytes are name of the printer.
     */
    if (read(fd, pname, sizeof(pname)) != sizeof(pname)) {
	/* Didn't get the printer name */
	close(fd);
	return;
    }

    while ( (count = read(fd, data, sizeof(data))) > 0 ) {
	if (hprinter == INVALID_HANDLE_VALUE) {
	    if (!OpenPrinter(pname, &hprinter, NULL)) {
		close(fd);
		return;
	    }
	    di.pDocName = (LPTSTR)gs_product;
	    di.pOutputFile = NULL;
	    di.pDatatype = "RAW";
	    if (!StartDocPrinter(hprinter, 1, (LPBYTE) & di)) {
		AbortPrinter(hprinter);
		close(fd);
		return;
	    }
	}
	if (!StartPagePrinter(hprinter)) {
		AbortPrinter(hprinter);
		close(fd);
		return;
	}
	if (!WritePrinter(hprinter, (LPVOID) data, count, &written)) {
	    AbortPrinter(hprinter);
	    close(fd);
	    return;
	}
    }
    if (hprinter != INVALID_HANDLE_VALUE) {
	if (count == 0) {
	    /* EOF */
	    EndPagePrinter(hprinter);
	    EndDocPrinter(hprinter);
	    ClosePrinter(hprinter);
	}
	else {
	    /* Error */
	    AbortPrinter(hprinter);
	}
    }
    close(fd);
}
开发者ID:MasterPlexus,项目名称:vendor_goldenve,代码行数:59,代码来源:gp_msprn.c

示例11: apc_prn_setup

Bool
apc_prn_setup( Handle self)
{
   void * lph;
   LONG sz, ret;
   DEVMODE * dm;
   HWND who = GetActiveWindow();
   HDC dc;

   objCheck false;
   if ( !OpenPrinter( sys s. prn. ppi. pPrinterName, &lph, nil))
      apiErrRet;
   sz = DocumentProperties( nil, lph, sys s. prn. ppi. pPrinterName, nil, nil, 0);
   if ( sz <= 0) {
      apiErr;
      ClosePrinter( lph);
      return false;
   }
   dm  = ( DEVMODE * ) malloc( sz);
   if ( !dm) {
      ClosePrinter( lph);
      return false;
   }

   sys s. prn. ppi. pDevMode-> dmFields = -1;
   ret = DocumentProperties( hwnd_to_view( who) ? who : nil, lph, sys s. prn. ppi. pPrinterName,
       dm, sys s. prn. ppi. pDevMode, DM_IN_BUFFER|DM_IN_PROMPT|DM_OUT_BUFFER);
   ClosePrinter( lph);
   if ( ret != IDOK) {
      free( dm);
      return false;
   }
   free( sys s. prn. ppi. pDevMode);
   sys s. prn. ppi. pDevMode = dm;

   if ( !( dc = prn_info_dc( self))) return false;
   sys res.      x = ( float) GetDeviceCaps( dc, LOGPIXELSX);
   sys res.      y = ( float) GetDeviceCaps( dc, LOGPIXELSY);
   sys lastSize. x = GetDeviceCaps( dc, HORZRES);
   sys lastSize. y = GetDeviceCaps( dc, VERTRES);
   if ( !DeleteDC( dc)) apiErr;

   return true;
}
开发者ID:Absolight,项目名称:Prima,代码行数:44,代码来源:dev.c

示例12: main

int main (int argc, char* argv[])
{
	
	HANDLE			printer;
	DWORD			i, status, needed, returned;
	PRINTER_ENUM_VALUES	*buffer = NULL;


	if (argc < 2)
	{
		fprintf (stderr, "useage: %s <printername>\n", argv[0]);
		exit (-1);
	}

	/* open the server */
	if (!OpenPrinter (argv[1], &printer, NULL))
		PrintLastError();
	else
		printf ("Printer [%s] opened successfully.\n\n", argv[1]);


	needed = returned = 0;
	status = EnumPrinterDataEx(printer, ENUM_KEY_NAME, (LPBYTE)buffer, 0, &needed, &returned);
	if (status == ERROR_MORE_DATA)
	{
		if ((buffer = malloc(needed)) == NULL)
		{
			fprintf (stderr, "Unable to malloc enough space for [%d] bytes\n", needed);
			exit (-1);
		}

		status = EnumPrinterDataEx(printer, ENUM_KEY_NAME, (LPBYTE)buffer, needed, &needed, &returned);
		if (status == ERROR_SUCCESS)
		{
			printf ("Printer Enum Values :\n");
			for (i=0; i<returned; i++)
			{
				print_printer_enum_values (&buffer[i]);
				printf ("\n");
			}
		}
		free (buffer);
	}
	else if (status != ERROR_SUCCESS)
		PrintLastError();


	/* close the server */
	if (!ClosePrinter(printer))
		PrintLastError();
	else
		printf ("Printer [%s] closed successfully.\n", argv[1]);

	return 0;

}
开发者ID:Coffeedude,项目名称:slag,代码行数:56,代码来源:EnumPrinterDataEx.c

示例13: DeleteShare

bool DeleteShare(UserManager *panel,bool selection)
{
  bool res=false;
  CFarPanelSelection sp((HANDLE)panel,selection);
  if(sp.Number())
  {
    TCHAR warning[TINY_BUFFER];
    if(sp.Number()==1)
    {
      TCHAR Truncated[MAX_PATH];
      _tcscpy(Truncated,sp[0].FileName);
      FSF.TruncPathStr(Truncated,50);
      FSF.sprintf(warning,GetMsg(mDelOne),Truncated);
    }
    else
      FSF.sprintf(warning,GetMsg(mDelShareN+NumberType(sp.Number())),sp.Number());
    const TCHAR *MsgItems[]={GetMsg(mButtonDelete),warning,GetMsg(mButtonDelete),GetMsg(mButtonCancel)};
    if(!Info.Message(&MainGuid,&DelShareMessageGuid,0,NULL,MsgItems,sizeof(MsgItems)/sizeof(MsgItems[0]),2))
    {
      res=true;
      for(int i=0;i<sp.Number();i++)
        if(panel->level==levelPrinterShared)
        {
          HANDLE printer; PRINTER_DEFAULTSW defaults; PRINTER_INFO_2W *data=NULL;
          memset(&defaults,0,sizeof(defaults));
          defaults.DesiredAccess=PRINTER_ALL_ACCESS;
          if(OpenPrinterW(panel->hostfile,&printer,&defaults))
          {
            DWORD Needed;
            if(!GetPrinterW(printer,2,NULL,0,&Needed))
            {
              if(GetLastError()==ERROR_INSUFFICIENT_BUFFER)
              {
                data=(PRINTER_INFO_2W *)malloc(Needed);
                if(data)
                {
                  if(GetPrinterW(printer,2,(PBYTE)data,Needed,&Needed))
                  {
                    data->Attributes&=~PRINTER_ATTRIBUTE_SHARED;
                    if(SetPrinterW(printer,2,(PBYTE)data,0)) res=true;
                  }
                  free(data); data=NULL;
                }
              }
            }
            ClosePrinter(printer);
          }
        }
        else if(sp[i].UserData.FreeData)
        {
          NetShareDel(panel->computer_ptr,GetWideNameFromUserData(sp[i].UserData.Data),0);
        }
    }
  }
  return res;
}
开发者ID:Maximus5,项目名称:evil-programmers,代码行数:56,代码来源:um_dels.cpp

示例14: getDefaultDevmodeC

void getDefaultDevmodeC(char *printSetup, LPHANDLE phPrinter,  char **device)
{
	int		size,r1;

	size		= ((int*)printSetup)[0];
	printSetup	+=4;
	r1 = DocumentProperties(NULL,phPrinter,((char*)device)+4,
							(DEVMODE*)printSetup,NULL,DM_OUT_BUFFER);
	ClosePrinter(phPrinter);
}
开发者ID:ygmpkk,项目名称:house,代码行数:10,代码来源:cprinter_121.c

示例15: printer_finish_job

void printer_finish_job(printer_job *pj)
{
    if (!pj)
	return;

    EndPagePrinter(pj->hprinter);
    EndDocPrinter(pj->hprinter);
    ClosePrinter(pj->hprinter);
    sfree(pj);
}
开发者ID:rdebath,项目名称:sgt,代码行数:10,代码来源:printing.c


注:本文中的ClosePrinter函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。