source: contrib/installer/uninstall/reshlp.cpp

Last change on this file 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: 4.9 KB
Line 
1/*
2 for the syntax of DLL CARDINFO.DLL, see:
3 "MMPM/2 Device Driver Reference"
4 ->Adding Support for Audio and Video Adapters
5 ->Audio Adapter Installation
6 ->Step 3: Modifying the CARDINFO.RC File
7*/
8#include "reshlp.h"
9
10APIRET OpenResourceDLL(PHMODULE phmod)
11{
12 APIRET rc = NO_ERROR;
13 if (!phmod)
14 {
15 return ERROR_INVALID_PARAMETER;
16 }
17 rc = DosLoadModule(NULL,0UL,"CARDINFO",phmod);
18 if (rc)
19 {
20 *phmod = NULLHANDLE;
21 }
22 return rc;
23}
24
25APIRET CloseResourceDLL(HMODULE hmod)
26{
27 APIRET rc = NO_ERROR;
28 if (hmod)
29 {
30 rc = DosFreeModule(hmod);
31 }
32 return rc;
33}
34
35APIRET QueryNumberAdapters(HMODULE hmod,PULONG pulNum)
36{
37 PVOID pStr;
38 APIRET rc = NO_ERROR;
39 if (!pulNum)
40 {
41 return ERROR_INVALID_PARAMETER;
42 }
43 rc = DosGetResource(hmod,RT_RCDATA,1UL,&pStr);
44 if (rc)
45 {
46 *pulNum = 0UL;
47 }
48 else
49 {
50 *pulNum = strtoul((PSZ)pStr,NULL,10);
51 rc = DosFreeResource(pStr);
52 }
53 return rc;
54}
55
56APIRET QueryAdapterID(HMODULE hmod,ULONG ulAdapterIdx,PULONG pulID)
57{
58 PVOID pStr;
59 APIRET rc = NO_ERROR;
60 if (!pulID)
61 {
62 return ERROR_INVALID_PARAMETER;
63 }
64 rc = DosGetResource(hmod,RT_RCDATA,(ulAdapterIdx+1)*10UL,&pStr);
65 if (rc)
66 {
67 *pulID = 0UL;
68 }
69 else
70 {
71 *pulID = strtoul((PSZ)pStr,NULL,10);
72 rc = DosFreeResource(pStr);
73 }
74 return rc;
75}
76
77APIRET QueryNumberOfDrivers(HMODULE hmod,ULONG ulAdapterIdx,PULONG pulDrivers)
78{
79 PVOID pStr;
80 APIRET rc = NO_ERROR;
81 if (!pulDrivers)
82 {
83 return ERROR_INVALID_PARAMETER;
84 }
85 rc = DosGetResource(hmod,RT_RCDATA,(ulAdapterIdx+1)*10UL+1UL,&pStr);
86 if (rc)
87 {
88 *pulDrivers = 0UL;
89 }
90 else
91 {
92 ULONG i;
93 PSZ pTemp = (PSZ)pStr;
94 /* skip:
95 1.) max num adapters
96 2.) name of help file
97 3.) name of custom audio installation dll
98 4.) name of custom audio installation dll entry point
99 */
100 for(i=0;i<4;i++)
101 {
102 pTemp += strlen(pTemp)+sizeof(CHAR);
103 }
104 /*
105 Number of config.sys lines in i
106 */
107 i = strtoul(pTemp,NULL,10);
108 /*
109 skip the config.sys lines
110 */
111 do
112 {
113 pTemp += strlen(pTemp)+sizeof(CHAR);
114 }
115 while(i--);
116 /*
117 Now we get the number of drivers defined
118 */
119 *pulDrivers = strtoul(pTemp,NULL,10);
120 rc = DosFreeResource(pStr);
121 }
122 return rc;
123}
124
125APIRET QueryNumberOfConfigStrings(HMODULE hmod,ULONG ulAdapterIdx,PULONG pulNum)
126{
127 PVOID pStr;
128 APIRET rc = NO_ERROR;
129 if (!pulNum)
130 {
131 return ERROR_INVALID_PARAMETER;
132 }
133 rc = DosGetResource(hmod,RT_RCDATA,(ulAdapterIdx+1)*10UL+1UL,&pStr);
134 if (rc)
135 {
136 *pulNum = 0UL;
137 }
138 else
139 {
140 ULONG i;
141 PSZ pTemp = (PSZ)pStr;
142 /* skip:
143 1.) max num adapters
144 2.) name of help file
145 3.) name of custom audio installation dll
146 4.) name of custom audio installation dll entry point
147 */
148 for(i=0;i<4;i++)
149 {
150 pTemp += strlen(pTemp)+sizeof(CHAR);
151 }
152 /*
153 Now we get the number of config.sys lines
154 */
155 *pulNum = strtoul(pTemp,NULL,10);
156 rc = DosFreeResource(pStr);
157 }
158 return rc;
159}
160
161APIRET QueryConfigString(HMODULE hmod,ULONG ulAdapterIdx,ULONG ulConfigIdx,PSZ pszString)
162{
163 PVOID pStr;
164 APIRET rc = NO_ERROR;
165 if (!pszString)
166 {
167 return ERROR_INVALID_PARAMETER;
168 }
169 rc = DosGetResource(hmod,RT_RCDATA,(ulAdapterIdx+1)*10UL+1UL,&pStr);
170 if (rc)
171 {
172 *pszString = '\0';
173 }
174 else
175 {
176 ULONG i;
177 PSZ pTemp = (PSZ)pStr;
178 /* skip:
179 1.) max num adapters
180 2.) name of help file
181 3.) name of custom audio installation dll
182 4.) name of custom audio installation dll entry point
183 5.) number of config.sys lines
184 */
185 for(i=0;i<5;i++)
186 {
187 pTemp += strlen(pTemp)+sizeof(CHAR);
188 }
189 /*
190 advance to the config.sys line we are looking for
191 */
192 while(ulConfigIdx--)
193 {
194 pTemp += strlen(pTemp)+sizeof(CHAR);
195 }
196 /*
197 get the config.sys line
198 */
199 strcpy(pszString,pTemp);
200 rc = DosFreeResource(pStr);
201 }
202 return rc;
203}
204
205
206
207
208APIRET QueryDriverInstallNameAndType(HMODULE hmod,ULONG ulAdapterIdx,ULONG ulDriverIdx,PSZ pszName,PULONG pulDevType)
209{
210 PVOID pStr;
211 APIRET rc = NO_ERROR;
212 if (!pszName || !pulDevType)
213 {
214 return ERROR_INVALID_PARAMETER;
215 }
216 rc = DosGetResource(hmod,RT_RCDATA,(ulAdapterIdx+1)*10UL+(ulDriverIdx+1)+1UL,&pStr);
217 if (rc)
218 {
219 *pszName = '\0';
220 *pulDevType = 0UL;
221 }
222 else
223 {
224 PSZ pTemp = (PSZ)pStr;
225 /*
226 first string is install name
227 */
228 strcpy(pszName,pTemp);
229 pTemp += strlen(pTemp)+sizeof(CHAR);
230 /*
231 second string is device type
232 */
233 *pulDevType = strtoul(pTemp,NULL,10);
234 rc = DosFreeResource(pStr);
235 }
236 return rc;
237}
238
239
Note: See TracBrowser for help on using the repository browser.