C++側
ヘッダ
1 2 3 4 5 6 |
#pragma once extern "C" { __declspec(dllexport) void Test(char* buf); } |
ソース
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#include <iostream> #include "library.h" void Test(char* buf) { std::cout << "Cの関数が呼び出されました。" << std::endl; buf[0] = 'a'; buf[1] = 'b'; buf[2] = 'c'; system("pause"); //return true; } |
C++で作成したDLLは、VB.NETアプリのexeと同階層に出力されるように設定しておく。
VB.NET側
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Imports System.Runtime.InteropServices Module Module1 <DllImport("Library", CallingConvention:=CallingConvention.Cdecl)> Private Sub Test(ByVal str As System.Text.StringBuilder) End Sub Sub Main() Dim a As New System.Text.StringBuilder(256) Test(a) Debug.WriteLine(a) End Sub End Module |
この記事へのコメントはありません。