Esempio n. 1
0
BOOL
bRegUpdate(
    HANDLE       hPrinter,          /* Access to registry */
    EXTDEVMODE  *pEDM,              /* The stuff to go */
    PWSTR        pwstrModel,        /* Model name, if not NULL */
    PRASDDUIINFO pRasdduiInfo       /* Global data access */
)
{
    /*
     *   Nothing especially exciting.  Simply rummage through the various
     * boxes and extract whatever information is there.  Then save this
     * data away in the registry.
     */

    int     iI;                 /* Loop index */

    DWORD   dwRet = TRUE;

    BOOL    bRet;               /* Returns TRUE only for success */
    DWORD dwErrCode = 0;  /* Error Code from SetPrinterData */

    bRet = TRUE;

    /*   Start with model name, if this is present  */

    if( pwstrModel )
    {
        /*   The model name is used for validity checking */
        if( dwErrCode = SetPrinterData( hPrinter, PP_MODELNAME, REG_SZ, (BYTE *)pwstrModel,
                              sizeof( WCHAR ) * (1 + wcslen( pwstrModel )) ) )
        {
#if DBG
        DbgPrint( "rasddui!SetPrinterData (model name) fails, error code = %ld\n", dwErrCode );
#endif

            return  FALSE;
        }
    }

    /* Write the new Keys. */

    if ( ( bRet = ((bRegUpdateTrayFormTable (hPrinter, pRasdduiInfo))   &&
                   (bRegUpdateMemory (hPrinter, pEDM, pRasdduiInfo))    &&
                   (bRegUpdateRasddFlags (hPrinter, pEDM))&&
                   (bRegUpdateFontCarts (hPrinter, pEDM, pRasdduiInfo)) ) ) )
        ;


    return  bRet ;                /* TRUE for success */
}
Esempio n. 2
0
////////////////////////////////////////////////////////////////////////////////
//
// OptItems call back for OEM printer property UI.
//
LONG APIENTRY OEMPrinterUICallBack(PCPSUICBPARAM pCallbackParam, POEMCUIPPARAM pOEMUIParam)
{
    LONG    lReturn = CPSUICB_ACTION_NONE;

    switch(pCallbackParam->Reason)
    {
        case CPSUICB_REASON_APPLYNOW:
            {
                DWORD   dwDriverValue = pOEMUIParam->pOEMOptItems[0].Sel;

                // Store OptItems state in printer data.
                SetPrinterData(pOEMUIParam->hPrinter, OEMUI_VALUE, REG_DWORD, (PBYTE) &dwDriverValue, sizeof(DWORD));
            }
            break;

        default:
            break;
    }

    return lReturn;
}
Esempio n. 3
0
BOOL
SavePrinterRegistryData(
    HANDLE  hPrinter,
    PVOID   pData,
    PWSTR   pRegKey
    )

/*++

Routine Description:

    Save printer data to the registry

Arguments:

    hPrinter - Handle to the printer object
    pData - Points to printer data to be saved
    pRegKey - Specifies the registry key name

Return Value:

    TRUE if successful, FALSE if there is an error

Note:

    We assume the first WORD of the printer data contains the size information.

--*/

{
    if (SetPrinterData(hPrinter, pRegKey, REG_BINARY, pData, *((PWORD) pData)) == ERROR_SUCCESS)
        return TRUE;

    Error(("Couldn't save printer data: %ws\n", pRegKey));
    return FALSE;
}
Esempio n. 4
0
BOOL
AddFormsToDataBase(
    PPRINTERINFO    pPI,
    BOOL            DeleteFirst
    )

/*++

Routine Description:

    This function add driver supports forms to the data base

Arguments:

    pPI - Pointer to the PRINTERINFO


Return Value:

    BOOLEAN


Author:

    09-Dec-1993 Thu 22:38:27 created  

    27-Apr-1994 Wed 19:18:58 updated  
        Fixed bug# 13592 which printman/spooler did not call ptrprop first but
        docprop so let us into unknown form database state,

Revision History:


--*/

