2014-02-11 8 views
3

올바르게 C++/ATL 프로젝트를 빌드하십시오. MFC 코드를 ATL (서비스 EXE) 프로젝트에 사용하려고합니다. 나는 내 모든 Existing Item을 포함 시켰습니다.오류 : 'CAtlServiceModuleT': 'ATL'의 구성원이 아닙니다.

error C2039: 'CAtlServiceModuleT' : is not a member of 'ATL'.

을 그리고, 디버거가 표시된 라인을 강조했다 : 나는 Use MFC in a Shared DLL에 프로젝트를 구성한 경우 디버깅하는 동안, 나는이 오류 메시지가 했어 내가 그것을 어떻게 해결합니까

class CATLProject6Module : public ATL::CAtlServiceModuleT< CATLProject6Module, IDS_SERVICENAME > //this one 
{ 
public : 
    DECLARE_LIBID(LIBID_ATLProject6Lib) 
    DECLARE_REGISTRY_APPID_RESOURCEID(IDR_ATLPROJECT6, "{3A7F25E3-CA7E-4C90-8B37-11DA70E42248}") 
     HRESULT InitializeSecurity() throw() 
    { 
     // TODO : Call CoInitializeSecurity and provide the appropriate security settings for your service 
     // Suggested - PKT Level Authentication, 
     // Impersonation Level of RPC_C_IMP_LEVEL_IDENTIFY 
     // and an appropriate Non NULL Security Descriptor. 

     return S_OK; 
    } 
    }; 

CATLProject6Module _AtlModule; 

을, 제발?

당신은 여기 내 stdafx.h 찾을 수 있습니다

// stdafx.h : include file for standard system include files, 
// or project specific include files that are used frequently, 
// but are changed infrequently 

#if !defined(AFX_STDAFX_H__91E578F6_59F0_4867_BDE7_FCC229588C74__INCLUDED_) 
#define AFX_STDAFX_H__91E578F6_59F0_4867_BDE7_FCC229588C74__INCLUDED_ 

#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 

#define VC_EXTRALEAN  // Exclude rarely-used stuff from Windows headers 

#define _WIN32_WINNT 0x0502 //so that I can use ReadDirectoryChanges 

#include <afxwin.h>   // MFC core and standard components 
#include <afxext.h>   // MFC extensions 
#include <afxdtctl.h>  // MFC support for Internet Explorer 4 Common Controls 
#ifndef _AFX_NO_AFXCMN_SUPPORT 
#include <afxcmn.h>   // MFC support for Windows Common Controls 
#endif // _AFX_NO_AFXCMN_SUPPORT 


//{{AFX_INSERT_LOCATION}} 
// Microsoft Visual C++ will insert additional declarations immediately before the previous line. 

#endif // !defined(AFX_STDAFX_H__91E578F6_59F0_4867_BDE7_FCC229588C74__INCLUDED_) 


#ifndef STRICT 
    #define STRICT 
#endif 

#include "targetver.h" 

#define _ATL_FREE_THREADED 

#define _ATL_NO_AUTOMATIC_NAMESPACE 

#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 


#define ATL_NO_ASSERT_ON_DESTROY_NONEXISTENT_WINDOW 

#include "resource.h" 
#include <atlbase.h> 
#include <atlcom.h> 
#include <atlctl.h> 

감사합니다 많이!

답변

0

큰 문제는 서로 다른 개념의 두 가지 유사한 것을 섞어 놓는 것입니다.

MFC와 ATL은 기본 클래스가 내부 프로그램 기능 (메시지 루프, 등록 등)을 지원할 수있는 방법을 제공합니다.

먼저 MFC 헤더를 포함하면 모듈 (CAtlServiceModuleT 템플릿 포함)의 클래스가 제외됩니다. #ifndef _AFX 헤더 파일을 참조하십시오.

먼저 atl 헤더를 포함하여이를 해결할 수 있습니다. 그러나 tha afx.h 헤더를 포함하기 전에 #undef WINDOWS해야합니다. 하지만 이건 해킹입니다!

아마도 더 좋은 방법은 기본 클래스로 MFC 프레임 워크를 사용하는 것입니다. 그 이유는 간단합니다 : 기존 CWinApp의 대부분의 MFC 릴레이 ... 그래서 이것을 필요로합니다. 그러나 이것을 사용할 때 더 이상 CAtlServiceModuleT가 필요하지 않습니다!

+2

답장을 보내 주셔서 감사합니다. 왜 그것이 '해킹'인지 말해 주실 수 있습니까? –

+0

MFC 헤더에 Windows 헤더가 기본으로 포함되어 있기 때문에 해킹입니다. 가드가 정의되지 않았기 때문에 Header에는 두 번 포함됩니다. 가장 좋은 방법은 MFC를 주 인스턴스로 사용하고 ATL 파트를 포함하는 것입니다. 내가 작성한대로 : MFC는 CWinApp에서만 작동합니다. 그래서 너는 그것을 필요로한다. 그렇다면 왜 ATL 모듈을 사용해야합니까? – xMRi

+2

서비스로 앱을 실행하고 RAM 사용을 최적화해야합니다. –