• <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
            今天在做東西的時(shí)候,用LoadString遇到了一些問題.可能大家日后也會(huì)用到,分享一下.

            LoadString 從資源載入字符串,我們一般這么用。
            舉個(gè)例子:
            TCHAR str[20];
            LoadString(hInstance, IDS_STR, str, 20);

            如果我們的字符串的長(zhǎng)度不知道,或許它會(huì)變化的話,我們?cè)趺磥慝@得資源ID對(duì)應(yīng)的字符串呢?這就要用到
            LoadString的另一種用法,我們可以這樣用
            LPCTSTR lpcStr = (LPCTSTR)LoadString(hInstance, IDS_STR, NULL, 0);

            感覺上沒有什么問題啊?

            但是實(shí)際應(yīng)用中又出現(xiàn)問題了,讀出的字符串沒有截?cái)嗵幚恚讼乱粋€(gè)ID包含的字符串或者更多。

            怎么辦?在MSDN中,LoadString已經(jīng)清楚地指出
            lpBuffer is set to NULL, the return value is a pointer to the requested string. The caller should cast the return value to an LPCTSTR. This pointer points directly to the resource, so the string is read-only. The length of the string, not including any terminating null character, can be found in the word preceding the string.

            同時(shí)它也給出了解決辦法:
            To use the lpBuffer pointer, the n flag must be set with the resource compiler, RC.
            Note   String resources are not null-terminated by default. When lpBuffer is set to NULL, verify whether the string resource represented by the pointer returned by LoadString is null-terminated, and if necessary, append a terminating null character to the resource before using it in your application.

            一開始我沒有太明白the n flag must be set with the resource compiler, RC.的含義,很迷惑,不知道如何解決。但是在網(wǎng)上尋找方法的時(shí)候,發(fā)現(xiàn)這么一篇文章
            http://lak4cyut.blogspot.com/2008/08/wm-api-loadstring.htmlWM API : LoadString() 另一種使用方式),我才徹底明白過來。

            我使用的是VS2005,在project->properties->Resource->Command Line中添加一個(gè) “-n”,即可。

            在運(yùn)行程序,正常顯示了。

            大家如遇相同問題,可以試試這個(gè)方法。
            posted on 2008-12-17 20:07 Sandy 閱讀(6772) 評(píng)論(8)  編輯 收藏 引用 所屬分類: windows學(xué)習(xí)

            FeedBack:
            # re: LoadString的一些小用法
            2008-12-17 23:24 | 萬連文
            看看VC的CString的LoadString的方法,可以自己封裝一個(gè)Win32版本的,你這個(gè)方法不是那么徹底解決問題。  回復(fù)  更多評(píng)論
              
            # re: LoadString的一些小用法
            2008-12-18 08:28 | Sandy
            @萬連文
            這個(gè)我還真的沒有想到.謝謝提醒.我自己也封裝了一個(gè),可是用起來比較麻煩,我去看看CString的LoadString怎么實(shí)現(xiàn)的.  回復(fù)  更多評(píng)論
              
            # re: LoadString的一些小用法
            2008-12-18 22:30 | dell筆記本
            不錯(cuò),好東西  回復(fù)  更多評(píng)論
              
            # re: LoadString的一些小用法
            2010-06-05 23:31 | VickieCastaneda
            Don't you know that it is high time to receive the <a href="http://lowest-rate-loans.com/topics/home-loans">home loans</a>, which would make you dreams real.   回復(fù)  更多評(píng)論
              
            # re: LoadString的一些小用法
            2010-06-15 09:32 | thesis
            Thank you a lot for your supreme issue referring to this good post. I could not find this kind of thesis report in web and wanted to buy the dissertation. Thus, I have all needed stuff at this time.   回復(fù)  更多評(píng)論
              
            # re: LoadString的一些小用法
            2010-08-02 09:25 | Freelance writing job
            I come to writing jobs service, with the aim to information close to this topic.   回復(fù)  更多評(píng)論
              
            # re: LoadString的一些小用法
            2010-08-05 05:26 | ringtones
            Some people will dispute much about your superior thought. I opine that, the great get ringtones service has to consult with you to produce the perfect quality free downloadable ringtones blog issue.   回復(fù)  更多評(píng)論
              
            # re: LoadString的一些小用法
            2010-10-07 11:25 | resume writing
            Are you willing to get resume, which suit the range of study you expect?. You can count on our resume writers, as you rely on yourself. Thanks because it’s the interesting  回復(fù)  更多評(píng)論
              
            国产精品免费看久久久香蕉| 久久婷婷五月综合97色直播| 久久综合国产乱子伦精品免费| 亚洲AV无码久久精品成人| 国内精品久久久久影院免费| 国产精品成人久久久久三级午夜电影 | 欧美性大战久久久久久 | 亚洲中文久久精品无码ww16| 99re久久精品国产首页2020| 色青青草原桃花久久综合| 久久国产精品国产自线拍免费 | 无码精品久久久天天影视| 国产精品丝袜久久久久久不卡 | 久久最新精品国产| 亚洲乱码精品久久久久.. | 精品久久久久久久久久久久久久久 | 东京热TOKYO综合久久精品 | 久久久久久A亚洲欧洲AV冫| 国内精品伊人久久久久AV影院| 欧美大战日韩91综合一区婷婷久久青草 | 狠狠精品久久久无码中文字幕| 国产综合久久久久久鬼色| 蜜桃麻豆WWW久久囤产精品| 久久久久香蕉视频| 精品久久久久久99人妻| 91超碰碰碰碰久久久久久综合| 97久久国产亚洲精品超碰热 | 久久国产免费直播| 国产成人精品久久亚洲| 日本久久久精品中文字幕| 韩国三级大全久久网站| 熟妇人妻久久中文字幕| 亚洲av日韩精品久久久久久a| 国产69精品久久久久观看软件 | 国产一区二区三区久久精品| 久久久久久久97| 狠狠色丁香婷婷久久综合不卡| 欧美久久综合性欧美| 伊人久久大香线蕉精品| 国产精品日韩深夜福利久久| 久久人妻少妇嫩草AV蜜桃|