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

📄 intrface.cpp

📁 WINDDK XP/2003 Microsoft Bitmap Printer Driver Sample Decompress to src in WINDDK and "build -cZ
💻 CPP
📖 第 1 页 / 共 4 页
字号:
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//
//  Copyright  1998 - 2003  Microsoft Corporation.  All Rights Reserved.
//
//  FILE:   Intrface.cpp
//    
//
//  PURPOSE:  Interface for User Mode COM Customization DLL.
//
//
//  Functions:
//          IPrintOemUni2 interface functions
//          COemCF class factory
//          Registration functions: DllCanUnloadNow, DllGetClassObject
//
//
//
//
//  PLATFORMS:  Windows XP, Windows Server 2003
//
//
//  History: 
//          06/26/03    xxx created.
//
//

#include "precomp.h"
#include <INITGUID.H>
#include <PRCOMOEM.H>

#include "bitmap.h"
#include "debug.h"
#include "intrface.h"

// ==================================================================
// Internal Globals
//
static long g_cComponents;      // Count of active components
static long g_cServerLocks;     // Count of locks
//
// ==================================================================

////////////////////////////////////////////////////////////////////////////////
//
// COemUni2 body
//
COemUni2::COemUni2() 
{
    m_cRef = 1;

    // Increment COM component count.
    InterlockedIncrement(&g_cComponents);

    InterlockedIncrement(&m_cRef);
    m_pOEMHelp = NULL; 

}

COemUni2::~COemUni2()
{
    // Make sure that helper interface is released.
    if(NULL != m_pOEMHelp)
    {
        m_pOEMHelp->Release();
        m_pOEMHelp = NULL;
    }

    // If this instance of the object is being deleted, then the reference 
    // count should be zero.
    assert(0 == m_cRef);
}

HRESULT __stdcall
COemUni2::
QueryInterface(
    const IID&  iid, 
    void**      ppv
    )
{    
    OEMDBG(DBG_VERBOSE, L"COemUni2::QueryInterface() entry.");
    
    if (iid == IID_IUnknown)
    {
        *ppv = static_cast<IUnknown*>(this); 
        VERBOSE(DLLTEXT("COemUni2::QueryInterface IUnknown.\r\n")); 
    }
    else if (iid == IID_IPrintOemUni2)
    {
        VERBOSE(DLLTEXT("COemUni2::QueryInterface IPrintOemUni2.\r\n")); 

        *ppv = static_cast<IPrintOemUni2*>(this);
    }
    else
    {
        WARNING(DLLTEXT("COemUni2::QueryInterface NULL. Returning E_NOINTERFACE.\r\n")); 

        *ppv = NULL;
        return E_NOINTERFACE;
    }
    reinterpret_cast<IUnknown*>(*ppv)->AddRef();
    return S_OK;
}

ULONG __stdcall
COemUni2::
AddRef(
    VOID
    )
{
    OEMDBG(DBG_VERBOSE, L"COemUni2::AddRef() entry.");

    return InterlockedIncrement(&m_cRef);
}

ULONG __stdcall
COemUni2::
Release(
    VOID
    ) 
{
    OEMDBG(DBG_VERBOSE, L"COemUni2::Release() entry.");
    ULONG   cRef    = InterlockedDecrement(&m_cRef);

    if (cRef == 0)
    {
        delete this;
        return 0;
    }
    return cRef;
}

HRESULT __stdcall
COemUni2::
CommandCallback(
    PDEVOBJ     pdevobj,
    DWORD       dwCallbackID,
    DWORD       dwCount,
    PDWORD      pdwParams,
    OUT INT     *piResult
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::CommandCallback

    The IPrintOemUni::CommandCallback method is used 
    to provide dynamically generated printer commands 
    for Unidrv-supported printers.
    
    Please refer to DDK documentation for more details.

Arguments:

    pdevobj - pointer to a DEVOBJ structure. 
    dwCallbackID - value representing the printer command's 
        *CallbackID attribute in the printer's generic printer 
        description (GPD) file.  
    dwCount - value representing the number of elements 
        in the array pointed to by pdwParams. Can be 0. 
    pdwParams - pointer to an array of DWORD-sized parameters 
        containing values specified by the printer commands 
        *Params attribute in the printer's GPD file. Can be NULL. 
    piResult - Receives a method-supplied result value.

Return Value:

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


--*/

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

    *piResult = 0;

    return S_OK;
}

