关于在Windows Mobile下今日插件使用WTL的问题

简介

本文讲述在今日插件开发中整合WTL遇到的问题,问题已经解决,看解决部分。

 

问题

最近一段时间都在开发今日插件(Today Plug-in)。开始把代码都写的差不多了,整合了Sqlite和WTL,关于Sqlite和WTL也可以参考之前写的文章。

Windows Mobile下访问Sqlite的Native C++封装

 

Windows Mobile和Wince下的WTL(Windows Template Library)开发

Windows Mobile 和 Wince 下的 WTL(Windows Template Library) 界面开发  

 

最后测试的时候发现今日插件没有正确显示出来。

一般来说一个部署成功的今日插件可以在配置里面显示。如下图:

Start->Settings->Today->Items

today1

我的插件名字叫做Jake’s Today。

 

但是一旦我整合了WTL,插件就不能显示到Today Setting里面了。

#include <atlbase.h>

#if _ATL_VER == 0x900
#define _SECURE_ATL 1
#endif
#include <atlstr.h>

#define _WTL_NO_CSTRING

#include <atlapp.h>

在StdAfx.h加入WTL的头文件,如果仅仅加入ATL支持,是没有问题的,但是一旦加入#include <atlapp.h> 后今日插件就不能显示到Today Setting里面了。如下图:

today2

今日插件Jake’s Today消失了。

我使用Dumpbin查看接口,发现接口与是否整合WTL无关。

Microsoft (R) COFF/PE Dumper Version 9.00.30729.01
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file Jaketoday.dll

File Type: DLL

Section contains the following exports for Jaketoday.dll

00000000 characteristics
4AE64262 time date stamp Tue Oct 27 21:44:18 2009
0.00 version
240 ordinal base
2 number of functions
0 number of names

ordinal hint RVA name

240 00002110 [NONAME] ?InitializeCustomItem@@YAPAUHWND__@@PAU_TODAY
LISTITEM@@PAU1@@Z (struct HWND__ * __cdecl InitializeCustomItem(struct _TODAYLIS
TITEM *,struct HWND__ *))
241 00002344 [NONAME] ?CustomItemOptionsDlgProc@@YAJPAUHWND__@@IIJ@
Z (long __cdecl CustomItemOptionsDlgProc(struct HWND__ *,unsigned int,unsigned i
nt,long))

Summary

1000 .data
1000 .pdata
5000 .rdata
2000 .reloc
1000 .rsrc
14000 .text

同样我把WTL整合的代码去掉,只是加上Sqlite的整合后,也出现同样的问题。目前为止,我没有整合到任何第三方到今日插件中。Windows Mobile下访问Sqlite的Native C++封装

 

这个问题我查找了MSDN没有找到答案,发贴提问了也没有人回答。

How to use WTL in today plug-in DLL

 

由于工期原因,我决定放弃原先的方案,直接使用Win32来完成这个今日插件。如果那位碰到并解决这个问题,请告知,在此先谢了。

 

PS:可能有曲线救国的方法,使用一个today host来调用DLL,因为这个host可以调用C#的DLL的,参考下面的链接。

Creating a Pocket PC Today Screen Plug-in with the .NET Compact Framework

Creating Managed Today Screen Items

 

解决

 经过Ray和UMU的帮助,找到了解决方法。问题是如果编译出来的DLL依赖于msvcr90d.dll的话,加载就失败了,我想可能是shell32不能成功加载msvcr90d.dll导致的。

下面使用 Dumpbin /imports win32.dll 查看没有使用WTL的版本的DLL。

Dump of file win32.dll

File Type: DLL

  Section contains the following imports:

    AYGSHELL.dll
              10010000 Import Address Table
              1000F3C0 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                      Ordinal    40
                      Ordinal    56

    COREDLL.dll
              1001000C Import Address Table
              1000F3CC Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                      Ordinal   725
                      Ordinal   884
                      Ordinal   874
                      Ordinal   873
                      Ordinal   730
                      Ordinal   263
                      Ordinal   916
                      Ordinal   262
                      Ordinal  2005
                      Ordinal   264
                      Ordinal   858
                      Ordinal   875
                      Ordinal    95
                      Ordinal   919
                      Ordinal  1047
                      Ordinal   267
                      Ordinal   266
                      Ordinal   258
                      Ordinal   246
                      Ordinal   691
                      Ordinal   868
                      Ordinal   692
                      Ordinal   684
                      Ordinal   497
                      Ordinal   876
                      Ordinal   250
                      Ordinal   261
                      Ordinal   911
                      Ordinal   903
                      Ordinal   921
                      Ordinal   910
                      Ordinal   260
                      Ordinal   248
                      Ordinal   945
                      Ordinal   923
                      Ordinal   924
                      Ordinal   935
                      Ordinal    90
                      Ordinal   912
                      Ordinal   897
                      Ordinal    63
                      Ordinal   931
                      Ordinal   895
                      Ordinal   918
                      Ordinal  2033
                      Ordinal  2027
                      Ordinal  2048
                      Ordinal  2053
                      Ordinal  2024
                      Ordinal  2046
                      Ordinal  1118
                      Ordinal  1122
                      Ordinal  1116
                      Ordinal  1113
                      Ordinal  1097
                      Ordinal  1025
                      Ordinal    23
                      Ordinal  1068
                      Ordinal  1094
                      Ordinal  2008
                      Ordinal  1551
                      Ordinal  1044
                      Ordinal  1095
                      Ordinal  1580
                      Ordinal  1572
                      Ordinal  1571
                      Ordinal  1575
                      Ordinal  1574
                      Ordinal  1065
                      Ordinal    87
                      Ordinal  1556
                      Ordinal  1046
                      Ordinal  1041
                      Ordinal  1018
                      Ordinal  1096
                      Ordinal   537
                      Ordinal    16
                      Ordinal    33
                      Ordinal    15
                      Ordinal  1492
                      Ordinal   520
                      Ordinal     3
                      Ordinal     4
                      Ordinal     5
                      Ordinal    11
                      Ordinal   171
                      Ordinal    75
                      Ordinal  1132
                      Ordinal   541
                      Ordinal    10
                      Ordinal   530
                      Ordinal   528
                      Ordinal   543
                      Ordinal   517
                      Ordinal     2
                      Ordinal   544
                      Ordinal  1876
                      Ordinal    36
                      Ordinal  1875
                      Ordinal  1570
                      Ordinal  1111
                      Ordinal  1100
                      Ordinal   496
                      Ordinal    12
                      Ordinal    34
                      Ordinal    35

  Summary

        1000 .data
        1000 .pdata
        3000 .rdata
        1000 .reloc
        D000 .rsrc
        C000 .text
        
