• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            面對(duì)現(xiàn)實(shí),超越自己
            逆水行舟,不進(jìn)則退
            posts - 269,comments - 32,trackbacks - 0

            獲取驅(qū)動(dòng)相關(guān)文件列表可用DRIVER_INFO_3,GetPrinterDriver

            MSDN中解釋?zhuān)?/span>

            DRIVER_INFO_3

            The DRIVER_INFO_3 structure contains printer driver information.

            typedef struct _DRIVER_INFO_3 { 
              DWORD  cVersion; 
              LPTSTR pName; 
              LPTSTR pEnvironment; 
              LPTSTR pDriverPath; 
              LPTSTR pDataFile; 
              LPTSTR pConfigFile; 
              LPTSTR pHelpFile; 
              LPTSTR pDependentFiles; 
              LPTSTR pMonitorName; 
              LPTSTR pDefaultDataType; 
            } DRIVER_INFO_3, *PDRIVER_INFO_3; 

            Members

            cVersion
            Specifies the operating system version for which the driver was written. It can be one of the following.
            Value Meaning
            0 Driver for Windows 95/98/Me.
            2 Driver for Windows NT 4.0.
            3 Driver for Windows 2000/XP.

            pName
            Pointer to a null-terminated string that specifies the name of the driver (for example, "QMS 810").
            pEnvironment
            Pointer to a null-terminated string that specifies the environment for which the driver was written (for example, Windows NT x86, Windows IA64, Windows x64, Windows NT R4000, Windows NT Alpha_AXP, Windows 4.0, or Windows NT PowerPC).
            Note Windows IA64 is available in Windows XP, Windows XP 64-Bit Edition, Windows Server 2003, and later versions. Windows x64 is available in Windows XP Service Pack 2 (SP2), Windows XP Professional x64 Edition, Windows Server 2003 Service Pack 1 (SP1), and later versions.
            pDriverPath
            Pointer to a null-terminated string that specifies a file name or full path and file name for the file that contains the device driver (for example, "C:\DRIVERS\Pscript.dll").
            pDataFile
            Pointer to a null-terminated string that specifies a file name or a full path and file name for the file that contains driver data (for example, "C:\DRIVERS\Qms810.ppd").
            pConfigFile
            Pointer to a null-terminated string that specifies a file name or a full path and file name for the device driver's configuration dynamic-link library (for example, "C:\DRIVERS\Pscrptui.dll").
            pHelpFile
            Pointer to a null-terminated string that specifies a file name or a full path and file name for the device driver's help file.
            pDependentFiles
            Pointer to a null-terminated string that specifies the files the driver is dependent on. Each file name in the string is also terminated with a null (for example, "Pscript.dll\0Qms810.PPD\0Pscrptui.dll\0Pspcriptui.hlp\0Pstest.txt\0\0").
            pMonitorName
            Pointer to a null-terminated string that specifies a language monitor (for example, "PJL monitor"). This member can be NULL and should be specified only for printers capable of bidirectional communication.
            pDefaultDataType
            Pointer to a null-terminated string that specifies the default data type of the print job (for example, "EMF").

            Requirements

              Windows NT/2000/XP/Vista: Included in Windows NT 4.0 and later.
              Windows 95/98/Me: Included in Windows 95 and later.
              Header: Declared in Winspool.h; include Windows.h.
              Unicode: Declared as Unicode and ANSI structures.

            GetPrinterDriver

            The GetPrinterDriver function retrieves driver data for the specified printer. If the driver is not installed on the local computer, GetPrinterDriver installs it.

            BOOL GetPrinterDriver(
              HANDLE hPrinter,     // printer object
              LPTSTR pEnvironment, // environment name
              DWORD Level,         // information level
              LPBYTE pDriverInfo,  // driver data buffer
              DWORD cbBuf,         // size of buffer
              LPDWORD pcbNeeded    // bytes received or required
            );

            Parameters

            hPrinter
            [in] Handle to the printer for which the driver data should be retrieved. Use the OpenPrinter or AddPrinter function to retrieve a printer handle.
            pEnvironment
            [in] Pointer to a null-terminated string that specifies the environment (for example, Windows NT x86, Windows IA64, Windows x64, Windows NT R4000, Windows NT Alpha_AXP, Windows 4.0, or Windows NT PowerPC). If this parameter is NULL, the current environment of the calling application and client machine (not of the destination application and print server) is used.
            Note Windows IA64 is available in Windows XP, Windows XP 64-Bit Edition, Windows Server 2003, and later versions. Windows x64 is available in Windows XP Service Pack 2 (SP2), Windows XP Professional x64 Edition, Windows Server 2003 Service Pack 1 (SP1), and later versions.
            Level
            [in] Specifies the printer driver structure returned in the pDriverInfo buffer. This parameter can be one of the following values.
            Level Structure
            1 DRIVER_INFO_1
            2 DRIVER_INFO_2
            3 Windows 95/98/Me, Windows NT4.0 and later: DRIVER_INFO_3
            4 Windows 2000/XP: DRIVER_INFO_4
            5 Windows 2000/XP: DRIVER_INFO_5
            6 Windows Me, Windows 2000/XP: DRIVER_INFO_6

            pDriverInfo
            [out] Pointer to a buffer that receives a structure containing information about the driver, as specified by Level. The buffer must be large enough to store the strings pointed to by the structure members.

            To determine the required buffer size, call GetPrinterDriver with cbBuf set to zero. GetPrinterDriver fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and the pcbNeeded parameter returns the size, in bytes, of the buffer required to hold the array of structures and their data.

            cbBuf
            [in] Specifies the size, in bytes, of the array at which pDriverInfo points.
            pcbNeeded
            [out] Pointer to a value that receives the number of bytes copied if the function succeeds or the number of bytes required if cbBuf is too small.

            Return Values

            If the function succeeds, the return value is a nonzero value.

            If the function fails, the return value is zero. To get extended error information, call GetLastError.

            Windows 95/98/Me: For a non-existent driver, the function returns ERROR_INVALID_NAMES.

            Windows NT/2000/XP: For a non-existent driver, the function returns ERROR_UNKNOWN_PRINTER_DRIVER.

            Remarks

            The DRIVER_INFO_2, DRIVER_INFO_3, DRIVER_INFO_4, DRIVER_INFO_5, and DRIVER_INFO_6 structures contain the file name or the full path and file name of the printer driver in the pDriverPath member. An application can use the path and file name to load a printer driver by calling the LoadLibrary function and supplying the path and file name as the single argument.

            Requirements

              Windows NT/2000/XP/Vista: Included in Windows NT 3.1 and later.
              Windows 95/98/Me: Included in Windows 95 and later.
              Header: Declared in Winspool.h; include Windows.h.
              Library: Use Winspool.lib.
              Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000/XP.


            相關(guān)代碼:

             1 BOOL CCommonFun::GetPrinterDriverInfo(HANDLE hPrinter, CStringArray &arsDriverFiles, CString &sDriverInstallPath)
             2 {
             3     DWORD dwNeed = 0;
             4     BOOL bOK = GetPrinterDriver(hPrinter, NULL, 3, NULL, NULL, &dwNeed);
             5     if (dwNeed > 0)
             6     {
             7         BYTE *pData = new BYTE[dwNeed];
             8 
             9         bOK = GetPrinterDriver(hPrinter, NULL, 3, pData, dwNeed, &dwNeed);
            10         if(bOK)
            11         {
            12             DRIVER_INFO_3 *pInfo3 = (DRIVER_INFO_3*)pData;
            13             sDriverInstallPath = GetFilePath(pInfo3->pDriverPath);
            14             if (sDriverInstallPath.IsEmpty())
            15             {
            16                 return FALSE;
            17             }
            18             //GetFileList
            19             arsDriverFiles.Add(GetFileFullName(pInfo3->pDriverPath));            
            20             arsDriverFiles.Add(GetFileFullName(pInfo3->pDataFile));        
            21             arsDriverFiles.Add(GetFileFullName(pInfo3->pConfigFile));
            22             arsDriverFiles.Add(GetFileFullName(pInfo3->pHelpFile));
            23 
            24             LPSTR __pdependentFiles = pInfo3->pDependentFiles;
            25             CString dependentFiles;
            26             //get dependent files
            27             if (__pdependentFiles)
            28             {
            29                 while (__pdependentFiles[0!= '\0')
            30                 {
            31                     dependentFiles = GetFileFullName(__pdependentFiles);
            32                     arsDriverFiles.Add(dependentFiles);
            33                     __pdependentFiles += (strlen(__pdependentFiles)+1);
            34                 }
            35             }
            36         }
            37         else
            38         {
            39             return FALSE;
            40         }
            41 
            42         delete []pData;
            43     }
            44     else
            45     {
            46         return FALSE;
            47     }
            48 
            49     return TRUE;
            50 }

             

            posted on 2012-09-04 17:51 王海光 閱讀(605) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): MFC
            久久精品国产半推半就| av午夜福利一片免费看久久| 久久人人爽人人爽人人片AV不 | 亚洲伊人久久综合中文成人网| 久久久久99精品成人片直播| 亚洲精品无码久久久久AV麻豆| 久久精品亚洲福利| 久久综合狠狠色综合伊人| 久久久久久无码Av成人影院| 亚洲人成伊人成综合网久久久| 久久亚洲国产最新网站| 一级女性全黄久久生活片免费| 久久精品国产72国产精福利| 久久精品成人| 久久乐国产精品亚洲综合| 欧美与黑人午夜性猛交久久久| 久久久久九国产精品| 久久精品人妻一区二区三区| 狠狠精品久久久无码中文字幕 | 99久久精品九九亚洲精品| 亚洲国产二区三区久久| a级毛片无码兔费真人久久| 日本精品久久久久中文字幕| 99久久综合狠狠综合久久| 国产精品永久久久久久久久久| 久久国产视频99电影| 亚洲精品久久久www| 色88久久久久高潮综合影院| 久久精品亚洲精品国产色婷| 久久91精品国产91久久小草| 成人久久精品一区二区三区| 国产免费久久精品99久久| 久久夜色精品国产亚洲av| 精品国产乱码久久久久软件| 无码AV波多野结衣久久| 久久噜噜电影你懂的| 午夜福利91久久福利| 色欲综合久久中文字幕网| 99热精品久久只有精品| 久久婷婷五月综合国产尤物app | 曰曰摸天天摸人人看久久久|