Using RedMon environment variables to get original Document Name 
Author Message
 Using RedMon environment variables to get original Document Name

The following snippet of code for Redmon can retrieve the document
name (or something hopefully relevant).

CString GetJobDocument( void )
{
        DWORD dwJob = atoi( getenv("REDMON_JOB") );
        HANDLE hPrinter = NULL;
        PRINTER_DEFAULTS *pd = NULL;

        pd = (PRINTER_DEFAULTS*)GlobalAlloc(GPTR, sizeof(PRINTER_DEFAULTS) );
        ZeroMemory( pd, sizeof(PRINTER_DEFAULTS));

        pd->DesiredAccess = PRINTER_ACCESS_USE;
        pd->pDatatype = NULL;
        pd->pDevMode = NULL;

        if( !OpenPrinter( getenv("REDMON_PRINTER"), &hPrinter, pd ) )
        {
                return "";
        }

        // Second, GetJob
        DWORD dwNeeded = 0;
        GetJob(hPrinter, dwJob, 1, NULL, 0, &dwNeeded);

        JOB_INFO_1 *ji = (JOB_INFO_1*)GlobalAlloc(GPTR, dwNeeded + 1 );
        ZeroMemory( ji, dwNeeded + 1);

        GetJob(hPrinter, dwJob, 1, (LPBYTE)ji, dwNeeded, &dwNeeded);
        CString csToReturn = ji->pDocument;

        return csToReturn;

Quote:
}

This should do the trick.


Tue, 18 Jan 2005 02:12:16 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Looking for someone using Ghostscript/Redmon in Openstep/yellowbox environments

2. Looking for someone using Ghostscript/Redmon in Openstep/yellowbox environments

3. Re : looking for someone using Ghostscript/Redmon in Openstep/yellowbox environments

4. Getting Environment Variables

5. Getting Environment Variables

6. Getting NT username environment variable

7. getting an environment variable

8. Creating and environment variable and using it in the same cmd window

9. getting object instance variable name.

10. Creating and environment variable and using it in the same cmd window

11. Using Environment Variables

12. Using Environment Variables

 

 
Powered by phpBB® Forum Software