⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intrface.cpp

📁 WINDDK XP/2003 Microsoft Bitmap Printer Driver Sample Decompress to src in WINDDK and "build -cZ
💻 CPP
📖 第 1 页 / 共 4 页
字号:
    The IPrintOemUni::DriverDMS method allows a rendering 
    plug-in for Unidrv to indicate that it uses a device-managed 
    drawing surface instead of the default GDI-managed surface.

    A rendering plug-in for Unidrv MUST implement the 
    IPrintOemUni::DriverDMS method.
    
    Please refer to DDK documentation for more details. For general info
    on device managed surfaces and how to handle them, please refer to 
    the section titled "Handling Device-Managed Surfaces". 

Arguments:

    pDevObj - pointer to a DEVOBJ structure. 
    pBuffer - pointer to a buffer to receive method-specified flags.
    cbSize - size, in bytes, of the buffer pointed to by pBuffer. 
    pcbNeeded - pointer to a location to receive the required 
        minimum pBuffer size.

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 


--*/

{
    OEMDBG(DBG_VERBOSE, L"COemUni2::DriverDMS() entry.");

    return E_NOTIMPL;
}

HRESULT __stdcall
COemUni2::
EnableDriver(
    DWORD               dwDriverVersion,
    DWORD               cbSize,
    PDRVENABLEDATA      pded
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::EnableDriver
    
    The IPrintOemUni::EnableDriver method allows a rendering 
    plug-in for Unidrv to hook out some graphics DDI functions.

    A rendering plug-in for Unidrv MUST implement the 
    IPrintOemUni::EnableDriver method.
    
    Please refer to DDK documentation for more details.

Arguments:

    DriverVersion - interface version number. This value is 
        defined by PRINTER_OEMINTF_VERSION, in printoem.h. 
    cbSize - size, in bytes, of the structure pointed to by pded. 
    pded - pointer to a DRVENABLEDATA structure.

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 


--*/

{
    OEMDBG(DBG_VERBOSE, L"COemUni2::EnableDriver() entry.");

    OEMEnableDriver(dwDriverVersion, cbSize, pded);     // Implemented in enable.cpp

    // Even if nothing is done, need to return S_OK so 
    // that DisableDriver() will be called, which releases
    // the reference to the Printer Driver's interface.
    //
    return S_OK;
}

HRESULT __stdcall
COemUni2::
EnablePDEV(
    PDEVOBJ             pdevobj,
    PWSTR               pPrinterName,
    ULONG               cPatterns,
    HSURF               *phsurfPatterns,
    ULONG               cjGdiInfo,
    GDIINFO             *pGdiInfo,
    ULONG               cjDevInfo,
    DEVINFO             *pDevInfo,
    DRVENABLEDATA       *pded,
    OUT PDEVOEM     *pDevOem
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::EnablePDEV
    
    The IPrintOemUni::EnablePDEV method allows a rendering 
    plug-in for Unidrv to create its own PDEV structure.

    A rendering plug-in for Unidrv MUST implement the 
    IPrintOemUni::EnablePDEV method.
    
    Please refer to DDK documentation for more details.

Arguments:

    pdevobj - pointer to a DEVOBJ structure. 
    pPrinterName - pointer to a text string representing the 
        logical address of the printer. 
    cPatterns - value representing the number of HSURF-typed 
        surface handles contained in the buffer pointed to by 
        phsurfPatterns. 
    phsurfPatterns - pointer to a buffer that is large enough to 
        contain cPatterns number of HSURF-typed surface handles. 
        The handles represent surface fill patterns. 
    cjGdiInfo - value representing the size of the structure pointed 
        to by pGdiInfo. 
    pGdiInfo - pointer to a GDIINFO structure. 
    cjDevInfo - value representing the size of the structure pointed 
        to by pDevInfo. 
    pDevInfo - pointer to a DEVINFO structure. 
    pded - pointer to a DRVENABLEDATA structure containing the 
        addresses of the printer driver's graphics DDI hooking functions. 
    pDevOem - Receives a method-supplied pointer to a private PDEV structure.

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 

    If the operation fails, the method should call SetLastError to set an error code.


--*/

{
    OEMDBG(DBG_VERBOSE, L"COemUni2::EnablePDEV() entry.");

    *pDevOem = OEMEnablePDEV(pdevobj, pPrinterName, cPatterns,  phsurfPatterns,
                            cjGdiInfo, pGdiInfo, cjDevInfo, pDevInfo, pded);

    return (NULL != *pDevOem ? S_OK : E_FAIL);
}

HRESULT __stdcall
COemUni2::
FilterGraphics(
    PDEVOBJ     pdevobj,
    PBYTE       pBuf,
    DWORD       dwLen
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::FilterGraphics

    The IPrintOemUni::FilterGraphics method can be used with 
    Unidrv-supported printers to modify scan line data and send 
    it to the spooler.
    
    Please refer to DDK documentation for more details.

Arguments:

    pdevobj - pointer to a DEVOBJ structure. 
    pBuf - pointer to a buffer containing scan line data to be printed. 
    dwLen - value representing the length, in bytes, of the data 
        pointed to by pBuf.

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 
    E_NOTIMPL The method is not implemented. 


--*/

{
    DWORD dwResult;
    
    OEMDBG(DBG_VERBOSE, L"COemUni2::FilterGraphics() entry.");

    m_pOEMHelp->DrvWriteSpoolBuf(pdevobj, pBuf, dwLen, &dwResult);
    
    if (dwResult == dwLen)
        return S_OK;
    else
        return S_FALSE;
}

HRESULT __stdcall
COemUni2::
GetImplementedMethod(
    PSTR pMethodName
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::GetImplementedMethod
    
    The IPrintOemUni::GetImplementedMethod method is used by 
    Unidrv to determine which IPrintOemUni interface methods 
    have been implemented by a rendering plug-in.

    A rendering plug-in for Unidrv MUST implement the 
    IPrintOemUni::GetImplemented method.
    
    Please refer to DDK documentation for more details.

Arguments:

    pMethodName - pointer to a string representing the name of an 
        IPrintOemUni interface method, such as "ImageProcessing" 
        for IPrintOemUni::ImageProcessing or "FilterGraphics" for 
        IPrintOemUni::FilterGraphics.

Return Value:

    S_OK The operation succeeded (the specified method is implemented). 
    S_FALSE The operation failed (the specified method is not implemented). 
 

--*/

{
    HRESULT Result = S_FALSE;

    OEMDBG(DBG_VERBOSE, L"COemUni2::GetImplementedMethod() entry.");
    VERBOSE(TEXT("\tCOemUni2::%hs: "), pMethodName);

    // Unidrv only calls GetImplementedMethod for optional
    // methods.  The required methods are assumed to be
    // supported.

    // Return S_OK for supported function (i.e. implemented),
    // and S_FALSE for functions that aren't supported (i.e. not implemented).
    switch (*pMethodName)
    {
        case 'C':
            if (!strcmp(NAME_CommandCallback, pMethodName))
            {
                Result = S_OK;
            }
            else if (!strcmp(NAME_Compression, pMethodName))
            {
                Result = S_FALSE;
            }
            break;
        case 'D':
            if (!strcmp(NAME_DownloadCharGlyph, pMethodName))
            {
                Result = S_FALSE;
            }
            else if (!strcmp(NAME_DownloadFontHeader, pMethodName))
            {
                Result = S_FALSE;
            }
            break;
        case 'F':
            if (!strcmp(NAME_FilterGraphics, pMethodName))
            {
                Result = S_OK;
            }
            break;
        case 'H':
            if (!strcmp(NAME_HalftonePattern, pMethodName))
            {
                Result = S_FALSE;
            }
            break;
        case 'I':
            if (!strcmp(NAME_ImageProcessing, pMethodName))
            {
                Result = S_OK;
            }
            break;
        case 'M':
            if (!strcmp(NAME_MemoryUsage, pMethodName))
            {
                Result = S_FALSE;
            }
            break;
        case 'O':
            if (!strcmp(NAME_OutputCharStr, pMethodName))
            {
                Result = S_FALSE;
            }
            break;
        case 'S':
            if (!strcmp(NAME_SendFontCmd, pMethodName))
            {
                Result = S_FALSE;
            }
            break;
        case 'T':
            if (!strcmp(NAME_TextOutAsBitmap, pMethodName))
            {
                Result = S_FALSE;
            }
            else if (!strcmp(NAME_TTDownloadMethod, pMethodName))
            {
                Result = S_FALSE;
            }
            else if (!strcmp(NAME_TTYGetInfo, pMethodName))
            {
                Result = S_FALSE;
            }
            break;
        case 'W':
            if (!strcmp(NAME_WritePrinter, pMethodName))
            {
                Result = S_FALSE;
            }
            break;
    }

    VERBOSE(Result == S_OK ? TEXT("Supported\r\n") : TEXT("NOT supported\r\n"));

    return Result;
}

HRESULT __stdcall
COemUni2::
GetInfo(
    DWORD       dwMode,
    PVOID       pBuffer,
    DWORD       cbSize,
    PDWORD      pcbNeeded
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::GetInfo
    
    A rendering plug-in's IPrintOemUni::GetInfo method returns 
    identification information.

    A rendering plug-in for Unidrv MUST implement the 
    IPrintOemUni::GetInfo method.
    
    Please refer to DDK documentation for more details.

Arguments:

    dwMode - Contains one of the following caller-supplied integer constants. 
        OEMGI_GETSIGNATURE - The method must return a unique four-byte 
            identification signature. The plug-in must also place this signature 
            in OPTITEM structures, as described in the description of the 
            OEMCUIPPARAM. structure's pOEMOptItems member. 
        OEMGI_GETVERSION - The method must return the user interface 
            plug-in's version number as a DWORD. The version format is 
            developer-defined. 
    pBuffer - pointer to memory allocated to receive the information specified 
        by dwInfo. 
    cbSize - size of the buffer pointed to by pBuffer. 
    pcbNeeded - pointer to a location to receive the number of bytes written 
        into the buffer pointed to by pBuffer.

Return Value:

    S_OK The operation succeeded (the specified method is implemented). 
    S_FALSE The operation failed (the specified method is not implemented). 
 

--*/

{
    PWSTR pszTag = L"COemUni2::GetInfo entry.";
    switch(dwMode)
    {
        case OEMGI_GETSIGNATURE: pszTag = L"COemUni2::GetInfo entry. [OEMGI_GETSIGNATURE]"; break;
        case OEMGI_GETVERSION: pszTag = L"COemUni2::GetInfo entry. [OEMGI_GETVERSION]"; break;

    }
    OEMDBG(DBG_VERBOSE, pszTag);

    // Validate parameters.
    if( (NULL == pcbNeeded)
        ||
        ( (OEMGI_GETSIGNATURE != dwMode)
        &&
        (OEMGI_GETVERSION != dwMode) ) )
    {
        WARNING(DLLTEXT("COemUni2::GetInfo() exit pcbNeeded is NULL! ERROR_INVALID_PARAMETER.\r\n"));
        SetLastError(ERROR_INVALID_PARAMETER);
        return E_FAIL;
    }

    // Set expected buffer size.
    *pcbNeeded = sizeof(DWORD);

    // Check buffer size is sufficient.
    if((cbSize < *pcbNeeded) || (NULL == pBuffer))
    {
        VERBOSE(TEXT("COemUni2::GetInfo() exit insufficient buffer!\r\n"));
        SetLastError(ERROR_INSUFFICIENT_BUFFER);
        return E_FAIL;
    }

    switch(dwMode)
    {
        // OEM DLL Signature
        case OEMGI_GETSIGNATURE:
            *(PDWORD)pBuffer = OEM_SIGNATURE;
            break;

        // OEM DLL version
        case OEMGI_GETVERSION:
            *(PDWORD)pBuffer = OEM_VERSION;
            break;

        // dwMode not supported.
        default:
            // Set written bytes to zero since nothing was written.
            WARNING(DLLTEXT("COemUni2::GetInfo() exit mode not supported.\r\n"));
            *pcbNeeded = 0;
            SetLastError(ERROR_NOT_SUPPORTED);
            return E_FAIL;
    }

    VERBOSE(TEXT("COemUni2::GetInfo() exit S_OK, (*pBuffer is %#x).\r\n"), *(PDWORD)pBuffer);

    return S_OK;
}

HRESULT __stdcall
COemUni2::
HalftonePattern(
    PDEVOBJ     pdevobj,
    PBYTE       pHTPattern,
    DWORD       dwHTPatternX,
    DWORD       dwHTPatternY,
    DWORD       dwHTNumPatterns,
    DWORD       dwCallbackID,
    PBYTE       pResource,
    DWORD       dwResourceSize
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::HalftonePattern

    The IPrintOemUni::HalftonePattern method can be used with 
    Unidrv-supported printers to create or modify a halftone 
    pattern before it is used in a halftoning operation.
    
    Please refer to DDK documentation for more details.

Arguments:

    pdevobj - pointer to a DEVOBJ structure. 
    pHTPattern - pointer to a buffer to receive the method-supplied 
        halftone pattern. Buffer size, in bytes, is:
        (((dwHTPatternX * dwHTPatternY) + 3)/4) * 4 * dwHTNumPatterns. 
    dwHTPatternX - length, in pixels, of the halftone pattern, as specified 
        by the GPD file's *HTPatternSize attribute. 
    dwHTPatternY - height, in pixels, of the halftone pattern, as specified 
        by the GPD file's *HTPatternSize attribute. 
    dwHTNumPatterns - number of patterns, as specified by the GPD file's 
        *HTNumPatterns attribute. This can be 1 or 3. 
    dwCallbackID - value identifying the halftone method, as specified by 
        the GPD file's *HTCallbackID attribute. 
    pResource - pointer to a buffer containing a halftone pattern, as 
        specified by the GPD file's *rcHTPatternID attribute. This can be NULL. 
    dwResourceSize - size of the halftone pattern contained in the buffer 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -