source: trunk/stream_ioproc/source/testproc.c@ 2

Last change on this file since 2 was 2, checked in by stevenhl, 8 years ago

Import sources from cwmm-full.zip dated 2005-03-21

File size: 5.3 KB
Line 
1/* This program (install.c) is Public Domain */
2
3#define INCL_OS2MM
4#define INCL_DOS
5#include <os2.h>
6#include <os2me.h>
7#include <string.h>
8#include <stdlib.h>
9#include <stdio.h>
10#include "streamproc.h"
11
12
13//#include <minstall.h>
14//If you don't have minstall.h, this is all that is needed
15typedef struct _INSTMCISENDCOMMAND
16 {
17 USHORT wDeviceID;
18 USHORT wMessage;
19 ULONG dwParam1;
20 ULONG dwParam2;
21 USHORT wUserParm;
22 } INSTMCISENDCOMMAND;
23
24typedef INSTMCISENDCOMMAND *PINSTMCISENDCOMMAND;
25#define IM_MCI_SEND_COMMAND 0x057C
26#define IM_MCI_EXTENDED_SYSINFO 0x057E
27#define IM_LOG_ERROR 0x0573
28
29
30int deleteProc(char *Fourcc) {
31 MMINIFILEINFO mmIniFileInfo;
32 ULONG ulFlags = 0L;
33 ULONG rc;
34
35 memset( &mmIniFileInfo, '\0', sizeof(MMINIFILEINFO) );
36 mmIniFileInfo.fccIOProc = mmioStringToFOURCC(Fourcc,0);
37 ulFlags = MMIO_FINDPROC;
38 rc = mmioIniFileHandler( &mmIniFileInfo,
39 ulFlags);
40 if (rc) {
41 printf("Couldn't find IOProc %s. Code: %ld\n",Fourcc,rc);
42 return rc;
43 }
44
45 ulFlags = MMIO_REMOVEPROC;
46 rc = mmioIniFileHandler( &mmIniFileInfo,
47 ulFlags);
48 if (rc) {
49 printf("Couldn't remove IOProc %s. Code: %ld\n",Fourcc,rc);
50 return rc;
51 } else {
52 printf("Removed IOProc %s.\n",Fourcc);
53 } /* endif */
54
55 {
56 char dllname[DLLNAME_SIZE] = "DLL\\";
57 char fulldllname[DLLNAME_SIZE] = "";
58
59 strncat(dllname, mmIniFileInfo.szDLLName,sizeof(dllname));
60 strncat(dllname, ".DLL",sizeof(dllname));
61 rc = DosSearchPath(2,"MMBASE",dllname,fulldllname,sizeof(fulldllname));
62 if (rc) {
63 printf("Couldn't find %s. code:%ld\n", dllname,rc);
64 return rc;
65 }
66
67 rc = DosReplaceModule(fulldllname,NULL,NULL);
68 if (rc) {
69 printf("Couldn't unlock %s. code:%ld\n", fulldllname,rc);
70 } else {
71 printf("Unlocked %s.\n", fulldllname);
72 } /* endif */
73
74 rc = DosDelete(fulldllname);
75 if (rc) {
76 printf("Couldn't delete %s. code:%ld\n", fulldllname,rc);
77 return rc;
78 } else {
79 printf("Deleted %s.\n", fulldllname);
80 } /* endif */
81 }
82
83 return 0;
84}
85
86int queryNumStorageProcs(void)
87{
88 MMFORMATINFO mmfinfo;
89 LONG lNum=0;
90
91 memset( &mmfinfo, '\0', sizeof(MMFORMATINFO) );
92 mmfinfo.ulIOProcType=MMIO_IOPROC_STORAGESYSTEM;
93 mmfinfo.ulMediaType=MMIO_MEDIATYPE_AUDIO;
94
95 mmioQueryFormatCount(&mmfinfo, &lNum, 0, 0);
96 return lNum;
97}
98
99BOOL getFormats(LONG lNum)
100{
101 MMFORMATINFO mmfinfo;
102 PMMFORMATINFO pmmfi;
103
104 LONG lFormatsRead;
105 int a;
106
107 memset( &mmfinfo, '\0', sizeof(MMFORMATINFO) );
108 mmfinfo.ulIOProcType=MMIO_IOPROC_STORAGESYSTEM;
109 // mmfinfo.ulMediaType=MMIO_MEDIATYPE_AUDIO;
110
111 if((pmmfi=(PMMFORMATINFO)malloc(lNum*sizeof(MMFORMATINFO)))==NULLHANDLE)
112 return FALSE;
113
114 printf("mmioGetFormats() returned: %d \n",
115 mmioGetFormats(&mmfinfo, lNum, pmmfi, &lFormatsRead,0,0));
116
117 printf("Info for %d formats read.\n\n", lFormatsRead);
118
119 for(a=0;a<lFormatsRead;a++)
120 {
121 char name[1000];
122 LONG lBytesRead;
123
124 if(0==mmioGetFormatName(pmmfi, name, &lBytesRead, 0L, 0L))
125 {
126 name[lBytesRead]=0;
127 printf("%2d: %s\n", a+1, name);
128 }
129 pmmfi++;
130 }
131 return TRUE;
132}
133
134int installProc(char * dllPath) {
135 MMINIFILEINFO mmIniFileInfo;
136 ULONG ulFlags = 0L;
137 ULONG rc;
138#if 0
139
140 memset( &mmIniFileInfo, '\0', sizeof(MMINIFILEINFO) );
141 mmIniFileInfo.fccIOProc = FOURCC_STREAM;//mmioStringToFOURCC(,0);
142 ulFlags = MMIO_FINDPROC;
143 rc = mmioIniFileHandler( &mmIniFileInfo,
144 ulFlags);
145 if (rc) {
146 printf("Couldn't find IOProc %s. Code: %ld\n",Fourcc,rc);
147 return rc;
148 }
149
150 ulFlags = MMIO_REMOVEPROC;
151 rc = mmioIniFileHandler( &mmIniFileInfo,
152 ulFlags);
153 if (rc) {
154 printf("Couldn't remove IOProc %s. Code: %ld\n",Fourcc,rc);
155 return rc;
156 } else {
157 printf("Removed IOProc %s.\n",Fourcc);
158 } /* endif */
159
160 {
161 char dllname[DLLNAME_SIZE] = "DLL\\";
162 char fulldllname[DLLNAME_SIZE] = "";
163
164 strncat(dllname, mmIniFileInfo.szDLLName,sizeof(dllname));
165 strncat(dllname, ".DLL",sizeof(dllname));
166 rc = DosSearchPath(2,"MMBASE",dllname,fulldllname,sizeof(fulldllname));
167 if (rc) {
168 printf("Couldn't find %s. code:%ld\n", dllname,rc);
169 return rc;
170 }
171
172 rc = DosReplaceModule(fulldllname,NULL,NULL);
173 if (rc) {
174 printf("Couldn't unlock %s. code:%ld\n", fulldllname,rc);
175 } else {
176 printf("Unlocked %s.\n", fulldllname);
177 } /* endif */
178
179 rc = DosDelete(fulldllname);
180 if (rc) {
181 printf("Couldn't delete %s. code:%ld\n", fulldllname,rc);
182 return rc;
183 } else {
184 printf("Deleted %s.\n", fulldllname);
185 } /* endif */
186 }
187#endif
188 return 0;
189}
190
191int main(int argc, char **argv) {
192
193 printf("Test stream io proc...\n");
194
195 printf("Installed storage procs: %d\n", queryNumStorageProcs());
196 getFormats(queryNumStorageProcs());
197
198 // getFormats(45);
199 installProc("STREAMIO.DLL");
200 return 0;
201}
202
203
204
Note: See TracBrowser for help on using the repository browser.