发表于:2010/9/29 14:10:52
#0楼
之前一直在xp,vista和win7(32,64位)运行正常的基于cvi9.0的程序,在加入一个日历activex控件后进行兼容性测试时发现,xp正常,但win7中连界面都进入不了。检查发现是由于目录设置中的加载目标到可执行文件窗口的设置错误所致,如下图所示:
[URL=https://32qjdg.blu.livefilestore.com/y1min3lyvzeuxhuql5bxncvkdlpt1afdchmrbhn-j0rfikjjfetmubdun4iqr2bomulyrbmugycqzdhtbnoetrgkjxnqekhyop_kj-zqu4kwqtwgocvjleomivj_rpzcurwopezr2ihbqwuo4iemowqww/image[23]%203918970c.png?download&psid=1]
[img]http://blog.gkong.com/https://32qjdg.blu.livefilestore.com/y1mi3cqjyheivlwburp0rcldf0ksplwxjcjc2qh5njwkrbwkzgnnk4l-deznxb2rcecccma6yctjkn8pb9cxvkujvv4dbyrl_e_sqy20fzssisedm75opfl1gcimdtjzixjk_cj_if0ajaoaxb2ya0j1w/image_thumb[11]%203c76dc5c.png?download&psid=1[/img]
[/URL]
[URL=https://32qjdg.blu.livefilestore.com/y1mnqktu4q4hpt0zwfo2yekmtwvdssfkwtonknbc_rpnz7r50e2fpzec2wgik9fo9fiyoafdsg03bia_khji4xfcwp2pqdihw7rnddwovpecmt-gaodd48c3ymnxou6mn-slzkxmywyezrzadtpqot_dw/%e6%97%a0%e6%a0%87%e9%a2%98[1].png?download&psid=1]
[img]http://blog.gkong.com/https://32qjdg.blu.livefilestore.com/y1mwrgx7vudsf42kbdedru_kkmwn-q2azreq73luzycdcxbi36qedah364leuyrapcan1hg90bd2y2ibfsjosrbji4zc35e4yrx5jpafyibylbsv9rylc7kaoxaqirypxudwnfttqi-us4nlbmjjwt5ba/%e6%97%a0%e6%a0%87%e9%a2%98_thumb[1].png?download&psid=1[/img]
[/URL]
去掉shell32.lib的打钩,这样程序在win7中运行时,另外把c源文件也一并去钓,把c源文件加入可执行文件的后果如下图所示
,vc运行时会调用对应于win7的shell32.dll。这样就不会出现兼容性的问题!
[URL=https://32qjdg.blu.livefilestore.com/y1mvv9pcxkra7s61fvizpc12wyopch2q2bb-2_ecuftncn2xwzdxxamlz9u9gplgmv-az-u_dhgdzcg6r0i8r92disp8utzvmbysysi2bm5jgfpi0-qv3pn7xdrwttucd-zeb8ijr5thtcnxb9rfwqcda/%e6%97%a0%e6%a0%87%e9%a2%981[3].jpg?download&psid=1]
[img]http://blog.gkong.com/https://32qjdg.blu.livefilestore.com/y1mvaewawsjv9yflr5-ksiet6wrrdomoyps6qdbkqvpjyurb2mug3h3hktc2crumzeqemkfb4o-bfevw-airrf2njv2dfb-edrofsp5s1evdudqagdtiteexavaainf13wazguhfygxik6sc02c1_xfja/%e6%97%a0%e6%a0%87%e9%a2%981_thumb[1].jpg?download&psid=1[/img]
[/URL]
win7的vc运行时在对可执行文件所作的动作。(误把c源文件嵌入到可执行文件所导致的)不过按下联取消,程序能正常运行!
附录1: shell32.lib
shell32 - shell32.dll - dll文件信息
dll 文件: shell32 或者 shell32.dll
dll 名称: microsoft windows shell library(微软视窗外壳要求生效的命令代码集合)
描述:
shell32.dll是windows的32位外壳动态链接库文件,用于打开网页和文件,建立文件时的默认文件名的设置等大量功能。
严格来讲,它只是代码的合集,真正执行这些功能的是操作系统的相关程序,dll文件只是根据设置调用这些程序的相关功能罢了。
属于: microsoft windows shell (微软视窗外壳)
系统 dll(动态连接库)文件: 是
[URL=https://32qjdg.blu.livefilestore.com/y1mron38u4hsdczbrhqcdp3jxm4i7gogcrrzwa5g1dhyqbwcaeyq7dt8-6hioi77onjdoauxqxksmh8sdaemxojqcvm0rqxyxkj0-lf9e7txidsjobv89ptn0peva_qim67f9yt3chibykltawev1a1dw/image[7]%204337c6b7.png?download&psid=1]
[img]http://blog.gkong.com/https://32qjdg.blu.livefilestore.com/y1mi12kxwsvhuwlx8lirtz7blyvrg5t1g_f8t3c8fmbsafy5h79yq2upvpkeofdo3_ishozs3zkhnnvc0imry4hygy7fffan0zwxhhromxkiy3o5dmzzoo5dkha9k4nmr06i2hio9whsprqcngjfemy6w/image_thumb[3]%2057781f46.png?download&psid=1[/img]
[/URL]
附录2:
[URL=http://digital.ni.com/public.nsf/websearch/97ec1ca826fffe0386256c710014290d?opendocument]
calling conventions in labwindows/cvi
[/URL]
调用约定,即options » build options » default calling convention。一般默认调用约定是__cdecl;而如果dll使用winapi,则需要使用调用约定__stdcall。请根据具体情况设置。比如下面的例子是一个默认约定选译为“__stdcall”在编译时出错的例子:
[URL=https://32qjdg.blu.livefilestore.com/y1m9s2cj_0h9u3zoojchu_pqlpnjmygyrylig4edajveytcqz33f3vqbsjni7bchttugew7mzat2zxclb4h0uutnthv-xc33sbsz2j8vesulpgq0b7c42p5cezyqdwyh0jrilnexcab3fcf-vwqdkqplq/image[19]%206df50091.png?download&psid=1]
[img]http://blog.gkong.com/https://32qjdg.blu.livefilestore.com/y1mqxbybvip7wxbwpjs50x0qfc1chddzv9qjz4ezqhndmsbkcw-bf_oqpqzo6v1kokeivogva9bx-samigwthea3epyliovexzmhumnqingl6skthak4sqg4e4oxipw66s31enzkssj4i7v3tbgix6pjg/image_thumb[9]%2005d89560.png?download&psid=1[/img]
[/URL]
附录3: build options 设置的一些说明
[URL=https://32qjdg.blu.livefilestore.com/y1matip-z18xy07a0m6ivujx1ico2c9vuf2b6dha8hubpaipaux9_ztmb9ucd8hojrgs3qks3wpwsamkvtbcepzgljrecui1ccckom2zxterumpb_pt_ecoiqwzclyzohuvp0yzxzehiranofusijgxna/image[15]%2036b569c2.png?download&psid=1]
[img]http://blog.gkong.com/https://32qjdg.blu.livefilestore.com/y1mmivucu2dyztnnojrhjx14ecxm9ivdgi4_gw_s7k-vni_zyh1q9t1g4k7l0mzidtgpzhcuc06ybofvywyx683loqpkthqplpewlhizdnfyp37hy4u9lx4m3muspdmwawa3lxt5ki-fjwtlgu_aqn4pa/image_thumb[7]%201e71b3cd.png?download&psid=1[/img]
[/URL]
----------------------------------------------
此篇文章从博客转发
原文地址: Http://blog.gkong.com/more.asp?id=125855&Name=zjcsharp
[URL=https://32qjdg.blu.livefilestore.com/y1min3lyvzeuxhuql5bxncvkdlpt1afdchmrbhn-j0rfikjjfetmubdun4iqr2bomulyrbmugycqzdhtbnoetrgkjxnqekhyop_kj-zqu4kwqtwgocvjleomivj_rpzcurwopezr2ihbqwuo4iemowqww/image[23]%203918970c.png?download&psid=1]
[img]http://blog.gkong.com/https://32qjdg.blu.livefilestore.com/y1mi3cqjyheivlwburp0rcldf0ksplwxjcjc2qh5njwkrbwkzgnnk4l-deznxb2rcecccma6yctjkn8pb9cxvkujvv4dbyrl_e_sqy20fzssisedm75opfl1gcimdtjzixjk_cj_if0ajaoaxb2ya0j1w/image_thumb[11]%203c76dc5c.png?download&psid=1[/img]
[/URL]
[URL=https://32qjdg.blu.livefilestore.com/y1mnqktu4q4hpt0zwfo2yekmtwvdssfkwtonknbc_rpnz7r50e2fpzec2wgik9fo9fiyoafdsg03bia_khji4xfcwp2pqdihw7rnddwovpecmt-gaodd48c3ymnxou6mn-slzkxmywyezrzadtpqot_dw/%e6%97%a0%e6%a0%87%e9%a2%98[1].png?download&psid=1]
[img]http://blog.gkong.com/https://32qjdg.blu.livefilestore.com/y1mwrgx7vudsf42kbdedru_kkmwn-q2azreq73luzycdcxbi36qedah364leuyrapcan1hg90bd2y2ibfsjosrbji4zc35e4yrx5jpafyibylbsv9rylc7kaoxaqirypxudwnfttqi-us4nlbmjjwt5ba/%e6%97%a0%e6%a0%87%e9%a2%98_thumb[1].png?download&psid=1[/img]
[/URL]
去掉shell32.lib的打钩,这样程序在win7中运行时,另外把c源文件也一并去钓,把c源文件加入可执行文件的后果如下图所示
,vc运行时会调用对应于win7的shell32.dll。这样就不会出现兼容性的问题!
[URL=https://32qjdg.blu.livefilestore.com/y1mvv9pcxkra7s61fvizpc12wyopch2q2bb-2_ecuftncn2xwzdxxamlz9u9gplgmv-az-u_dhgdzcg6r0i8r92disp8utzvmbysysi2bm5jgfpi0-qv3pn7xdrwttucd-zeb8ijr5thtcnxb9rfwqcda/%e6%97%a0%e6%a0%87%e9%a2%981[3].jpg?download&psid=1]
[img]http://blog.gkong.com/https://32qjdg.blu.livefilestore.com/y1mvaewawsjv9yflr5-ksiet6wrrdomoyps6qdbkqvpjyurb2mug3h3hktc2crumzeqemkfb4o-bfevw-airrf2njv2dfb-edrofsp5s1evdudqagdtiteexavaainf13wazguhfygxik6sc02c1_xfja/%e6%97%a0%e6%a0%87%e9%a2%981_thumb[1].jpg?download&psid=1[/img]
[/URL]
win7的vc运行时在对可执行文件所作的动作。(误把c源文件嵌入到可执行文件所导致的)不过按下联取消,程序能正常运行!
附录1: shell32.lib
shell32 - shell32.dll - dll文件信息
dll 文件: shell32 或者 shell32.dll
dll 名称: microsoft windows shell library(微软视窗外壳要求生效的命令代码集合)
描述:
shell32.dll是windows的32位外壳动态链接库文件,用于打开网页和文件,建立文件时的默认文件名的设置等大量功能。
严格来讲,它只是代码的合集,真正执行这些功能的是操作系统的相关程序,dll文件只是根据设置调用这些程序的相关功能罢了。
属于: microsoft windows shell (微软视窗外壳)
系统 dll(动态连接库)文件: 是
[URL=https://32qjdg.blu.livefilestore.com/y1mron38u4hsdczbrhqcdp3jxm4i7gogcrrzwa5g1dhyqbwcaeyq7dt8-6hioi77onjdoauxqxksmh8sdaemxojqcvm0rqxyxkj0-lf9e7txidsjobv89ptn0peva_qim67f9yt3chibykltawev1a1dw/image[7]%204337c6b7.png?download&psid=1]
[img]http://blog.gkong.com/https://32qjdg.blu.livefilestore.com/y1mi12kxwsvhuwlx8lirtz7blyvrg5t1g_f8t3c8fmbsafy5h79yq2upvpkeofdo3_ishozs3zkhnnvc0imry4hygy7fffan0zwxhhromxkiy3o5dmzzoo5dkha9k4nmr06i2hio9whsprqcngjfemy6w/image_thumb[3]%2057781f46.png?download&psid=1[/img]
[/URL]
附录2:
[URL=http://digital.ni.com/public.nsf/websearch/97ec1ca826fffe0386256c710014290d?opendocument]
calling conventions in labwindows/cvi
[/URL]
调用约定,即options » build options » default calling convention。一般默认调用约定是__cdecl;而如果dll使用winapi,则需要使用调用约定__stdcall。请根据具体情况设置。比如下面的例子是一个默认约定选译为“__stdcall”在编译时出错的例子:
[URL=https://32qjdg.blu.livefilestore.com/y1m9s2cj_0h9u3zoojchu_pqlpnjmygyrylig4edajveytcqz33f3vqbsjni7bchttugew7mzat2zxclb4h0uutnthv-xc33sbsz2j8vesulpgq0b7c42p5cezyqdwyh0jrilnexcab3fcf-vwqdkqplq/image[19]%206df50091.png?download&psid=1]
[img]http://blog.gkong.com/https://32qjdg.blu.livefilestore.com/y1mqxbybvip7wxbwpjs50x0qfc1chddzv9qjz4ezqhndmsbkcw-bf_oqpqzo6v1kokeivogva9bx-samigwthea3epyliovexzmhumnqingl6skthak4sqg4e4oxipw66s31enzkssj4i7v3tbgix6pjg/image_thumb[9]%2005d89560.png?download&psid=1[/img]
[/URL]
附录3: build options 设置的一些说明
[URL=https://32qjdg.blu.livefilestore.com/y1matip-z18xy07a0m6ivujx1ico2c9vuf2b6dha8hubpaipaux9_ztmb9ucd8hojrgs3qks3wpwsamkvtbcepzgljrecui1ccckom2zxterumpb_pt_ecoiqwzclyzohuvp0yzxzehiranofusijgxna/image[15]%2036b569c2.png?download&psid=1]
[img]http://blog.gkong.com/https://32qjdg.blu.livefilestore.com/y1mmivucu2dyztnnojrhjx14ecxm9ivdgi4_gw_s7k-vni_zyh1q9t1g4k7l0mzidtgpzhcuc06ybofvywyx683loqpkthqplpewlhizdnfyp37hy4u9lx4m3muspdmwawa3lxt5ki-fjwtlgu_aqn4pa/image_thumb[7]%201e71b3cd.png?download&psid=1[/img]
[/URL]
----------------------------------------------
此篇文章从博客转发
原文地址: Http://blog.gkong.com/more.asp?id=125855&Name=zjcsharp