703
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Drawing;
using Emgu.CV; //Emgu
using Emgu.CV.Structure;
using System.Runtime.InteropServices;
namespace DectFunct
{
[Guid("6B4ED5B9-5356-42E3-A6CA-1A242F91583A")]
public interface IComInterface
{
//[DllExport("Dect", CallingConvention = CallingConvention.StdCall)]
[DispId(1)]
int Dect(int x_allspace, int y_allspace, int x_space, int dead_sum, int pic_name);
[DispId(2)]
string COMINFO { get; }
[DispId(3)]
int add(int x_allspace, int y_allspace);
}
[Guid("1A8EB38C-E732-49B2-A897-B40FFD744E3D")]
public class Class1 : IComInterface
{
public int Dect(int x_allspace, int y_allspace, int x_space, int dead_sum, int pic_name)
{
int result = 0;
float hexagon_L = x_space;
Image<Bgr, Byte> image_Source;
//String openFile = pic_name + ".png";
string name = Convert.ToString(pic_name);
String openFile = name + ".bmp";
image_Source = new Image<Bgr, byte>(openFile);
if (image_Source != null)
result = 1;
return result;
}
public string COMINFO
{
get
{
return "com 測試";
}
}
public int add(int x, int y)
{
int z = 0;
z = x + y;
return z;
}
}
#pragma hdrstop
#include <iostream>
#include <vcl.h>
#include "Dectfunct_tlb.h"
using namespace std;
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
HRESULT hr;
//初始化COM
CoInitialize ( NULL );
Dectfunct_tlb::IComInterfacePtr ptr;
hr = ptr.CreateInstance(__uuidof (Dectfunct_tlb::Class1));
if(hr == S_OK)
{
cout << ptr->add (32, 16)<<endl;
cout << ptr->Dect (32, 16, 3, 1, 1)<<endl;
BSTR outp = NULL;
ptr->get_COMINFO(&outp);
cout<<AnsiString(outp)<<endl;
}
CoUninitialize ();
system("pause");
return 0;
}