Try to change to MFC extension DLL
This commit is contained in:
@@ -2,78 +2,9 @@
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "SiaDrive.Api.h"
|
||||
#include <curl\curl.h>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//
|
||||
//TODO: If this DLL is dynamically linked against the MFC DLLs,
|
||||
// any functions exported from this DLL which call into
|
||||
// MFC must have the AFX_MANAGE_STATE macro added at the
|
||||
// very beginning of the function.
|
||||
//
|
||||
// For example:
|
||||
//
|
||||
// extern "C" BOOL PASCAL EXPORT ExportedFunction()
|
||||
// {
|
||||
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
||||
// // normal function body here
|
||||
// }
|
||||
//
|
||||
// It is very important that this macro appear in each
|
||||
// function, prior to any calls into MFC. This means that
|
||||
// it must appear as the first statement within the
|
||||
// function, even before any object variable declarations
|
||||
// as their constructors may generate calls into the MFC
|
||||
// DLL.
|
||||
//
|
||||
// Please see MFC Technical Notes 33 and 58 for additional
|
||||
// details.
|
||||
//
|
||||
|
||||
// CSiaDriveApiApp
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSiaDriveApiApp, CWinApp)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
// CSiaDriveApiApp construction
|
||||
|
||||
CSiaDriveApiApp::CSiaDriveApiApp()
|
||||
{
|
||||
// TODO: add construction code here,
|
||||
// Place all significant initialization in InitInstance
|
||||
}
|
||||
|
||||
|
||||
// The one and only CSiaDriveApiApp object
|
||||
|
||||
CSiaDriveApiApp theApp;
|
||||
|
||||
|
||||
// CSiaDriveApiApp initialization
|
||||
|
||||
BOOL CSiaDriveApiApp::InitInstance()
|
||||
{
|
||||
CWinApp::InitInstance();
|
||||
|
||||
if (!AfxSocketInit())
|
||||
{
|
||||
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
curl_global_init(CURL_GLOBAL_WIN32);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int CSiaDriveApiApp::ExitInstance()
|
||||
{
|
||||
curl_global_cleanup();
|
||||
|
||||
return CWinApp::ExitInstance();
|
||||
}
|
||||
|
@@ -1,29 +0,0 @@
|
||||
// SiaDrive.Api.h : main header file for the SiaDrive.Api DLL
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __AFXWIN_H__
|
||||
#error "include 'stdafx.h' before including this file for PCH"
|
||||
#endif
|
||||
|
||||
#include "resource.h" // main symbols
|
||||
|
||||
|
||||
// CSiaDriveApiApp
|
||||
// See SiaDrive.Api.cpp for the implementation of this class
|
||||
//
|
||||
|
||||
class CSiaDriveApiApp : public CWinApp
|
||||
{
|
||||
public:
|
||||
CSiaDriveApiApp();
|
||||
|
||||
// Overrides
|
||||
public:
|
||||
virtual BOOL InitInstance();
|
||||
|
||||
virtual int ExitInstance();
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
@@ -90,7 +90,7 @@
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>TTMATH_NOASM;_AFXEXT;CURL_STATICLIB;WIN32;_WINDOWS;_DEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;_AFXEXT;TTMATH_NOASM;CURL_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\3rd-party\ttmath-0.9.3;..\3rd-party\curl-7.52.1\include;.\;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@@ -98,6 +98,7 @@
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<ModuleDefinitionFile>.\SiaDrive.Api.def</ModuleDefinitionFile>
|
||||
<AdditionalDependencies>..\3rd-party\curl-7.52.1\build\Win32\VC14\LIB Debug\libcurld.lib</AdditionalDependencies>
|
||||
<AdditionalOptions>/verbose:lib %(AdditionalOptions)</AdditionalOptions>
|
||||
</Link>
|
||||
<Midl>
|
||||
<MkTypLibCompatible>false</MkTypLibCompatible>
|
||||
@@ -139,7 +140,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>TTMATH_NOASM;_AFXEXT;CURL_STATICLIB;WIN32;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_WINDOWS;_LIB;TTMATH_NOASM;_AFXEXT;CURL_STATICLIB;WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\3rd-party\ttmath-0.9.3;..\3rd-party\curl-7.52.1\include;.\;</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@@ -167,7 +168,7 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>TTMATH_NOASM;_AFXEXT;CURL_STATICLIB;_WINDOWS;NDEBUG;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>TTMATH_NOASM;_AFXEXT;CURL_STATICLIB;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>..\3rd-party\ttmath-0.9.3;..\3rd-party\curl-7.52.1\include;.\</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
@@ -191,6 +192,20 @@
|
||||
<Text Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
</PrecompiledHeader>
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
</PrecompiledHeader>
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
</PrecompiledHeader>
|
||||
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="SiaApi.cpp" />
|
||||
<ClCompile Include="SiaCommon.cpp" />
|
||||
<ClCompile Include="SiaCurl.cpp" />
|
||||
@@ -213,7 +228,6 @@
|
||||
<ClInclude Include="SiaApi.h" />
|
||||
<ClInclude Include="SiaCommon.h" />
|
||||
<ClInclude Include="SiaCurl.h" />
|
||||
<ClInclude Include="SiaDrive.Api.h" />
|
||||
<ClInclude Include="SiaDriveConfig.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
|
@@ -48,11 +48,11 @@
|
||||
<ClCompile Include="SiaFile.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="SiaDrive.Api.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="stdafx.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
70
SiaDrive.Api/dllmain.cpp
Normal file
70
SiaDrive.Api/dllmain.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
// dllmain.cpp : Defines the initialization routines for the DLL.
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <afxwin.h>
|
||||
#include <afxdllx.h>
|
||||
#include <curl\curl.h>
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
static AFX_EXTENSION_MODULE SiaDriveApiDLL = { NULL, NULL };
|
||||
|
||||
extern "C" int APIENTRY
|
||||
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
// Remove this if you use lpReserved
|
||||
UNREFERENCED_PARAMETER(lpReserved);
|
||||
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
TRACE0("SiaDrive.Api.DLL Initializing!\n");
|
||||
|
||||
// Extension DLL one-time initialization
|
||||
if (!AfxInitExtensionModule(SiaDriveApiDLL, hInstance))
|
||||
return 0;
|
||||
|
||||
// Insert this DLL into the resource chain
|
||||
// NOTE: If this Extension DLL is being implicitly linked to by
|
||||
// an MFC Regular DLL (such as an ActiveX Control)
|
||||
// instead of an MFC application, then you will want to
|
||||
// remove this line from DllMain and put it in a separate
|
||||
// function exported from this Extension DLL. The Regular DLL
|
||||
// that uses this Extension DLL should then explicitly call that
|
||||
// function to initialize this Extension DLL. Otherwise,
|
||||
// the CDynLinkLibrary object will not be attached to the
|
||||
// Regular DLL's resource chain, and serious problems will
|
||||
// result.
|
||||
|
||||
new CDynLinkLibrary(SiaDriveApiDLL);
|
||||
|
||||
// Sockets initialization
|
||||
// NOTE: If this Extension DLL is being implicitly linked to by
|
||||
// an MFC Regular DLL (such as an ActiveX Control)
|
||||
// instead of an MFC application, then you will want to
|
||||
// remove the following lines from DllMain and put them in a separate
|
||||
// function exported from this Extension DLL. The Regular DLL
|
||||
// that uses this Extension DLL should then explicitly call that
|
||||
// function to initialize this Extension DLL.
|
||||
if (!AfxSocketInit())
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
curl_global_init(CURL_GLOBAL_WIN32);
|
||||
}
|
||||
else if (dwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
TRACE0("SiaDrive.Api.DLL Terminating!\n");
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
// Terminate the library before destructors are called
|
||||
AfxTermExtensionModule(SiaDriveApiDLL);
|
||||
|
||||
}
|
||||
return 1; // ok
|
||||
}
|
@@ -7,7 +7,6 @@
|
||||
#ifndef VC_EXTRALEAN
|
||||
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
|
||||
#endif
|
||||
|
||||
#include "targetver.h"
|
||||
|
||||
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
|
||||
|
Reference in New Issue
Block a user