Visual Studio 2005 problem with attributed code
I get lots of errors when compiling this file under VS2005, but none when compiling under VS2003. I
want to override DllMain, DllRegisterServer, and DllUnregisterServer. I have not found any notes on
converting attributes for VS2005. Any suggestions?
Thanks,
Frank
// CloakBHO.cpp : Implementation of DLL Exports.
#include "stdafx.h"
#include "resource.h"
#include "General.h"
#include "cpIndentTrace.h"
#include "globals.h"
#include "functions.h"
// The module attribute causes DllMain, DllRegisterServer and DllUnregisterServer to be
automatically implemented for you
[ module(dll,
uuid = "{D6C367C6-6640-447F-B7AD-C5B59AC14CCB}",
name = "TurboPasswordsBHO",
helpstring = "TurboPasswords 1.0 Type Library",
resource_name = "IDR_FLOUNDERBHO"),
]
class CFlounderBHOModule
{
public:
// Override CAtlDllModuleT members
//CFlounderBHOModule();
BOOL WINAPI DllMain (DWORD dwReason, LPVOID /*lpReserved*/);
HRESULT DllRegisterServer (BOOL bRegTypeLib = TRUE);
HRESULT DllUnregisterServer (BOOL bUnRegTypeLib = TRUE);
};
HRESULT CFlounderBHOModule::DllRegisterServer(BOOL bRegTypeLib /*= TRUE*/) throw()
{
HRESULT hr = __super::DllRegisterServer(bRegTypeLib);
// Register the BHO and extensions.
if(SUCCEEDED(hr))
hr = UpdateRegistryFromResource(IDR_FLOUNDERBHO, bRegTypeLib, NULL);
return hr;
}
HRESULT CFlounderBHOModule::DllUnregisterServer(BOOL bUnRegTypeLib /*= TRUE*/) throw()
{
HRESULT hr = __super::DllUnregisterServer(bUnRegTypeLib);
// Unregister the BHO and extensions.
if (SUCCEEDED(hr))
hr = UpdateRegistryFromResource(IDR_FLOUNDERBHO, !bUnRegTypeLib, NULL);
return hr;
}
BOOL WINAPI CFlounderBHOModule::DllMain(DWORD dwReason, LPVOID /* lpReserved */) throw()
{
LPVOID lpvData;
BOOL fIgnore;
switch (dwReason)
{
// The DLL is loading due to process
// initialization or a call to LoadLibrary.
case DLL_PROCESS_ATTACH:
{
if (CAtlBaseModule::m_bInitFailed)
{
ATLASSERT(0);
return FALSE;
}
#if defined(_ATL_MIN_CRT) && !defined(USE_TLS)
DisableThreadLibraryCalls(_AtlBaseModule.GetModuleInstance());
#endif
// Check who's loading us.
// If it's Explorer then "no thanks" and exit...
TCHAR pszLoader[MAX_PATH];
GetModuleFileName(NULL, pszLoader, MAX_PATH);
_tcslwr(pszLoader);
if (_tcsstr(pszLoader, _T("explorer.exe")))
return FALSE;
}
// no break, fall through to DLL_THREAD_ATTACH
case DLL_PROCESS_DETACH:
{
}
break;
}
return TRUE; // ok
}
------ Build started: Project: BHO, Configuration: Debug Win32 ------
Compiling...
CloakBHO.cpp
\cloakbho.cpp(16) : error C2059: syntax error : ']'
\cloakbho.cpp(18) : error C2143: syntax error : missing ';' before '{'
\cloakbho.cpp(18) : error C2447: '{' : missing function header (old-style formal list?)
\cloakbho.cpp(30) : error C2653: 'CFlounderBHOModule' : is not a class or namespace name
\cloakbho.cpp(30) : error C3646: 'throw' : unknown override specifier
\cloakbho.cpp(31) : error C2091: function returns function
\cloakbho.cpp(32) : error C2653: '__super' : is not a class or namespace name
\cloakbho.cpp(32) : error C2440: 'initializing' : cannot convert from 'HRESULT (__cdecl *)(void)' to
'HRESULT'
There is no context in which this conversion is possible
\cloakbho.cpp(36) : error C3861: 'UpdateRegistryFromResourceD': identifier not found
\cloakbho.cpp(38) : error C2440: 'return' : cannot convert from 'HRESULT' to 'HRESULT (__cdecl *)(void)'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or
function-style cast
\cloakbho.cpp(41) : error C2653: 'CFlounderBHOModule' : is not a class or namespace name
\cloakbho.cpp(43) : error C2790: 'super' : this keyword can only be used within the body of class
member function
\cloakbho.cpp(43) : error C2337: 'DllUnregisterServer' : attribute not found
\cloakbho.cpp(47) : error C3861: 'UpdateRegistryFromResourceD': identifier not found
\cloakbho.cpp(51) : error C2653: 'CFlounderBHOModule' : is not a class or namespace name
\cloakbho.cpp(64) : error C2337: 'm_bInitFailed' : attribute not found
\cloakbho.cpp(64) : error C2065: 'm_bInitFailed' : undeclared identifier
Build log was saved at "file://\Debug\BuildLog.htm"
BHO - 17 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========