我试过网上找到的所有方法创建com组件,但是在vs6.0自带的查看工具中查看,都看不到组件中的方法。
请问谁有C#创建com组件和vc6中调用的例子?发给我[email protected] 万分感谢!!!
在vc6使用如下代码调用失败。
HINSTANCE hinstLib = LoadLibrary("ComTest.dll"); //我写的com组件
if(!hinstLib )
{
AfxMessageBox("11");
}
if(hinstLib)//到这里还是正常运行的,就是说能加载ComTest.dll
{
FARPROC proc = GetProcAddress(hinstLib,"getname");//到这里就不行了,获取不到组件中方法的地址
if(!proc)
{
AfxMessageBox("21");
}
}
请问谁有C#创建com组件和vc6中调用的例子?发给我[email protected] 万分感谢!!!
在vc6使用如下代码调用失败。
HINSTANCE hinstLib = LoadLibrary("ComTest.dll"); //我写的com组件
if(!hinstLib )
{
AfxMessageBox("11");
}
if(hinstLib)//到这里还是正常运行的,就是说能加载ComTest.dll
{
FARPROC proc = GetProcAddress(hinstLib,"getname");//到这里就不行了,获取不到组件中方法的地址
if(!proc)
{
AfxMessageBox("21");
}
}
解决方案 »
- 有点技术难度,非诚勿扰!图片压缩成avi格式时,图片大小转换的算法是如何来的?
- asp.net 用linkbutton实现从数据库中读取文件名并在新窗口中打开该pdf文档
- 线程锁表问题,能解决吗?
- winfrom中执行bat文件 帮忙
- GridView和DataGrid显示 男 女
- 本着有分就散,有问题就问的精神,问个问题..如何开发带有下拉框的控件.
- USB小票打印机弹钱箱问题~
- 请教html转txt的较好算法!
- 求助:怎样在C#中调用oracle的函数?
- 如何创建一个泛型抽象类的List?
- 如何用代码实现对文件夹权限的控制(添加用户,并完全访问)
- 如何才能引用 System.Management ?
<ComClass(ComClass1.ClassId, ComClass1.InterfaceId, ComClass1.EventsId)> _
Public Class ComClass1
' Use the Region directive to define a section named COM Guids.
#Region "COM GUIDs"
' These GUIDs provide the COM identity for this class
' and its COM interfaces. You can generate
' these guids using guidgen.exe
Public Const ClassId As String = "7666AC25-855F-4534-BC55-27BF09D49D46"
Public Const InterfaceId As String = "54388137-8A76-491e-AA3A-853E23AC1217"
Public Const EventsId As String = "EA329A13-16A0-478d-B41F-47583A761FF2"
#End Region Public Sub New()
MyBase.New()
End Sub Function AddNumbers(ByVal X As Integer, ByVal Y As Integer)
AddNumbers = X + Y
End Function
End Class
注意 此属性简化 COM 对象的创建。若要创建 COM 对象,必须使用在“配置属性”对话框的“生成”节中选择的“注册 Com Interop”选项来编译项目。
yadg(阿俊) 你的方法没有可能是因为你方法参数的数据类型有问题,你加一个没有参数的方法试试看。