I have imported an Activex component (*.ocx) on Embarcadero C++Builder 10.2 when I build the program I get this warning "Warning W8127 Function defined with different linkage".
Can any one tell me how I can resolve this issue. My code is below:
#include <vcl.h>
#pragma hdrstop
#include <System.Win.ComServ.hpp>
#include <axbase.h>
#include <olectl.h>
#pragma package(smart_init)
#pragma link "System.Win.ComServ"
#pragma package(smart_init)
#pragma link "System.Win.ComServ"
// -----------------------------------------------------------------------------
// Entry point of your Server invoked by Windows for processes or threads are
// initialized or terminated.
//
// -----------------------------------------------------------------------------
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
return TRUE;
}
// -----------------------------------------------------------------------------
// Entry point of your Server invoked to inquire whether the DLL is no
// longer in use and should be unloaded.
// -----------------------------------------------------------------------------
STDAPI __export DllCanUnloadNow(void)
{
Comserv::TComServer* comserver = Comserv::GetComServer();
return (!comserver ||
((comserver->ObjectCount /* + comserver->FactoryCount */) == 0)) ?
S_OK : S_FALSE;
}
// -----------------------------------------------------------------------------
// Entry point of your Server allowing OLE to retrieve a class object from
// your Server
// -----------------------------------------------------------------------------
STDAPI __export DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
Comobj::TComObjectFactory* Factory = Comobj::ComClassManager()->GetFactoryFromClassID(rclsid);
if (Factory)
{
if (Factory->GetInterface(riid, ppv))
return S_OK;
else
return E_NOINTERFACE;
}
else
{
*ppv = 0;
return CLASS_E_CLASSNOTAVAILABLE;
}
}
// -----------------------------------------------------------------------------
// Entry point of your Server invoked to instruct the server to create
// registry entries for all classes supported by the module
// -----------------------------------------------------------------------------
STDAPI __export DllRegisterServer(void)
{
Comserv::TComServer* comserver = Comserv::GetComServer();
if (comserver)
{
try
{
comserver->LoadTypeLib();
comserver->UpdateRegistry(true);
return S_OK;
}
catch(...)
{
return E_FAIL;
}
}
else
{
return E_FAIL;
}
}
// -----------------------------------------------------------------------------
// Entry point of your Server invoked to instruct the server to remove
// all registry entries created through DllRegisterServer.
// -----------------------------------------------------------------------------
STDAPI __export DllUnregisterServer(void)
{
Comserv::TComServer* comserver = Comserv::GetComServer();
if (comserver)
{
try
{
comserver->LoadTypeLib();
comserver->UpdateRegistry(false);
return S_OK;
}
catch(...)
{
return E_FAIL;
}
}
else
{
return E_FAIL;
}
}
// ------------------------------------------------------------------------------
// Entry point of your Server installation/setup. Used for 'PerUser' registration
// Invoked via call to "regsvr32 /n /i:user [/u] axlibrary.dll"
// ------------------------------------------------------------------------------
STDAPI __export DllInstall(BOOL bInstall, LPCWSTR pszCmdLine)
{
Comserv::TComServer* comserver = Comserv::GetComServer();
if (comserver)
{
bool savePerUser = comserver->PerUserRegistration;
if (pszCmdLine && !StrIComp(pszCmdLine, L"user"))
comserver->PerUserRegistration = true;
else
comserver->PerUserRegistration = false;
HRESULT result = E_FAIL;
if (bInstall)
{
result = DllRegisterServer();
if (result == E_FAIL)
DllUnregisterServer();
}
else
result = DllUnregisterServer();
comserver->PerUserRegistration = savePerUser;
return result;
}
else
{
return E_FAIL;
}
}
The functions DllCanUnloadNow()
and DllGetClassObject
are declared in this header file "comebaseapi.h" as follow:
_Check_return_
STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Outptr_ LPVOID FAR* ppv);
__control_entrypoint(DllExport)
STDAPI DllCanUnloadNow(void);
The functions DllRegisterServer()
and DllUnregisterServer()
are declared in this header file "olectl.h" as follow:
__control_entrypoint(DllExport)
STDAPI DllRegisterServer(void);
__control_entrypoint(DllExport)
STDAPI DllUnregisterServer(void);
The function DllInstall()
is declared in this header file "shlwapi.h" as follow:
// DllInstall (to be implemented by self-installing DLLs)
STDAPI DllInstall(BOOL bInstall, _In_opt_ PCWSTR pszCmdLine);
I thank you for your support.