1 建立一个默认的项目
2 利用New ATL Object向导添加Objects/simple object.
3 在idl文件中定义一个结构:全部文件如下
// Del_0.idl : IDL source for Del_0.dll
//// This file will be processed by the MIDL tool to
// produce the type library (Del_0.tlb) and marshalling code.import "oaidl.idl";
import "ocidl.idl";typedef
[uuid(def9b53e-08f9-4042-b5bb-43eef37d18e6)]
struct MyTX
{
long x;
long y;
}MyTX;   //自定义结构 [
object,
uuid(1B27E58D-B3C4-4F4F-9E63-4601D6694ABA),
dual,
helpstring("IDel_x0 Interface"),
pointer_default(unique)
]
interface IDel_x0 : IDispatch
{
};[
uuid(1E62057B-D554-488B-AE21-22AAA946490F),
version(1.0),
helpstring("Del_0 1.0 Type Library")
]
library DEL_0Lib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb"); [
uuid(10A019E0-71C4-47B6-A5F4-8E247B58F0F5),
helpstring("_IDel_x0Events Interface")
]
dispinterface _IDel_x0Events
{
properties:
methods:
}; [
uuid(9A18A96E-FB9C-463D-A3C7-0A8E8D36C2BE),
helpstring("Del_x0 Class")
]
coclass Del_x0
{
[default] interface IDel_x0;
[default, source] dispinterface _IDel_x0Events;
};
};4 想加入方法 HRESULT GetStructValue([in] SAFEARRAY(MyTX)* pValue);
过程如下:
在接口的右键菜单的选择"Add Method",在随后的对话框中的方法名称中输入"GetStructValue"
在参数中输入"[in] SAFEARRAY(MyTX)* pValue",
接下来确定添加,此时出现问题,VC弹出对话框"Unable to create the function because the header or implementation file could not be found",不能添加.
这是什么原因呢??求救中