{
    WCHAR       wName[CCHFORMNAME + 2];
    BOOL        bRet;
    LONG        i;
    DWORD       Type;


    Type = REG_SZ;

    if ((GetPrinterData(pPI->hPrinter,
                        wszModel,
                        &Type,
                        (LPBYTE)wName,
                        sizeof(wName),
                        &i) == ERROR_SUCCESS) &&
        (wcscmp(pPI->PlotDM.dm.dmDeviceName, wName))) {

        PLOTDBG(DBG_FORMS, ("Already added forms to the data base for %s",
                                                pPI->PlotDM.dm.dmDeviceName));
        return(TRUE);
    }

    //
    // Find out if we have permission to do this
    //

    if (SetPrinterData(pPI->hPrinter,
                       wszModel,
                       REG_SZ,
                       (LPBYTE)pPI->PlotDM.dm.dmDeviceName,
                       (wcslen(pPI->PlotDM.dm.dmDeviceName) + 1) *
                                            sizeof(WCHAR)) == ERROR_SUCCESS) {

        PFORMSRC    pFS;
        FORM_INFO_1 FI1;

        //
        // We have permission to update the registry so do it now
        //

        pPI->Flags |= PIF_UPDATE_PERMISSION;

        PLOTDBG(DBG_PERMISSION,
                ("!!! MODEL NAME: '%s' not Match, Re-installed Form Database",
                                            pPI->PlotDM.dm.dmDeviceName));

        //
        // Add the driver supportes forms to the system spooler data base if
        // not yet done so
        //

        FI1.pName = wName;

        for (i = 0, pFS = (PFORMSRC)pPI->pPlotGPC->Forms.pData;
             i < (LONG)pPI->pPlotGPC->Forms.Count;
             i++, pFS++) {

            //
            // We will only add the non-roll paper forms
            //

            if (pFS->Size.cy) {

                str2Wstr(wName, CCHOF(wName), pFS->Name);

                //
                // Firstable we will delete the same name form in the data
                // base first, this will ensure we have our curent user defined
                // form can be installed
                //

                if (DeleteFirst) {

                    DeleteForm(pPI->hPrinter, wName);
                }

                FI1.Size                 = pFS->Size;
                FI1.ImageableArea.left   = pFS->Margin.left;
                FI1.ImageableArea.top    = pFS->Margin.top;
                FI1.ImageableArea.right  = FI1.Size.cx - pFS->Margin.right;
                FI1.ImageableArea.bottom = FI1.Size.cy - pFS->Margin.bottom;

                PLOTDBG(DBG_FORMS, (
                        "AddForm: %s-[%ld x %ld] (%ld, %ld)-(%ld, %ld)",
                        FI1.pName, FI1.Size.cx, FI1.Size.cy,
                        FI1.ImageableArea.left, FI1.ImageableArea.top,
                        FI1.ImageableArea.right,FI1.ImageableArea.bottom));

                FI1.Flags = FORM_PRINTER;

                if ((!AddForm(pPI->hPrinter, 1, (LPBYTE)&FI1))  &&
                    (GetLastError() != ERROR_FILE_EXISTS)       &&
                    (GetLastError() != ERROR_ALREADY_EXISTS)) {

                    bRet = FALSE;
                    PLOTERR(("AddFormsToDataBase: AddForm(%s) failed, [%ld]",
                                        wName, GetLastError()));
                }
            }
        }

        return(TRUE);

    } else {

        pPI->Flags &= ~PIF_UPDATE_PERMISSION;

        PLOTDBG(DBG_PERMISSION, ("AddFormsToDataBase(): NO UPDATE PERMISSION"));

        return(FALSE);
    }
}
Esempio n. 5
0
BOOL
AddDriverForms(
    HANDLE  hPrinter,
    PMPD    pmpd
    )

/*++

Routine Description:

    Add printer-specific forms to the global forms database

Arguments:

    hPrinter - Identifies the printer being upgraded
    pmpd - Points to printer description data

Return Value:

    TRUE if successful, FALSE if there is an error

--*/

{
    PFEATURE    pFeature;
    PPAPERSIZE  pPaperSize;
    WORD        index;
    DWORD       type, value, cbNeeded;
    FORM_INFO_1 formInfo;

    //
    // Check if we've added printer-specific forms already
    //

    if (GetPrinterData(hPrinter,
                       REGSTR_FORMSADDED,
                       &type,
                       (PBYTE) &value,
                       sizeof(value),
                       &cbNeeded) == ERROR_SUCCESS)
    {
        return TRUE;
    }

    Verbose(("Adding printer-specific forms\n"));

    //
    // Call AddForm for every printer specific form
    //

    formInfo.Flags = 0;
    pFeature = MpdPaperSizes(pmpd);
    
    for (index=0; index < pFeature->count; index++) {

        pPaperSize = FindIndexedSelection(pFeature, index);

        //
        // Form name, size, and imageable area
        //

        formInfo.pName = GetXlatedName(pPaperSize);
        formInfo.Size = pPaperSize->size;

        formInfo.ImageableArea.left = formInfo.ImageableArea.top = 0;
        formInfo.ImageableArea.right = formInfo.Size.cx;
        formInfo.ImageableArea.bottom = formInfo.Size.cy;

        AddForm(hPrinter, 1, (PBYTE) &formInfo);
    }

    //
    // Indicate we have successfully added printer specific forms
    //

    value = 1;
    SetPrinterData(hPrinter, REGSTR_FORMSADDED, REG_DWORD, (PBYTE) &value, sizeof(value));
    
    return TRUE;
}