下面使用        Dumpbin /imports wtl.dll 查看没有整合WTL的版本的DLL。

Dump of file wtl.dll

File Type: DLL

  Section contains the following imports:

    AYGSHELL.dll
              1001A000 Import Address Table
              10019AA8 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                      Ordinal    40
                      Ordinal    56

    COREDLL.dll
              1001A00C Import Address Table
              10019AB4 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                      Ordinal   725
                      Ordinal   884
                      Ordinal   874
                      Ordinal   873
                      Ordinal   730
                      Ordinal   263
                      Ordinal   916
                      Ordinal   262
                      Ordinal  2005
                      Ordinal   264
                      Ordinal   858
                      Ordinal   875
                      Ordinal    95
                      Ordinal   919
                      Ordinal  1047
                      Ordinal   267
                      Ordinal   266
                      Ordinal   258
                      Ordinal   246
                      Ordinal   691
                      Ordinal   868
                      Ordinal   692
                      Ordinal   684
                      Ordinal   497
                      Ordinal   876
                      Ordinal   250
                      Ordinal   261
                      Ordinal   911
                      Ordinal   903
                      Ordinal   921
                      Ordinal   910
                      Ordinal   260
                      Ordinal   248
                      Ordinal   945
                      Ordinal   923
                      Ordinal   924
                      Ordinal   935
                      Ordinal    90
                      Ordinal   912
                      Ordinal   897
                      Ordinal    63
                      Ordinal   931
                      Ordinal   895
                      Ordinal   918
                      Ordinal  2033
                      Ordinal  2027
                      Ordinal  2048
                      Ordinal  2053
                      Ordinal  2024
                      Ordinal  2046
                      Ordinal  1118
                      Ordinal  1122
                      Ordinal  1116
                      Ordinal  1113
                      Ordinal  1097
                      Ordinal  1025
                      Ordinal    23
                      Ordinal  1068
                      Ordinal  1094
                      Ordinal  2008
                      Ordinal  1551
                      Ordinal  1044
                      Ordinal  1095
                      Ordinal  1580
                      Ordinal  1572
                      Ordinal  1571
                      Ordinal  1575
                      Ordinal  1574
                      Ordinal  1065
                      Ordinal    87
                      Ordinal  1556
                      Ordinal  1046
                      Ordinal  1041
                      Ordinal  1018
                      Ordinal  1096
                      Ordinal   537
                      Ordinal    16
                      Ordinal    33
                      Ordinal    15
                      Ordinal  1492
                      Ordinal   520
                      Ordinal     3
                      Ordinal     4
                      Ordinal     5
                      Ordinal    11
                      Ordinal   171
                      Ordinal    75
                      Ordinal  1132
                      Ordinal   541
                      Ordinal    10
                      Ordinal   530
                      Ordinal   528
                      Ordinal   543
                      Ordinal   517
                      Ordinal     2
                      Ordinal   544
                      Ordinal    34
                      Ordinal    12
                      Ordinal  1876
                      Ordinal    36
                      Ordinal  1875
                      Ordinal  1177
                      Ordinal   553
                      Ordinal  1496
                      Ordinal   494
                      Ordinal    61
                      Ordinal   524
                      Ordinal   550
                      Ordinal  1043
                      Ordinal   542
                      Ordinal   549
                      Ordinal   516
                      Ordinal   548
                      Ordinal   230
                      Ordinal  1054
                      Ordinal  1570
                      Ordinal  1111
                      Ordinal  1100
                      Ordinal   496
                      Ordinal    35

    msvcr90d.dll
              1001A1F0 Import Address Table
              10019C98 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                   26 wcsncpy_s

    ole32.dll
              1001A1F8 Import Address Table
              10019CA0 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                   1E ReadClassStm
                    3 CoCreateInstance
                   28 WriteClassStm

  Summary

        1000 .data
        1000 .pdata
        5000 .rdata
        2000 .reloc
        D000 .rsrc
       14000 .text
       
发现WTL版本比Win32版本增加了对msvcr90d.dll和ole32.dll的依赖。
如果要去掉这些依赖可以通过编译Release版本来解决。   

 

posted @ 2009-10-28 06:55  Jake Lin  阅读(1530)  评论(5编辑  收藏  举报