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 6130241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:50:07+00:00 2026-05-23T16:50:07+00:00

There are few question from the following code which i came across here :

  • 0

There are few question from the following code which i came across here:

// RawDataToPrinter - sends binary data directly to a printer 
//  
// szPrinterName: NULL-terminated string specifying printer name 
// lpData:        Pointer to raw data bytes 
// dwCount        Length of lpData in bytes 
//  
// Returns: TRUE for success, FALSE for failure. 
//  
BOOL RawDataToPrinter(LPTSTR szPrinterName, LPBYTE lpData, DWORD dwCount)
{
    BOOL     bStatus = FALSE;
    HANDLE     hPrinter = NULL;
    DOC_INFO_1 DocInfo;
    DWORD      dwJob = 0L;
    DWORD      dwBytesWritten = 0L;

    // Open a handle to the printer. 
    bStatus = OpenPrinter( szPrinterName, &hPrinter, NULL );  // question 1
    if (bStatus) {
        // Fill in the structure with info about this "document." 
        DocInfo.pDocName = (LPTSTR)_T("My Document");  // question 2
        DocInfo.pOutputFile = NULL;                 // question 3
        DocInfo.pDatatype = (LPTSTR)_T("RAW");   // question 4

        // Inform the spooler the document is beginning. 
        dwJob = StartDocPrinter( hPrinter, 1, (LPBYTE)&DocInfo );  // question 5
        if (dwJob > 0) {
            // Start a page. 
            bStatus = StartPagePrinter( hPrinter );
            if (bStatus) {
                // Send the data to the printer. 
                bStatus = WritePrinter( hPrinter, lpData, dwCount, &dwBytesWritten);
                EndPagePrinter (hPrinter);
            }
            // Inform the spooler that the document is ending. 
            EndDocPrinter( hPrinter );
        }
        // Close the printer handle. 
        ClosePrinter( hPrinter );
    }
    // Check to see if correct number of bytes were written. 
    if (!bStatus || (dwBytesWritten != dwCount)) {
        bStatus = FALSE;
    } else {
        bStatus = TRUE;
    }
    return bStatus;
}

Please look for the question number in comments

Question 1

  • when i have set hPrinter = null then what is meant by &hPrinter ?

Question 2

  • what does (LPTSTR)_T denote ? (see T )

Question 3

  • What does null here denote ?

Question 4

  • What does RAW mean ( what type of data it is ? ) ?

Question 5

  • What does 1 denote here ?
  • 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-05-23T16:50:07+00:00Added an answer on May 23, 2026 at 4:50 pm
    1. &hPrinter is the address of the hPrinter variable. You need to pass it so the OpenPrinter function can write in it the actual handle to the printer.

    2. _T takes your character string and converts it to the proper ANSI (8bits/character) or Unicode (16bits/character) representation based on your compilation settings. Basically it’s a macro that either expands to nothing (ANSI) or L (Unicode) plus the actual string.

    3. Here where, in the code? NULL is a macro that expands to (basically) 0. It’s used to provide a decent default value.

    4. Raw data is exactly what it sounds, raw data. It’s not structured in any way, it’s just a soup of bytes you pass to a (usually) device.

    5. From http://msdn.microsoft.com/en-us/library/dd145115(v=vs.85).aspx:

      The version of the structure to which pDocInfo points. This value must be 1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is not a technical question, but given that there are a few iPhone
This is more of a beginner's question. Say I have the following code: library(multicore)
I received this code from one of those nice people here who are willing
From reading a few questions and answers here, it seems that a telnet stream
i have an ActiveX. ActiveX means: Internet Explorer native binary code running from a
There are a few questions on SO already regarding LINQ pivots and while a
There are a few questions about configuring Apache for local development, such as this
A few questions on MS Access databases - Size: Are there limits to the
I know there are already a few questions regarding recommendations for C++ unit test
So, there seems to be a few questions asking about removing files/directories matching certain

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.