source: contrib/installer/uninstall/uninstall.cpp@ 406

Last change on this file since 406 was 406, checked in by Brendan Oakley, 17 years ago

New install/uninstall src, from Lars

  • Property svn:eol-style set to native
File size: 2.4 KB
Line 
1#define INCL_BASE
2#define INCL_PM
3#include <os2.h>
4
5#define INCL_OS2MM
6#include <os2me.h>
7
8#include "reshlp.h"
9#include "insthlp.h"
10
11int main(int argc, char *argv[])
12{
13
14 CHAR szDriverName[MAX_DEVICE_NAME];
15 APIRET rc;
16 HMODULE hmod;
17 ULONG ulNumAdapters;
18 ULONG ulNumDrivers;
19 ULONG ulDevType;
20 PSZ pszDevType;
21 BOOL fRC=FALSE;
22 PAPSZ StringArray=NULL;
23 PCHAR pBuf=NULL;
24
25 rc = OpenResourceDLL(&hmod);
26 if (rc == NO_ERROR)
27 {
28 rc = QueryNumberAdapters(hmod,&ulNumAdapters);
29 for (ULONG i=0;i<ulNumAdapters;i++)
30 {
31 ULONG ulID;
32 ULONG ulConfigStrings;
33 ULONG j;
34
35 rc = QueryAdapterID(hmod,i,&ulID);
36
37 rc = QueryNumberOfConfigStrings(hmod,i,&ulConfigStrings);
38 if (ulConfigStrings)
39 {
40 pBuf = (PCHAR)calloc(ulConfigStrings,CCHMAXPATH);
41 StringArray = (PAPSZ)calloc(ulConfigStrings,sizeof(PSZ));
42 if (pBuf && StringArray)
43 {
44 for (j=0;j<ulConfigStrings;j++)
45 {
46 *StringArray[j]=&pBuf[j*CCHMAXPATH];
47 rc = QueryConfigString(hmod,i,j,*StringArray[j]);
48 }
49 DeleteConfigSysEntries(ulConfigStrings,StringArray);
50 }
51 free(pBuf);
52 free(StringArray);
53 }
54
55 rc = QueryNumberOfDrivers(hmod,i,&ulNumDrivers);
56 for (j=0;j<ulNumDrivers;j++)
57 {
58 rc = QueryDriverInstallNameAndType(hmod,i,j,szDriverName,&ulDevType);
59 fRC = DeleteDevices(ulDevType,szDriverName);
60 }
61 }
62 rc = CloseResourceDLL(hmod);
63 if (UpdateMMPM2Ini())
64 {
65 APIRET rc;
66 ULONG ulRead=0;
67 CHAR c;
68
69 printf("MMPM2.INI is now locked and protected against further changes\nDo you want to reboot now? ");
70 fflush(stdout);
71 rc = DosRead(0,&c,sizeof(c),&ulRead);
72 if (c == 'Y' || c == 'y')
73 {
74 if (!RebootSystem())
75 {
76 printf("Reboot failed !\n");
77 }
78 }
79 }
80 }
81 else
82 {
83 printf(
84 "Uninstall utility expects to find DLL \"CARDINFO.DLL\" in order to perform\n"
85 "uninstallation.\n"
86 "Make sure you either have \"CARDINFO.DLL\" in current path and \".\" on LIBPATH\n"
87 "or you have \"CARDINFO.DLL\" somewhere on LIBPATH/BEGINLIBPATH/ENDLIBPATH\n");
88 }
89 return 0;
90}
91
92
Note: See TracBrowser for help on using the repository browser.