wpf调用VC++ dll

环境  VS2010

 

// DllDemo.h

#pragma once

using namespace System;

namespace DllDemo {

	public ref class MyValue
	{
		// TODO: 在此处添加此类的方法。
		int value;
	public: MyValue()
			{
				value = 123456789;
			}

	public: int printValue()
			{
				return value;
			}
	};
}

  

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using System.Runtime.InteropServices;

using DllDemo;

namespace WXDWXT_WPF
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {

        MyValue myv1;
        public MainWindow()
        {
            InitializeComponent();

            myv1 = new MyValue();
        }
        


        private void button1_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("" + myv1.printValue());
        }
    }
}

  

posted @ 2019-05-29 18:29  _守一  阅读(215)  评论(0编辑  收藏  举报