请问com组建注册是什么意思? 如果有一个COM组建,不能在VC中直接调用吗?还要注册吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 注册了 你才能调用 否则程序不知道关于他的一些信息 比如文件位置、支持的线程模型 etc 1、COM组件在使用之前必须先将其注册到系统中,也就是将该组件的相关信息(比如路径,类型等)写进注册表中。操作系统提供了一套专门的东西(可以理解为一个类似数据库的东西)来管理所有的COM组件。2、用户在使用COM组件的时候<1>先找到COM组件,去哪里找,肯定是向系统查询,如果不注册,自然也就查询不到,更不用说创建对象了; <2>是通过COM组件的GUID来创建相应的COM对象的,并查询指定的接口; 注册其实就是把这个COM的一些关键信息写入注册表,比如COM 的PE文件所在的路径,这个COM的线程模型等,这样,无论哪个本地程序都可以通过通过注册表查找到这个COM并调用它 把组件存放的路径及其支持的套间模型及可能使用的类型库的路径信息。应用程序在使用组件的时候调用CoCreateInstance的时候内部代码运行时,会查找注册表。 this post do good to me Regsvr OCX文件所在路径就可以注册了VS2005里边添加工具箱选项-》COM组件项目--》添加变量 普通的Dll也需要进行注册才可以运行,而COM对象或是COM服务器要提供给服务于Client,那么客户端首先要知道要没有这个服务?如何进行这个服务的调用或是访问,因此它会找一些有用的键值,而客户所找的范畴就是注册表。由此而言,注册的确很有必要而肯是必不可少的。 DLL不需要注册,DLL跟COM不是同一个东西.... 同楼上, DLL 和 COM 并不是同一个东西COM要以DLL作为宿主,DLL导出函数供客户程序调用,并实现对COM的注册其实组件并不是完全依赖注册才可以用。只是注册可以实现组件位置的透明性如如下VB代码就实现了通过组件位置访问组件的示例,'//Declare Window APIOption ExplicitPrivate Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryW" (ByVal lpLibFileName As Long) As LongPrivate Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As LongPrivate Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As LongPrivate Declare Function CallAsmCode Lib "user32" Alias "CallWindowProcW" (FirstAsmCode As Long, ByVal pA As Long, ByVal pB As Long, ByVal pC As Long, lpD As Long) As LongPrivate Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)Private AsmCode(94) As LongPublic Function LoadObjectByName(ByVal DllPath As String, ByVal ClsName As String, pDll As Long) As Object Dim pObj As Long, TLIAPP As Object, TLI As Object Dim CLSID As String, IID As String, IIDName As String On Error GoTo Err Set TLIAPP = CreateObject("TLI.TLIApplication") Set TLI = TLIAPP.TypeLibInfoFromFile(DllPath) IIDName = "_" & Trim(ClsName) CLSID = TLI.GetTypeInfo(Trim(ClsName)).Guid IID = TLI.GetTypeInfo(Trim(IIDName)).Guid Set LoadObjectByName = LoadObjectByID(DllPath, CLSID, IID, pDll) Set TLI = NothingErr:End FunctionPublic Function LoadObjectByID(ByVal DllPath As String, ByVal CLSID As String, ByVal IID As String, pDll As Long) As Object Dim pObj As Long Call InitAsmCode pObj = CallAsmCode(AsmCode(20), StrPtr(DllPath), StrPtr(CLSID), StrPtr(IID), pDll) CopyMemory LoadObjectByID, pObj&, 4&End FunctionPublic Function UnLoadDll(pDll As Long) As Long Call InitAsmCode UnLoadDll = CallAsmCode(AsmCode(79), pDll, 0, 0, 0)End FunctionPrivate Sub InitAsmCode() If AsmCode(4) Then Exit Sub Dim pDll As Long pDll = LoadLibrary(StrPtr("kernel32")) AsmCode(0) = GetProcAddress(pDll, "LoadLibraryW") AsmCode(1) = GetProcAddress(pDll, "GetProcAddress") AsmCode(2) = GetProcAddress(pDll, "FreeLibrary") Call FreeLibrary(pDll) AsmCode(4) = &H476C6C44 AsmCode(5) = &H6C437465 AsmCode(6) = &H4F737361 AsmCode(7) = &H63656A62 AsmCode(8) = &H4C430074 AsmCode(9) = &H46444953 AsmCode(10) = &H536D6F72 AsmCode(11) = &H6E697274 AsmCode(12) = &H10067 AsmCode(13) = &H0& AsmCode(14) = &HC00000 AsmCode(15) = &H0& AsmCode(16) = &H6F4600 AsmCode(17) = &H65006C AsmCode(18) = &H320033 AsmCode(19) = &H0& AsmCode(20) = &H83EC8B55 '´´½¨¶ÔÏóº¯ÊýÈë¿Ú AsmCode(21) = &HE853D8C4 AsmCode(22) = &H0& AsmCode(23) = &H6CEB815B AsmCode(24) = &H8D100010 AsmCode(25) = &H105293 AsmCode(26) = &H93FF5210 AsmCode(27) = &H10001010 AsmCode(28) = &H32938D50 AsmCode(29) = &H52100010 AsmCode(30) = &H1493FF50 AsmCode(31) = &H8D100010 AsmCode(32) = &H101C93 AsmCode(33) = &HFF028910 AsmCode(34) = &H101893 AsmCode(35) = &H875FF10 AsmCode(36) = &H101093FF AsmCode(37) = &HC00B1000 AsmCode(38) = &H86840F AsmCode(39) = &H45890000 AsmCode(40) = &H20938DFC AsmCode(41) = &H52100010 AsmCode(42) = &H1493FF50 AsmCode(43) = &HB100010 AsmCode(44) = &H506674C0 AsmCode(45) = &H52EC558D AsmCode(46) = &HFF0C75FF AsmCode(47) = &H101C93 AsmCode(48) = &H558D5810 AsmCode(49) = &H938D52D8 AsmCode(50) = &H10001042 AsmCode(51) = &HEC558D52 AsmCode(52) = &HBD0FF52 AsmCode(53) = &H8D3E75C0 AsmCode(54) = &HFF52DC55 AsmCode(55) = &H93FF1075 AsmCode(56) = &H1000101C AsmCode(57) = &HD8558B50 AsmCode(58) = &H8D54128B AsmCode(59) = &H6A50DC45 AsmCode(60) = &HD875FF00 AsmCode(61) = &HB0C52FF AsmCode(62) = &H8B1575C0 AsmCode(63) = &H4D8BFC45 AsmCode(64) = &H59018914 AsmCode(65) = &H8BD18B51 AsmCode(66) = &H52FF5112 AsmCode(67) = &H14EB5804 AsmCode(68) = &HEB06EB58 AsmCode(69) = &HEB02EB0F AsmCode(70) = &HFC75FF0B AsmCode(71) = &H101893FF AsmCode(72) = &HC0331000 AsmCode(73) = &H10C2C95B AsmCode(74) = &H6C6C4400 AsmCode(75) = &H556E6143 AsmCode(76) = &H616F6C6E AsmCode(77) = &H776F4E64 AsmCode(78) = &H0& AsmCode(79) = &H53EC8B55 '³¢ÊÔжÔØDLLº¯ÊýÈë¿Ú AsmCode(80) = &HE8& AsmCode(81) = &HEB815B00 AsmCode(82) = &H10001155 AsmCode(83) = &H1139938D AsmCode(84) = &HFF521000 AsmCode(85) = &H93FF0875 AsmCode(86) = &H10001014 AsmCode(87) = &H1374C00B AsmCode(88) = &HC00BD0FF AsmCode(89) = &H75FF0E74 AsmCode(90) = &H1893FF08 AsmCode(91) = &H33100010 AsmCode(92) = &H4801EBC0 AsmCode(93) = &H10C2C95B AsmCode(94) = &H90909000End Sub若是C++也可以通过两个API函数,::LoadLibrary和::GetProcAddress来实现通过组件位置访问组件 如果你调用的com是dll,而且你知道位置确实可以不要com,直接调用但是如果com不是dll,或者不知道位置,就一定要有注册,访问组件的方式了 菜鸟求教关于对话框设置为全屏的问题 VC大大们,帮帮小弟啊 在用VB做图像处理界面的时候碰到一个尴尬的问题~~帮帮忙~ 打开新程序的时候如何关闭自己 请帮忙,做不出就没有工作了!Debug Assertion Failed!错误. 给大家介绍一个电子图书 / 视频教材 下载的地方 请介绍一下关于VC的认证~~~~~~~~~~~~~在线等 各位兄弟,我如何拆分一个const char*字符串,并保证每个子字符串不包括乱字符,见内?谢谢先 小波二维变换在图象处理中的应用,包括小波变换的分辨率(算法求助)高分求助 link是出现如下提示,该怎办 有关串口的问题 按钮控件 如何这样响应?
应用程序在使用组件的时候调用CoCreateInstance的时候内部代码
运行时,会查找注册表。
VS2005里边添加工具箱选项-》COM组件
项目--》添加变量
Option Explicit
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryW" (ByVal lpLibFileName As Long) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function CallAsmCode Lib "user32" Alias "CallWindowProcW" (FirstAsmCode As Long, ByVal pA As Long, ByVal pB As Long, ByVal pC As Long, lpD As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private AsmCode(94) As Long
Public Function LoadObjectByName(ByVal DllPath As String, ByVal ClsName As String, pDll As Long) As Object
Dim pObj As Long, TLIAPP As Object, TLI As Object
Dim CLSID As String, IID As String, IIDName As String
On Error GoTo Err
Set TLIAPP = CreateObject("TLI.TLIApplication")
Set TLI = TLIAPP.TypeLibInfoFromFile(DllPath)
IIDName = "_" & Trim(ClsName)
CLSID = TLI.GetTypeInfo(Trim(ClsName)).Guid
IID = TLI.GetTypeInfo(Trim(IIDName)).Guid
Set LoadObjectByName = LoadObjectByID(DllPath, CLSID, IID, pDll)
Set TLI = Nothing
Err:
End Function
Public Function LoadObjectByID(ByVal DllPath As String, ByVal CLSID As String, ByVal IID As String, pDll As Long) As Object
Dim pObj As Long
Call InitAsmCode
pObj = CallAsmCode(AsmCode(20), StrPtr(DllPath), StrPtr(CLSID), StrPtr(IID), pDll)
CopyMemory LoadObjectByID, pObj&, 4&
End Function
Public Function UnLoadDll(pDll As Long) As Long
Call InitAsmCode
UnLoadDll = CallAsmCode(AsmCode(79), pDll, 0, 0, 0)
End Function
Private Sub InitAsmCode()
If AsmCode(4) Then Exit Sub
Dim pDll As Long
pDll = LoadLibrary(StrPtr("kernel32"))
AsmCode(0) = GetProcAddress(pDll, "LoadLibraryW")
AsmCode(1) = GetProcAddress(pDll, "GetProcAddress")
AsmCode(2) = GetProcAddress(pDll, "FreeLibrary")
Call FreeLibrary(pDll)
AsmCode(4) = &H476C6C44
AsmCode(5) = &H6C437465
AsmCode(6) = &H4F737361
AsmCode(7) = &H63656A62
AsmCode(8) = &H4C430074
AsmCode(9) = &H46444953
AsmCode(10) = &H536D6F72
AsmCode(11) = &H6E697274
AsmCode(12) = &H10067
AsmCode(13) = &H0&
AsmCode(14) = &HC00000
AsmCode(15) = &H0&
AsmCode(16) = &H6F4600
AsmCode(17) = &H65006C
AsmCode(18) = &H320033
AsmCode(19) = &H0&
AsmCode(20) = &H83EC8B55 '´´½¨¶ÔÏóº¯ÊýÈë¿Ú
AsmCode(21) = &HE853D8C4
AsmCode(22) = &H0&
AsmCode(23) = &H6CEB815B
AsmCode(24) = &H8D100010
AsmCode(25) = &H105293
AsmCode(26) = &H93FF5210
AsmCode(27) = &H10001010
AsmCode(28) = &H32938D50
AsmCode(29) = &H52100010
AsmCode(30) = &H1493FF50
AsmCode(31) = &H8D100010
AsmCode(32) = &H101C93
AsmCode(33) = &HFF028910
AsmCode(34) = &H101893
AsmCode(35) = &H875FF10
AsmCode(36) = &H101093FF
AsmCode(37) = &HC00B1000
AsmCode(38) = &H86840F
AsmCode(39) = &H45890000
AsmCode(40) = &H20938DFC
AsmCode(41) = &H52100010
AsmCode(42) = &H1493FF50
AsmCode(43) = &HB100010
AsmCode(44) = &H506674C0
AsmCode(45) = &H52EC558D
AsmCode(46) = &HFF0C75FF
AsmCode(47) = &H101C93
AsmCode(48) = &H558D5810
AsmCode(49) = &H938D52D8
AsmCode(50) = &H10001042
AsmCode(51) = &HEC558D52
AsmCode(52) = &HBD0FF52
AsmCode(53) = &H8D3E75C0
AsmCode(54) = &HFF52DC55
AsmCode(55) = &H93FF1075
AsmCode(56) = &H1000101C
AsmCode(57) = &HD8558B50
AsmCode(58) = &H8D54128B
AsmCode(59) = &H6A50DC45
AsmCode(60) = &HD875FF00
AsmCode(61) = &HB0C52FF
AsmCode(62) = &H8B1575C0
AsmCode(63) = &H4D8BFC45
AsmCode(64) = &H59018914
AsmCode(65) = &H8BD18B51
AsmCode(66) = &H52FF5112
AsmCode(67) = &H14EB5804
AsmCode(68) = &HEB06EB58
AsmCode(69) = &HEB02EB0F
AsmCode(70) = &HFC75FF0B
AsmCode(71) = &H101893FF
AsmCode(72) = &HC0331000
AsmCode(73) = &H10C2C95B
AsmCode(74) = &H6C6C4400
AsmCode(75) = &H556E6143
AsmCode(76) = &H616F6C6E
AsmCode(77) = &H776F4E64
AsmCode(78) = &H0&
AsmCode(79) = &H53EC8B55 '³¢ÊÔжÔØDLLº¯ÊýÈë¿Ú
AsmCode(80) = &HE8&
AsmCode(81) = &HEB815B00
AsmCode(82) = &H10001155
AsmCode(83) = &H1139938D
AsmCode(84) = &HFF521000
AsmCode(85) = &H93FF0875
AsmCode(86) = &H10001014
AsmCode(87) = &H1374C00B
AsmCode(88) = &HC00BD0FF
AsmCode(89) = &H75FF0E74
AsmCode(90) = &H1893FF08
AsmCode(91) = &H33100010
AsmCode(92) = &H4801EBC0
AsmCode(93) = &H10C2C95B
AsmCode(94) = &H90909000
End Sub若是C++
也可以通过两个API函数,::LoadLibrary和::GetProcAddress来实现通过组件位置访问组件
但是如果com不是dll,或者不知道位置,就一定要有注册,访问组件的方式了