• <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 閱讀(4986) 評論(0)  編輯 收藏 引用 所屬分類: Windows Mobile
            老司机国内精品久久久久| 精品久久久久久99人妻| 亚洲一级Av无码毛片久久精品| 日韩中文久久| 亚洲国产精品无码久久久不卡| 久久国产精品成人影院| 久久国产热这里只有精品| 狠狠色丁香久久婷婷综合_中| 久久亚洲精精品中文字幕| 久久av免费天堂小草播放| 久久久久人妻精品一区| 久久精品免费网站网| 国产成人综合久久综合| 亚洲第一永久AV网站久久精品男人的天堂AV | 久久免费精品视频| 人妻少妇精品久久| 国产毛片久久久久久国产毛片 | 久久精品毛片免费观看| 久久久久久毛片免费看| 精品久久久久久中文字幕| 97精品依人久久久大香线蕉97| 97精品国产97久久久久久免费| 狠狠综合久久AV一区二区三区| 91久久福利国产成人精品| 久久精品水蜜桃av综合天堂| 狠狠色丁香婷婷久久综合| 久久久久久国产a免费观看不卡| 欧美精品久久久久久久自慰| 久久精品国产99国产精品导航| 麻豆久久| 久久九九兔免费精品6| 久久久国产99久久国产一| 国产综合精品久久亚洲| 99久久夜色精品国产网站| 日本免费一区二区久久人人澡| 久久精品国产亚洲精品2020| 久久亚洲精品中文字幕| 久久久久成人精品无码中文字幕| 无码久久精品国产亚洲Av影片| 色综合久久久久综合体桃花网| 久久久噜噜噜www成人网|