天天看點

關于報Internet Services錯誤的問題

不是技術問題的問題.

切記:要裝對應的SP1!

拿到手一個項目編譯了一下出現個錯誤 :

#error :  Internet Services classes not supported in this library variant.

是在 afxinet.h 裡

#ifdef _AFX_NO_INET_SUPPORT

#error Internet Services classes not supported in this library variant.

#endif

郁悶了一下,後來解決了。

不是别的問題,一般是沒打SP1,或打的錯誤。

在沒打之前在D:/Program Files/Microsoft Visual Studio 8/VC/ce/atlmfc/include/afxinet.h 裡有這段代碼。

#ifdef _AFX_NO_INET_SUPPORT

#error Internet Services classes not supported in this library variant.

#endif

而打過之後是沒有的:

#ifndef __AFXINET_H_

#define __AFXINET_H_

#pragma once

#ifndef __AFX_H__

 #include <afx.h>

#endif

#ifndef _WININET_

#include <wininet.h>

#endif

#ifdef _AFXDLL

#pragma comment(lib, "wininet.lib")

#endif

這個問題不是技術問題!

參考文獻:

也談EVC工程移植

本文是針對作者本人的一個具體的移植項目,将碰到的所有問題列出來,并給出具體的解決方法。由于是一個具體的項目,是以不能把所有的EVC工程移植問題囊括進來。是以,在移植項目前,建議還是看看以下的文章:

循序漸進:将 eMbedded Visual C++ 應用程式遷移到 Visual Studio 2005

eMbedded Visual C++ 到 Visual Studio 2005 更新向導(注意其最後一句話:預設情況下,Embedded Visual C++ 4.0 版會将 MFC Pocket PC 應用程式的對話框樣式(Border)設定為 DS_MODALFRAME。MFC 8.0 不支援此樣式。 —— 應改為Thin,如果不改的話,視窗就無法彈出。)

從 eVC 移植所帶來的已知問題

Migrating Microsoft eMbedded Visual C++ Projects to Visual Studio 2005

        開發環境: Windows XP +SP2 , Visual Studio 2005 professional, Windows Mobile 6.0 Professional SDK。

注:(1) 對于 Windows Mobile 5.0 SDK 開發的程式在 Windows Mobile 6.0 下也能運作,而且不需要對程式進行任何的修改。

      (2)由于有些錯誤,是環境配置問題,是以在Debug/Resease模式下,都需要進行修改,以下錯誤中,如果是這類錯誤,都在标号後面寫着 “Resealse 模式也需要改”,當天切換到别的SDK下,如Windows Mobile 5.0 SDK,也需要修改。

      以下是針對Debug模式下的:

1、StdAfx.cpp (Resealse 模式也需要改)

編譯錯誤:D:/Program Files/Microsoft Visual Studio 8/VC/ce/atlmfc/include/afxver_.h(77) : fatal error C1189: #error : Please use the /MD switch for _AFXDLL builds

解決方法:右擊工程名,打開Project properties對話框,切換到C/C++->Code generation頁,将Runtime Libarary 設定成“Multi-threaded DLL(/MD)”,即可解決此問題。

2、編譯錯誤:error C2065: 'i' : undeclared identifier

原因:是由于存在以下的代碼段:

for (int i = 0; i < MAX_LEN; i ++)

{

   //……

}

for (i = 0; i < MAX_NUM; i ++)

{

    //……

}

對于evc離開循環後,循環變量仍然有效,并且仍可以使用,但是在VS2005下是不行的,由此可見VS2005對變量的定義與審查更為嚴格,還有就是對數組越界問題也比EVC來的強。

解決方法:(不能完全相信編譯器,也不能把所有的文法檢查都丢給編譯器)

int i = 0;

for (i = 0; i < MAX_LEN; i ++)

{

    //……

}

for (i = 0; i < MAX_NUM; i ++)

{

     //……

}

3、error C2664: '_wcsnicmp' : cannot convert parameter 2 from 'LPWORD' to 'const wchar_t *'

 需要 強制類型轉換。

4、error C2061: syntax error : identifier 'HELPINFO'

自己 增加HELPINFO的類型,增加頭檔案 HelpInfo.h。

5、error C2146: syntax error : missing ';' before identifier 'm_wndCommandBar'

原因:在Windows Mobile 5.0/6.0 下CCeCommandBar類被CCommandBar替換

解決方法:

CCeCommandBar   m_wndCommandBar; ---- 〉CCommandBar   m_wndCommandBar;

6、error C2065: 'NUM_TOOL_TIPS' : undeclared identifier

解決:

//#if defined(_WIN32_WCE_PSPC) && (_WIN32_WCE >= 212)

#define NUM_TOOL_TIPS 8

//#endif

7、error C3861: 'ON_WM_HELPINFO': identifier not found

同 4

8、error C2440: 'static_cast' : cannot convert from 'void (__cdecl CMyAppView::* )(void)' to 'LRESULT (__cdecl CWnd::* )(WPARAM,LPARAM)'None of the functions with this name in scope match the target type

解決方法:

