メインメニューを開く

差分

== DLLのコード ==
=== ヘッダーファイル(*.h) ===
<source syntaxhighlight lang="cpp">
#ifndef DLLAPI
#define DLLAPI extern "C" __declspec(dllimport)
DLLAPI long __stdcall _Sum(const long p_Number1, const long p_Number2);
</sourcesyntaxhighlight
=== コードファイル(*.cpp) ===
<source syntaxhighlight lang="cpp">
#define DLLAPI
return p_Number1 + p_Number2;
}
</sourcesyntaxhighlight
=== モジュール定義ファイル(*.def) ===
<source syntaxhighlight lang="cpptext">
LIBRARY CppDll
EXPORTS
_Sum
</sourcesyntaxhighlight>
== C♯のプロジェクト作成 ==
MVVMモデルでサンプルを作ったからビューモデルが入っているけど…DLLを呼ぶには必要ないから無視してね。
=== モデル ===
<source syntaxhighlight lang="csharpC#">
using System;
using System.Collections.Generic;
}
}
</sourcesyntaxhighlight
=== ビュー ===
<source syntaxhighlight lang="xml">
<Window x:Class="CSharpToCDLL.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
</Grid>
</Window>
</sourcesyntaxhighlight
=== ビューモデル ===
<source syntaxhighlight lang="csharpC#">
using System;
using System.Collections.Generic;
}
}
</sourcesyntaxhighlight>
[[Category:C♯]]
[[Category:C++]]
[[Category:dll]]