通过api注册控件:
Option Explicit
Private Declare Function LoadLibraryA Lib "kernel32" (ByVal lLibFileName As String) As Long
Private Declare Function CreateThread Lib "kernel32" (lThreadAttributes As Any, ByVal lStackSize As Long, ByVal lStartAddress As Long, ByVal larameter As Long, ByVal lCreationFlags As Long, lThreadID As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal lMilliseconds As Long) As Long
Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lProcName As String) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetExitCodeThread Lib "kernel32" (ByVal hThread As Long, lExitCode As Long) As Long
Private Declare Sub ExitThread Lib "kernel32" (ByVal lExitCode As Long)
'Purpose   :    This function registers and Unregisters OLE components
'Inputs    :    sDllPath                        The path to the DLL/OCX
'               bRegister                       If True Registers the control, else unregisters control
'Outputs   :    Returns True if successful
'Author    :    Andrewb
'Date      :    04/09/2000
'Notes     :    This effectively replaces RegSvr32.exe by loading the library and
'               calling the register or unregister functions exposed by all OLE components.
'Revisions :
Function RegisterServer(ByVal sDllPath As String, Optional bRegister As Boolean = True) As Boolean
Dim lLibAddress As Long, lProcAddress As Long, lThreadID As Long, lSuccess As Long, lExitCode As Long, lThread As Long
Dim sRegister As String
Const clMaxTimeWait As Long = 20000     'Wait 20 secs for register to
complete
On Error GoTo ExitFunc
If Len(sDllPath) > 0 And Len(Dir(sDllPath)) > 0 Then
'File exists
If bRegister Then
sRegister = "DllRegisterServer"
Else
sRegister = "DllUnregisterServer"
End If
'Load library into current process
lLibAddress = LoadLibraryA(sDllPath)
If lLibAddress Then
'Get address of the DLL function
lProcAddress = GetProcAddress(lLibAddress, sRegister)
If lProcAddress Then
'Found interface, make call to component
lThread = CreateThread(ByVal 0&, 0&, ByVal lProcAddress, ByVal 0&, 0&, lThread)
If lThread Then
'Created thread
lSuccess = (WaitForSingleObject(lThread, clMaxTimeWait) = 0)
If Not lSuccess Then
'Failed to register, close thread
Call GetExitCodeThread(lThread, lExitCode)
Call ExitThread(lExitCode)
RegisterServer = False
Else
'Register control
RegisterServer = True
Call CloseHandle(lThread)
End If
End If
Else
'Object doesn't expose OLE interface
FreeLibrary lLibAddress
End If
Call FreeLibrary(lLibAddress)
End If
End If
ExitFunc:
On Error GoTo 0
End Function'调用
RegisterServer app.path+"\Dbgrid32.ocx",true
RegisterServer app.path+"\Dblist32.ocx",true

解决方案 »

  1.   

    把Dbgrid32.ocx和Dblist32.ocx控件用到的*.ocx or *.dll拷贝到你程序的exe文件的相同目录下。最好是打包。vb有打包工具,不过打包后安装程序巨大
      

  2.   

    上面几位朋友的方法应该是无效的,这是因为Dbgrid32.ocx需要在注册表中添加许可。就是那个DBGRID.REG需要导入到注册表,如果没有导入到注册表的话,Dbgrid32.ocx放到哪里都是不能用的。
    这个问题这样我想就可以了:
    第一种方法:
    1,用打包软件(安装制作程序)打包你的软件。
    2,在打包软件中定义一个注册表操作:
       HKEY_CLASSES_ROOT\Licenses\586C75F1-EFBC-11CF-B9F3-00A0247033C4 = xybiedobrqsprbijaegcbislrsiucfjdhisl
    3,这样就可以了,当你的安装程序执行时就可以把Dbgrid32.ocx许可信息添加到注册表。第二种方法:
    在主程序加载过程中添加这个:   Dim RetVal
       RetVal = Shell("regedit -s DBGRID.REG", 1)上面程序的意思是以不提示方式导入DBGRID.REG的内容到注册表。
    不过这要求DBGRID.REG与你的程序在一个文件夹下,当然你也可以指定它的路径。
    这段程序将在你的程序每次执行时都执行。所以推荐用第一种方法。安装软件可以到   CSDN专用FTP   下载:
    ftp://friend:[email protected]
      

  3.   

    不好意思,上面有一个误笔,更正如下:HKEY_CLASSES_ROOT\Licenses\556C75F1-EFBC-11CF-B9F3-00A0247033C4 = xybiedobrqsprbijaegcbislrsiucfjdhisl
      

  4.   

    打包,如果用了Access数据库,还要检查ado版本号。
      

  5.   

    lsr66(瑞丽.com员工) 
    说的不错,是有一个reg文件需要导入。请问老大能帮我看一下源程序吗?
    我修改后提示错误
      

  6.   

    2,在打包软件中定义一个注册表操作:
       HKEY_CLASSES_ROOT\Licenses\586C75F1-EFBC-11CF-B9F3-00A0247033C4 = xybiedobrqsprbijaegcbislrsiucfjdhisl请问在打包过程中那里能添加这个选项
      

  7.   

    请问我有一个help.chm文件,怎样加入安装包中,我添加不了,总是提示文件类型不对![email protected]
      

  8.   

    一个一个问题来吧:
    1,源程序我不看了,修改后错误是因为我上面已经说了,我笔误,已经改成:
       HKEY_CLASSES_ROOT\Licenses\556C75F1-EFBC-11CF-B9F3-00A0247033C4 = xybiedobrqsprbijaegcbislrsiucfjdhisl上面有个小错误,已经改了,注意这里:“Licenses\586”改成了“Licenses\556”。2,增加注册表操作:
    这里以Setupbuilder1.5为例:
    前面的基本设置工作完成后,点右边的“高级设置”-左边的“登记注册表信息”-右击“HKEY_CLASSES_ROOT”-新建 项-右击“新项 #1”-重命名为“Licenses”-右击“Licenses”-新建 项-右击“新项 #1”-重命名为“556C75F1-EFBC-11CF-B9F3-00A0247033C4”-双击右边的“默认”-添加字串键值“xybiedobrqsprbijaegcbislrsiucfjdhisl”这样就可以了。3,要添加 help.chm 到安装文件夹,可以这样:
    仍然以Setupbuilder1.5为例:
    前面的基本设置工作完成后,点右边的“常规设置”-左边的“指定文件组和文件”-右击“Program Files”-添加文件-指定你的help.chm文件路径即可。
    这样help.chm将在安装时被拷贝到安装文件夹与可执行文件在一起。
      

  9.   

    Setupbuilder1.5编译出错
    对于添加chm文件,请问vb自带的打包程序怎么弄呢
      

  10.   

    1,用VB自带的打包程序可以这样:指定好VBP文件后-点“打包”-点“相关文件”(注意不是“标准安装包”)-指向要打包的文件夹-点“添加”-添加你所要添加的文件(如果看不到你所想要的文件请指定文件类型为所有文件)-点确定-(必要的话,还可以修改.PDM宏文件,自己指定需要添加的文件和安装时所放的位置,文件一看就懂的)-现在又回到主面板,点“打包”-下一步-“标准安装包”-.......可以了。。2,Setupbuilder1.5编译出错好像是因为你没有用FTP上同一个文件夹下zip文件中的序列号注册。如果注册后仍然出错的话,重装覆盖一下即可。ftp://friend:[email protected]/精品软件/编程类/安装制作/