afx_msg void OnHotLinkExplain();  --- 〉

afx_msg LRESULT OnHotLinkExplain(WPARAM wParam,LPARAM lParam);

9、error C2664: 'CSize CDC::GetTextExtent(LPCTSTR,int) const' : cannot convert parameter 1 from 'WORD *' to 'LPCTSTR'

Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast需要 強制轉換

pDC->GetTextExtent(&i, 1).cx);   ——>

pDC->GetTextExtent((LPCTSTR)&i, 1).cx;

10、error C2039: 'OnHelpInfo' : is not a member of 'CView'

error C2039: 'OnHelpInfo' : is not a member of 'CFrameWnd'

error C2039: 'OnHelpInfo' : is not a member of 'CDialog'

解決方法:用TRUE替換相應的類成員函數OnHelpInfo'

return CView::OnHelpInfo(pHelpInfo); ——> return TRUE;

11、error C2039: 'm_bShowSharedNewButton' : is not a member of 'CCommandBar'

D:/Program Files/Microsoft Visual Studio 8/VC/ce/atlmfc/include/afxext.h(557) : see declaration of 'CCommandBar'

解決方法:

直接注釋掉 m_wndCommandBar.m_bShowSharedNewButton = FALSE;

12、./MyApp.rc(380) : fatal error RC1015: cannot open include file 'wceres.rc'.

解決方法:

直接注釋掉:#include "wceres.rc"         // WCE-specific components

但是,這個錯誤很讨厭, 每次你修改資源檔案後,都得修改該語句,不知道為什麼。

13、Resease 模式下也要修改

error LNK2019: unresolved external symbol SHInitExtraControls referenced in function "protected: __cdecl CMyAppView::CMyAppView(void)" ( [email protected]@[email protected])

問題:程式中調用了SHInitExtraControls();

error LNK2019: unresolved external symbol SHSipPreference referenced in function "protected: void __cdecl CMyAppView::OnKillfocusWord(void)" ( [email protected]@@IAAXXZ)

問題:程式中調用了SHSipPreference

以上兩個函數都在:Library: aygshell.lib裡

解決方法:

工程-->屬性-->Linker -->input -- > Additional Denpendencies :aygshell.lib

14、Resease 模式下也要修改

orelibc.lib(wwinmain.obj) : error LNK2019: unresolved external symbol wWinMain referenced in function wWinMainCRTStartup

屬性—〉Linker—〉Anvanced—〉EntryPoint

将 wWinMainCRTStartup 更改為 WinMainCRTStartup

Entry Point是WinMainCRTStartup(ANSI)或wWinMainCRTStartup(UINCODE),即: ... WinMainCRTStartup 或wWinMainCRTStartup 會調用WinMain 或wWinMain。

15、  error C3861: 'LoadStdProfileSettings': identifier not found

注釋掉函數 LoadStdProfileSettings;

該函數的具體功能,看MSDN。 

       BTW:編譯的時候,有可能會出現一些由以上錯誤産生的連鎖錯誤,俗稱“蝴蝶效應”,如error C2143: syntax error : missing ';' before '}'

error C2143: syntax error : missing ';' before ','

error C2143: syntax error : missing ';' before '{'

少了了'{'、'}'、';'等等,把以上的錯誤—主要沖突解決了,這些錯誤—錯誤沖突也就迎刃而解了。何況,這個工程是以前在EVC IDE下編譯通過,MS再怎麼優化或改進編譯器,也總不可能發生自相沖突的事情吧,總要考慮相容性吧,要對自己或公司的前輩有信心!

      到此,已經能夠編譯通過,但是運作的時候,又出現如下的問題:

16、Resease 模式下也要修改

按F5,出現如下的對話框:

關于報Internet Services錯誤的問題

解決方法:

 右擊工程的屬性—〉General—〉Project Defaults –〉Use MFC :

Use MFC in a shared DLL ——> Use MFC in a static DLL

也正是因為這個,VS2005産生的EXE程式比EVC産生的要大200多k。   //以下從另外一個地方得來的知識和自己移植發現的問題[GXH] 17、Internet Services需要移植

According to MSDN documentation, these classes were dropped from MFC. If I try to use any of these classes I get the following error message:

Fatal error C1189: #error :  Internet Services classes not supported in this

library variant.

I traced the problem and found the following code in afxinet.h

#ifdef _AFX_NO_INET_SUPPORT

#error Internet Services classes not supported in this library variant.

#endif

My question is: Is there any replacement classes to the above ones?

In general, for working/functional classes from MFC4 the advice we've been giving people is to look at whether they can lift the source for the class from MFC4 and make it part of their project (or compile it into a static lib, and link that in, etc.). The classes above were probably cut for size reasons, or because the behaviour they wrapped was easily accessible in another way (yes, in many cases this turned out to be the wrong thing to do). In other cases, the cut classes never worked, or never really made sense on CE-based devices.

This problem has been solved in VS2005 SP1 according to MSDN.

18、CBitmapButton需要移植

VS2005 removed this class from MFC, just directly copy it from other MFC's source file winbtn.cpp can solve this problem.

繼續閱讀