日期:2014-05-17 浏览次数:20881 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sample4Lib;
namespace UseCom
{
class Program
{
static void Main(string[] args)
{
//Fun pf = new Fun();//OK now
IFun pf = new Fun();
var a = pf.Add(2, 3);
IFun f1 = pf as IFun;
}
}
}
[
object,
uuid(906AA3B5-7341-455F-B391-AD6D15087701),
pointer_default(unique)
]
interface IFun : IUnknown{
[] HRESULT Add([in] LONG n1, [in] LONG n2, [out,retval] LONG** pVal);
};
[
uuid(197CE716-F985-4C7A-B202-7FFB27E6B3A0),
version(1.0),
]
STDMETHODIMP CFun::Add(LONG n1, LONG n2, LONG** pVal)
{
// TODO: Add your implementation code here
*pVal=new LONG;
**pVal=n1+n2;
return S_OK;
}