-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathuninstall.PRG
131 lines (113 loc) · 3.93 KB
/
uninstall.PRG
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
* Install/register ParallelFox on developer machine
Local lcEXE, lcDLL, lcProgID, lcMTDLLProgId
Do Case
Case Version(5) >= 1000 and Evaluate("_Win64") = .t. && VFP Advanced 64-bit
* Doesn't work yet
MessageBox("ParallelFox is not functional with VFP Advanced 64-bit. It is partially supported on VFPA 32-bit." + Chr(13) + Chr(13) + ;
"See https://github.com/VFPX/ParallelFox/tree/master/vfpa for more details.", 16, "ParallelFox")
Return
lcEXE = "ParallelFox64.exe"
lcProgID = "ParallelFox64.Application"
lcDLL = "ParallelFoxMT.dll"
lcMTDLLProgID = "ParallelFoxMT.Application"
Case Version(5) >= 1000 && VFP Advanced 32-bit
lcEXE = "ParallelFoxA.exe"
* Depending on how installed, DLL may be in VFPA folder
If !File(lcEXE)
lcEXE = "VFPA\" + lcEXE
EndIf
lcProgID = "ParallelFoxA.Application"
* MTDLL crashes due to problems with ExecScript(), so use VFP9 version for now
lcDLL = "ParallelFoxMT.dll"
lcMTDLLProgID = "ParallelFoxMT.Application"
Otherwise && VFP 9.0
lcEXE = "ParallelFox.exe"
lcProgID = "ParallelFox.Application"
lcDLL = "ParallelFoxMT.dll"
lcMTDLLProgID = "ParallelFoxMT.Application"
EndCase
* Registering ParallelFox.exe requires elevation on Windows Vista/7
* ParallelFox /regserver without elevation will fail, but will not notify user of failure.
* This program requests elevation and confirms registration.
Local llSuccess, lcMessage
ShellExec(FullPath(lcEXE),"RunAs","/unregserver")
* Depending on how installed, DLL may be in MTDLL folder
If !File(lcDLL)
lcDLL = "MTDLL/" + lcDLL
EndIf
ShellExec("RegSvr32.exe","RunAs", "/s /u " + FullPath(lcDLL) )
Wait "Unregistering ParallelFox..." window timeout 1 && wait for registration to complete
lcMessage = ""
llSuccess = .t.
If !IsRegistered(lcProgID)
lcMessage = lcEXE + " was unregistered successfully."
Else
llSuccess = .f.
lcMessage = lcEXE + " was NOT unregistered."
EndIf
If !IsRegistered(lcMTDLLProgID)
lcMessage = lcMessage + Chr(13) + lcDLL + " was unregistered successfully."
Else
llSuccess = .f.
lcMessage = lcMessage + Chr(13) + lcDLL + " was NOT unregistered."
EndIf
MessageBox(lcMessage, Iif(llSuccess, 64, 16), "ParallelFox")
If MessageBox("Uninstall ParallelFox IntelliSense scripts?", 4+32, "ParallelFox IntelliSense") = 6
Do UninstallFFI
EndIf
MessageBox("Uninstall Complete.", 64, "ParallelFox")
Return
Procedure UninstallFFI
Local lnCurrentArea
lnCurrentArea = Select()
Select 0
Use (_FoxCode) Again Alias FFIFoxCode Shared
Delete for InList(Lower(abbrev), "parallel ", "worker ", "pfhandleffi ")
Use
Select (lnCurrentArea)
EndProc
Function ShellExec
LParameter lcLink, lcAction, lcParms
lcAction = IIf(Empty(lcAction), "Open", lcAction)
lcParms = IIf(Empty(lcParms), "", lcParms)
DECLARE INTEGER ShellExecute ;
IN SHELL32.dll ;
INTEGER nWinHandle, ;
STRING cOperation, ;
STRING cFileName, ;
STRING cParameters, ;
STRING cDirectory, ;
INTEGER nShowWindow
DECLARE INTEGER FindWindow ;
IN WIN32API ;
STRING cNull,STRING cWinName
Return ShellExecute(FindWindow(0, _Screen.caption), lcAction, ;
lcLink, lcParms, JustPath(lcLink), 1)
EndFunc
Function IsRegistered
Lparameters lcLookUpKey
* Registry roots
#DEFINE HKEY_CLASSES_ROOT -2147483648 && BITSET(0,31)
#DEFINE HKEY_CURRENT_USER -2147483647 && BITSET(0,31)+1
#DEFINE HKEY_LOCAL_MACHINE -2147483646 && BITSET(0,31)+2
#DEFINE HKEY_USERS -2147483645 && BITSET(0,31)+3
* Load DLLs
Clear Dlls RegOpenKey
Clear Dlls RegCloseKey
LOCAL nHKey,cSubKey,nResult
DECLARE Integer RegOpenKey IN Win32API ;
Integer nHKey, String @cSubKey, Integer @nResult
DECLARE Integer RegCloseKey IN Win32API ;
Integer nHKey
* Try to open key
Local lnErrorCode, lnSubKey
lnSubKey = 0
lnErrorCode = RegOpenKey(HKEY_CLASSES_ROOT,lcLookUpKey,@lnSubKey)
If lnErrorCode = 0 && success
* Close key
=RegCloseKey(lnSubKey)
Return .t.
Else
Return .f.
EndIf
EndFunc