日期:2014-05-17 浏览次数:20829 次
namespace ClassLibrary1
{
[Guid("DA07B88D-29F0-41cf-B3D3-611010E6F3FE")]
[ComVisible(true)]
public interface IComTest
{
int Plus(int one, int two);
int Minus(int one, int two);
int Sum(Array arr);
}
[Guid("04F4DC83-8883-4a03-BDBC-92D8630ECC1E")]
[ClassInterface(ClassInterfaceType.None)]
public class ComTest : IComTest
{
public int Plus(int a, int b)
{
return a + b;
}
public int Minus(int a, int b)
{
return a - b;
}
public int Sum(Array arr)
{
return (arr as int[]).Sum();
}
}
public class Class1
{
}
}
int main(void)
{
CoInitialize(NULL);
IComTestPtr pt(CLSID_ComTest,NULL,CLSCTX_ALL);
_tprintf(_T("%d\n"),pt->Plus(2,3));
pt.Release();
CoUninitialize();
return 0;
}