Skip to main content
本文に 16 文字追加
ソース リンク
maeda
  • 11
  • 3
class testDLL
{
    [DllImport("testDLL.dll", EntryPoint = ";func1";getTablePtr";)]
    public static extern IntPtr getTablePtr();
    [DllImport("testDLL.dll", EntryPoint = ";func2";getValFromTable";)]
    public static extern long getValFromTable(IntPtr ptrTable);
}
    
namespace DLLtest
{

    public partial class MainWindow : Window
    {
        IntPtr ptrT;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Start(object sender, RoutedEventArgs e)
        {
            ptrT = testDLL.getTablePtr();
            ret = testDLL.getValFromTable(ptrT);
        }
    }
}
class testDLL
{
    [DllImport("testDLL.dll", EntryPoint = ";func1";)]
    public static extern IntPtr getTablePtr();
    [DllImport("testDLL.dll", EntryPoint = ";func2";)]
    public static extern long getValFromTable(IntPtr ptrTable);
}
    
namespace DLLtest
{

    public partial class MainWindow : Window
    {
        IntPtr ptrT;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Start(object sender, RoutedEventArgs e)
        {
            ptrT = testDLL.getTablePtr();
            ret = testDLL.getValFromTable(ptrT);
        }
    }
}
class testDLL
{
    [DllImport("testDLL.dll", EntryPoint = ";getTablePtr";)]
    public static extern IntPtr getTablePtr();
    [DllImport("testDLL.dll", EntryPoint = ";getValFromTable";)]
    public static extern long getValFromTable(IntPtr ptrTable);
}
    
namespace DLLtest
{

    public partial class MainWindow : Window
    {
        IntPtr ptrT;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Start(object sender, RoutedEventArgs e)
        {
            ptrT = testDLL.getTablePtr();
            ret = testDLL.getValFromTable(ptrT);
        }
    }
}
本文に 5 文字追加
ソース リンク
cubick
  • 2.1万
  • 5
  • 27
  • 64

C++プログラム

/* C++プログラム */

// データテーブル
typedef struct{
    unsigned long v[0x10];
}TBL;

// テーブルのポインタ取得
extern "C" __declspec(dllexport) TBL* getTablePtr()
{
    TBL* ptrTable;
    /* 処理 */
    return(ptrTable);
}

// テーブルからデータ取得
extern "C" __declspec(dllexport) LONG  getValFromTable(TBL* ptrTable)
{
    /* 処理 */
    return(val);
}

C#プログラム

/* C#プログラム */

class testDLL
{
    [DllImport("testDLL.dll", EntryPoint = "func1")]
    public static extern IntPtr getTablePtr();
    [DllImport("testDLL.dll", EntryPoint = "func2")]
    public static extern long getValFromTable(IntPtr ptrTable);
}
    
namespace DLLtest
{

    public partial class MainWindow : Window
    {
        IntPtr ptrT;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Start(object sender, RoutedEventArgs e)
        {
            ptrT = testDLL.getTablePtr();
            ret = testDLL.getValFromTable(ptrT);
        }
    }
}
/* C++プログラム */

// データテーブル
typedef struct{
    unsigned long v[0x10];
}TBL;

// テーブルのポインタ取得
extern "C" __declspec(dllexport) TBL* getTablePtr()
{
    TBL* ptrTable;
    /* 処理 */
    return(ptrTable);
}

// テーブルからデータ取得
extern "C" __declspec(dllexport) LONG  getValFromTable(TBL* ptrTable)
{
    /* 処理 */
    return(val);
}
/* C#プログラム */

class testDLL
{
    [DllImport("testDLL.dll", EntryPoint = "func1")]
    public static extern IntPtr getTablePtr();
    [DllImport("testDLL.dll", EntryPoint = "func2")]
    public static extern long getValFromTable(IntPtr ptrTable);
}
    
namespace DLLtest
{

    public partial class MainWindow : Window
    {
        IntPtr ptrT;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Start(object sender, RoutedEventArgs e)
        {
            ptrT = testDLL.getTablePtr();
            ret = testDLL.getValFromTable(ptrT);
        }
    }
}

C++プログラム

// データテーブル
typedef struct{
    unsigned long v[0x10];
}TBL;

// テーブルのポインタ取得
extern "C" __declspec(dllexport) TBL* getTablePtr()
{
    TBL* ptrTable;
    /* 処理 */
    return(ptrTable);
}

// テーブルからデータ取得
extern "C" __declspec(dllexport) LONG  getValFromTable(TBL* ptrTable)
{
    /* 処理 */
    return(val);
}

C#プログラム

class testDLL
{
    [DllImport("testDLL.dll", EntryPoint = "func1")]
    public static extern IntPtr getTablePtr();
    [DllImport("testDLL.dll", EntryPoint = "func2")]
    public static extern long getValFromTable(IntPtr ptrTable);
}
    
namespace DLLtest
{

    public partial class MainWindow : Window
    {
        IntPtr ptrT;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Start(object sender, RoutedEventArgs e)
        {
            ptrT = testDLL.getTablePtr();
            ret = testDLL.getValFromTable(ptrT);
        }
    }
}
本文に 3 文字追加
ソース リンク
maeda
  • 11
  • 3
/* C#プログラム */

class testDLL
{
    [DllImport("testDLL.dll", EntryPoint = "func1")]
    public static extern IntPtr getTablePtr();
    [DllImport("testDLL.dll", EntryPoint = "func2")]
    public static extern long getValFromTable(IntPtr ptrTable);
}
    
namespace DLLtest
{

    public partial class MainWindow : Window
    {
        IntPtr ptrT;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Start(object sender, RoutedEventArgs e)
        {
            ptrT = testDLL.getTablePtr();
            ret = testDLL.getValFromTable(ptrT);
        }
    }
}
/* C#プログラム */

class testDLL
{
    [DllImport("testDLL.dll", EntryPoint = "func1")]
    public static extern IntPtr getTablePtr();
    [DllImport("testDLL.dll", EntryPoint = "func2")]
    public static extern long getValFromTable(IntPtr ptrTable);
    
namespace DLLtest
{

    public partial class MainWindow : Window
    {
        IntPtr ptrT;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Start(object sender, RoutedEventArgs e)
        {
            ptrT = testDLL.getTablePtr();
            ret = testDLL.getValFromTable(ptrT);
        }
    }
}
/* C#プログラム */

class testDLL
{
    [DllImport("testDLL.dll", EntryPoint = "func1")]
    public static extern IntPtr getTablePtr();
    [DllImport("testDLL.dll", EntryPoint = "func2")]
    public static extern long getValFromTable(IntPtr ptrTable);
}
    
namespace DLLtest
{

    public partial class MainWindow : Window
    {
        IntPtr ptrT;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void Start(object sender, RoutedEventArgs e)
        {
            ptrT = testDLL.getTablePtr();
            ret = testDLL.getValFromTable(ptrT);
        }
    }
}
本文に 149 文字追加
ソース リンク
maeda
  • 11
  • 3
読み込んでいます
本文に 79 文字追加
ソース リンク
maeda
  • 11
  • 3
読み込んでいます
ソース リンク
maeda
  • 11
  • 3
読み込んでいます