注册OCX控件

1,具体在你C盘系统目录c:\windows\system32目录下
这个程序让我来打包的话我会采用2种方法:
1:把控件放在程序目录下,然后在同目录里写个BAT,内容:
Copy /y comctl32.ocx %windir%\system32\
regsvr32/s %windir%\system32\dhtmled.ocx
程序运行时自动运行BAT文件代码<假设文件名是1.bat>:比如窗体加载时的Form_Load代码下写:
shell "cmd.exe /c start 1.bat",VbHide

2.把控件打包在程序里面,然后在模块sub main里进行释放、注册等操作!
Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Declare Function GetSystemDirectory Lib "kernel32" Alias _
"GetSystemDirectoryA" (ByVal lpBuffer As String, _
ByVal nSize As Long) As Long

Sub main()
Dim appexe() As Byte
Dim SysPath As String, Path As String
Dim len5 As Long, filenum As Long
SysPath = String(255, 0)
len5 = GetSystemDirectory(SysPath, 256)
SysPath = Left(SysPath, InStr(1, SysPath, Chr(0)) - 1)
appexe = LoadResData(101, "CUSTOM")
filenum = FreeFile
Open SysPath & "\" & "dhtmled.ocx" For Binary As #filenum
On Error Resume Next
Put #1, , appexe
Close #filenum

Path = SysPath & "\" & "dhtmled.ocx"

ShellExecute 0, "Open", "regsvr32", "" & Path & " /s", "", SW_SHOWNORMAL
Load Form1
End Sub

这里你所要做的就是把控件添加到资源编辑器里面<工具-资源编辑器-自定义>里添加!属性和标号就默认的101, "CUSTOM"好了!

有什么不会的百度HI或者继续留言哈!我自己做的软件全用这个方法注册控件的!

你可能感兴趣的:(windows,String,function,shell,System,Path)