Правильно строит проект C++/ATL: Я пытаюсь использовать код MFC в проекте ATL (Service EXE). В котором я включил все мои Existing Item
. Когда я настроил проект Use MFC in a Shared DLL
, я имел это сообщение об ошибке при отладке:Ошибка: 'CAtlServiceModuleT': не является членом 'ATL'
error C2039: 'CAtlServiceModuleT' : is not a member of 'ATL'.
И, отладчик подчеркнул отмеченную строку:
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>
Спасибо большое !!
Спасибо за ваш ответ, это интересно знать. Не могли бы вы рассказать мне, почему это «взломать»? –
Это взломать, потому что заголовки MFC включают заголовок Windows по умолчанию. Теперь заголовок включает два раза, потому что защита не определена. Лучший способ - использовать MFC в качестве основного экземпляра и включить в него части ATL. Как я писал: MFC работает только с CWinApp. Так вам это нужно. Итак, почему вы должны использовать модуль ATL? – xMRi
Мне нужно запустить приложение в качестве сервиса и оптимизировать его использование ОЗУ. –