HRESULT __stdcall
COemUni2::
Compression(
    PDEVOBJ     pdevobj,
    PBYTE       pInBuf,
    PBYTE       pOutBuf,
    DWORD       dwInLen,
    DWORD       dwOutLen,
    OUT INT     *piResult
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::Compression

    The IPrintOemUni::Compression method can be used 
    with Unidrv-supported printers to provide a customized 
    bitmap compression method.
    
    Please refer to DDK documentation for more details.

Arguments:

    pdevobj - pointer to a DEVOBJ structure. 
    pInBuf - pointer to input scan line data. 
    pOutBuf - pointer to an output buffer to receive 
        compressed scan line data. 
    dwInLen - length of the input data. 
    dwOutLen - length of the output buffer. 
    piResult - Receives a method-supplied result value. If the 
        operation succeeds, this value should be the number 
        of compressed bytes, which must not be larger than 
        the value received for dwOutLen. If an error occurs, 
        or if the method cannot compress, the result value 
        should be -1. 

Return Value:

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


--*/

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

    return E_NOTIMPL;
}

HRESULT __stdcall
COemUni2::
DevMode(
    DWORD           dwMode,
    POEMDMPARAM pOemDMParam
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::DevMode

    The IPrintOemUni::DevMode method, provided by 
    rendering plug-ins for Unidrv, performs operations 
    on private DEVMODE members.

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

Arguments:

    dwMode - caller-supplied constant. Refer to the docs 
        for more information. 
    pOemDMParam - pointer to an OEMDMPARAM structure.

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 


--*/

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

    DBG_OEMDMPARAM(DBG_VERBOSE, L"pOemDMParam", pOemDMParam);

    return hrOEMDevMode(dwMode, pOemDMParam);

    return S_OK;
}

HRESULT __stdcall
COemUni2::
DisableDriver(
    VOID
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::DisableDriver
    
    The IPrintOemUni::DisableDriver method allows 
    a rendering plug-in for Unidrv to free resources 
    that were allocated by the plug-in's 
    IPrintOemUni::EnableDriver method.

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

Arguments:

    VOID

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 


--*/

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

    OEMDisableDriver();     // implemented in enable.cpp

    // Release reference to Printer Driver's interface.
    //
    if (this->m_pOEMHelp)
    {
        this->m_pOEMHelp->Release();
        this->m_pOEMHelp = NULL;
    }

    return S_OK;
}

HRESULT __stdcall
COemUni2::
DisablePDEV(
    PDEVOBJ     pdevobj
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::DisablePDEV
    
    The IPrintOemUni::DisablePDEV method allows a rendering 
    plug-in for Unidrv to delete the private PDEV structure that 
    was allocated by its IPrintOemUni::EnablePDEV method.

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

Arguments:

    pdevobj - pointer to a DEVOBJ structure.

Return Value:

    S_OK The operation succeeded. 
    E_FAIL The operation failed. 


--*/

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

    OEMDisablePDEV(pdevobj);

    return S_OK;
}

HRESULT __stdcall
COemUni2::
DownloadCharGlyph(
    PDEVOBJ         pdevobj,
    PUNIFONTOBJ     pUFObj,
    HGLYPH          hGlyph,
    PDWORD          pdwWidth,
    OUT DWORD       *pdwResult
    ) 

/*++

Routine Description:

    Implementation of IPrintOemUni::DownloadCharGlyph

    The IPrintOemUni::DownloadCharGlyph method enables a 
    rendering plug-in for Unidrv to send a character glyph for 
    a specified soft font to the printer.
    
    Please refer to DDK documentation for more details.

Arguments:

    pdevobj - pointer to a DEVOBJ structure. 
    pUFObj - pointer to a UNIFONTOBJ structure. 
    hGlyph - glyph handle. 
    pdwWidth - pointer to receive the method-supplied width of the character. 
    pdwResult - Receives a method-supplied value representing the amount 
        of printer memory, in bytes, required to store the character glyph. 
        If the operation fails, the returned value should be zero.

Return Value:

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


--*/

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

    return E_NOTIMPL;
}

HRESULT __stdcall
COemUni2::
DownloadFontHeader(
    PDEVOBJ         pdevobj,
    PUNIFONTOBJ     pUFObj,
    OUT DWORD       *pdwResult
    ) 

/*++

Routine Description:

    Implementation of IPrintOemUni::DownloadFontHeader

    The IPrintOemUni::DownloadFontHeader method allows a 
    rendering plug-in for Unidrv to send a font's header 
    information to a printer.
    
    Please refer to DDK documentation for more details.

Arguments:

    pdevobj - pointer to a DEVOBJ structure. 
    pUFObj - pointer to a UNIFONTOBJ structure. 
    pdwResult - Receives a method-supplied value representing the amount 
        of printer memory, in bytes, required to store the font header 
        information. If the operation fails, the returned value should be zero.

Return Value:

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


--*/

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

    return E_NOTIMPL;
}

HRESULT __stdcall
COemUni2::
DriverDMS(
    PVOID       pDevObj,
    PVOID       pBuffer,
    DWORD       cbSize,
    PDWORD      pcbNeeded
    )

/*++

Routine Description:

    Implementation of IPrintOemUni::DriverDMS

⌨️ 快捷键说明

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