Skip to content

Commit

Permalink
Add c++ test dll.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielFabian committed Feb 28, 2015
1 parent 2acdc0b commit 03c9452
Show file tree
Hide file tree
Showing 11 changed files with 406 additions and 2 deletions.
34 changes: 34 additions & 0 deletions FSharp.InteropServices.Dynamic.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,50 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
build.fsx = build.fsx
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestDll", "TestDll\TestDll.vcxproj", "{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|Mixed Platforms = Release|Mixed Platforms
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1A21652C-E09A-4305-B901-43F701BB5900}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1A21652C-E09A-4305-B901-43F701BB5900}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1A21652C-E09A-4305-B901-43F701BB5900}.Debug|ARM.ActiveCfg = Debug|Any CPU
{1A21652C-E09A-4305-B901-43F701BB5900}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{1A21652C-E09A-4305-B901-43F701BB5900}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{1A21652C-E09A-4305-B901-43F701BB5900}.Debug|Win32.ActiveCfg = Debug|Any CPU
{1A21652C-E09A-4305-B901-43F701BB5900}.Debug|x64.ActiveCfg = Debug|Any CPU
{1A21652C-E09A-4305-B901-43F701BB5900}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1A21652C-E09A-4305-B901-43F701BB5900}.Release|Any CPU.Build.0 = Release|Any CPU
{1A21652C-E09A-4305-B901-43F701BB5900}.Release|ARM.ActiveCfg = Release|Any CPU
{1A21652C-E09A-4305-B901-43F701BB5900}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{1A21652C-E09A-4305-B901-43F701BB5900}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{1A21652C-E09A-4305-B901-43F701BB5900}.Release|Win32.ActiveCfg = Release|Any CPU
{1A21652C-E09A-4305-B901-43F701BB5900}.Release|x64.ActiveCfg = Release|Any CPU
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Debug|Any CPU.ActiveCfg = Debug|Win32
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Debug|ARM.ActiveCfg = Debug|Win32
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Debug|Mixed Platforms.ActiveCfg = Debug|x64
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Debug|Mixed Platforms.Build.0 = Debug|x64
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Debug|Win32.ActiveCfg = Debug|Win32
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Debug|Win32.Build.0 = Debug|Win32
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Debug|x64.ActiveCfg = Debug|Win32
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Release|Any CPU.ActiveCfg = Release|Win32
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Release|ARM.ActiveCfg = Release|Win32
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Release|Mixed Platforms.Build.0 = Release|Win32
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Release|Win32.ActiveCfg = Release|Win32
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Release|Win32.Build.0 = Release|Win32
{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
13 changes: 11 additions & 2 deletions FSharp.InteropServices.Dynamic/Script.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ open System
open FSharp.InteropServices.Dynamic
open System.Text

let (++) x y = System.IO.Path.Combine(x, y)

let user32 = Library("user32.dll")

let test =
Expand All @@ -28,6 +30,13 @@ let test3 : int =
user32?MessageBox(0, "Hello world", "MyTitle", 0)
user32?MessageBox(0, "Hello world", "MyTitle", 0)

let testDll =
match IntPtr.Size with
| 4 -> Library(__SOURCE_DIRECTORY__ ++ ".." ++ "Debug" ++ "TestDll.dll")
| _ -> Library(__SOURCE_DIRECTORY__ ++ ".." ++ "x64" ++ "Debug" ++ "TestDll.dll")

let test4 : unit =
let w, h = ref 0, ref 0
user32?twoRefInts(w, h)
let forty, two = ref 0, ref 0
testDll?setArgs(forty, two)

printfn "%A" (forty, two)
40 changes: 40 additions & 0 deletions TestDll/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
========================================================================
DYNAMIC LINK LIBRARY : TestDll Project Overview
========================================================================

AppWizard has created this TestDll DLL for you.

This file contains a summary of what you will find in each of the files that
make up your TestDll application.


TestDll.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.

TestDll.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).

TestDll.cpp
This is the main DLL source file.

/////////////////////////////////////////////////////////////////////////////
Other standard files:

StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named TestDll.pch and a precompiled types file named StdAfx.obj.

/////////////////////////////////////////////////////////////////////////////
Other notes:

AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.

/////////////////////////////////////////////////////////////////////////////
28 changes: 28 additions & 0 deletions TestDll/TestDll.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// TestDll.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include "TestDll.h"


// This is an example of an exported variable
TESTDLL_API int nTestDll=0;

// This is an example of an exported function.
TESTDLL_API int fnTestDll(void)
{
return 42;
}

TESTDLL_API void setArgs(int* x, int* y)
{
*x = 4;
*y = 2;
}

// This is the constructor of a class that has been exported.
// see TestDll.h for the class definition
CTestDll::CTestDll()
{
return;
}
25 changes: 25 additions & 0 deletions TestDll/TestDll.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the TESTDLL_EXPORTS
// symbol defined on the command line. This symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// TESTDLL_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#ifdef TESTDLL_EXPORTS
#define TESTDLL_API __declspec(dllexport)
#else
#define TESTDLL_API __declspec(dllimport)
#endif

// This class is exported from the TestDll.dll
class TESTDLL_API CTestDll {
public:
CTestDll(void);
// TODO: add your methods here.
};

extern TESTDLL_API int nTestDll;
extern "C" {
TESTDLL_API void setArgs(int* x, int* y);
}

TESTDLL_API int fnTestDll(void);
175 changes: 175 additions & 0 deletions TestDll/TestDll.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{F9908D10-BEB3-46B2-809F-0BA6DB9684BE}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>TestDll</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TESTDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TESTDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TESTDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;TESTDLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
<ClInclude Include="TestDll.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
</PrecompiledHeader>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
<CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
</PrecompiledHeader>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="TestDll.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
42 changes: 42 additions & 0 deletions TestDll/TestDll.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="TestDll.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="TestDll.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="dllmain.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
Loading

0 comments on commit 03c9452

Please sign in to comment.