• <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>
            春暖花開
            雪化了,花開了,春天來了
            posts - 149,comments - 125,trackbacks - 0

            今天在運用VerQueryValue的時候發現了一個很詭異的問題,出錯了。不是這個函數出錯了,而是后面對其中的值的運用出錯了。

            SDK中的代碼是這樣的

            // Structure used to store enumerated languages and code pages.

            struct LANGANDCODEPAGE {
              WORD wLanguage;
              WORD wCodePage;
            }
             *lpTranslate;

            // Read the list of languages and code pages.
            DWORD cbTranslate = 0;

            VerQueryValue(pBlock, 
                          TEXT(
            "\\VarFileInfo\\Translation"),
                          (LPVOID
            *)&lpTranslate,
                          
            &cbTranslate);

            // Read the file description for each language and code page.

            for( i=0; i < (cbTranslate/sizeof(struct LANGANDCODEPAGE)); i++ )
            {
              wsprintf( SubBlock, 
                        TEXT(
            "\\StringFileInfo\\%04x%04x\\FileDescription"),
                        lpTranslate[i].wLanguage,
                        lpTranslate[i].wCodePage);

              
            // Retrieve file description for language and code page "i". 
              VerQueryValue(pBlock, 
                            SubBlock, 
                            
            &lpBuffer, 
                            
            &dwBytes); 
            }


            我在使用的時候,直接調用的是lpTranslate[0].wLanguage,然而此時調用出錯了! 為何?可能是這個值不存在。

            簡單的判斷 if (lpTranslate != NULL) 是不妥的。

            我查看了一下SDK文檔

            Return Values

            If the specified version-information structure exists, and version information is available, the return value is nonzero. If the address of the length buffer is zero, no value is available for the specified version-information name.

            If the specified name does not exist or the specified resource is not valid, the return value is zero.

            如果cbTranslate為零的話,則沒有任何版本信息獲得,所以我的判斷if (lpTranslate != NULL)是不充分的。

            所以需要改為if (lpTranslate != NULL && cbTranslate != 0), 這樣就OK了。

            總結: 要認真看文檔, 有些條件要注意到!


            posted on 2009-06-17 18:55 Sandy 閱讀(4993) 評論(0)  編輯 收藏 引用 所屬分類: Windows Mobile
            99久久国产综合精品成人影院| 一本久道久久综合狠狠爱| 久久99久久99小草精品免视看| 精品国产乱码久久久久久郑州公司 | 中文字幕久久精品无码| 久久精品www| 99久久成人国产精品免费| 久久精品国产亚洲av麻豆图片| 国产一级持黄大片99久久 | 国产精品免费久久| 狠狠狠色丁香婷婷综合久久五月| 久久最新免费视频| 久久综合成人网| 欧美黑人又粗又大久久久| 一本色道久久综合狠狠躁| 亚洲国产天堂久久综合| 国産精品久久久久久久| 久久久久久狠狠丁香| 丁香五月网久久综合| 久久精品国产第一区二区| 久久亚洲中文字幕精品一区| 亚洲乱码中文字幕久久孕妇黑人| 夜夜亚洲天天久久| 久久天天躁夜夜躁狠狠| 久久久久人妻一区精品性色av| 国产精品久久久久天天影视| 一本色道久久综合狠狠躁篇| 国产一级做a爰片久久毛片| 久久天天躁夜夜躁狠狠躁2022| 日本久久久久久中文字幕| 亚洲日韩中文无码久久| 综合久久给合久久狠狠狠97色| 久久九九免费高清视频| 91久久香蕉国产熟女线看| 国产精品久久久久影院色| 久久精品免费观看| 久久激情亚洲精品无码?V| 久久综合久久鬼色| 97精品依人久久久大香线蕉97| 国产精品久久久久蜜芽| 99久久婷婷国产综合亚洲|