# 移除vb做的程式不是用uninstal.exe

Posted by Honey on July 13, 1999 at 18:27:11:

In Reply to: 请教一个大家应该会的,反安装程式 posted by simon on July 13, 1999 at 12:51:08:

st5unst.log这是不能移除的
否则也别想移除程式了
原理简单讲一下 因为装封暨部署精灵是微软做的
原先设定就是要在控制台移除 若要在所属程式集的目录底下
建立移除程式 只有自己多写一个啰
也几样东西一定要知道
VB6移除方法如下
C:\WINDOWS\st6unst.exe -n "C:\Program Files\Reda\ST6UNST.LOG"
若是vb6则为
C:\WINDOWS\st5unst.exe -n "C:\Program Files\Reda\ST5UNST.LOG"
知道是哪里不同了吧
vb6改法也一样 把5改成4
做出的程式 在装封暨部署精灵在"包含档案"时记得加入
自己写的移除程式
执行到到"开始功能表的项目"时 按"新增项目"
目的档案是自己写的移除程式

移除程式 我的写法如下
首先开启新专案
2.移除Form1
3.新增一个模组
4.在模组贴上以下程式
Private Declare Function FindFirstFile Lib _
"kernel32" Alias "FindFirstFileA" (ByVal _
lpFileName As String, lpFindFileData _
As WIN32_FIND_DATA) As Long
'/*来寻找档案*/
Private Declare Function GetWindowsDirectory _
Lib "kernel32" Alias "GetWindowsDirectoryA" ( _
ByVal lpBuffer As String, ByVal nSize As Long) As Long
'/*Windows路径*/

Private Const MAX_PATH = 260 '/*档案最长长度*/
Private Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
Option Explicit
Public Sub Main()
Dim StrFileName As String, WD As WIN32_FIND_DATA
Dim StrVersion As String
WD = GetUnFile(App.Path) '/*将路径传入 传回找到档案的资讯*/
StrVersion = Mid(WD.cFileName, 3, 1)
'/*WD.cFileName是找到的档名 形式是ST?UNST.LOG _
当?=6时表示是VB6做出来的 ?=5表示是vb6做出来的 _
只要将档名第三个自取回即可知道版本*/

StrFileName = App.Path & "\ST" & StrVersion & "UNST.LOG"
'/*组成正确的档名*/

Shell GetWinPath & "\st" & StrVersion & "unst.exe -n" & Chr(34) & StrFileName & Chr(34), vbMaximizedFocus
'/*不同版本要用不同的解除安装程式 _
ST6UNST.LOG 要用ST6UNST.exe _
ST5UNST.LOG 要用ST5UNST.exe _
Chr(34)是"这个符号 因为在程式中有特别意义 _
是参数时要以Chr(34)替代*/
End Sub
Public Function GetWinPath() As String '/*传回Windows路径*/
Dim S As String * 80, Length As Long
Length = GetWindowsDirectory(S, Len(S))
GetWinPath = Left(S, Length)
End Function
Public Function GetUnFile(StrPath As String) As WIN32_FIND_DATA
'/*传回寻找到的档案资讯*/
FindFirstFile StrPath & "\ST?UNST.LOG", GetUnFile
End Function

Follow Ups: