水無瀬の部屋 > Programming > sample > tools > mci > toolmci.cpp |
---|
1: //*********************************************************
2: // プロジェクト: TOOLS
3: // ファイル名: toolmci.h
4: //*********************************************************
5: #include <mci/toolmci.h> //
6: #include <header/tooldbg.h> //
7: #include <header/toolbase.h> //
8: #include <header/toolwind.h>
9:
10:
11: //---------------------------------------------------------
12: // マクロ の 定義
13: //---------------------------------------------------------
14: #define DWORD_PTR_TO_DWORD( dp ) PtrToUlong( dp ) // _W64
15:
16:
17: //******************************************************************************************************************
18: // MCI_OPEN
19: //******************************************************************************************************************
20: //*********************************************************
21: // MCI_SendOpenCommand
22: //*********************************************************
23: bool
24: MCI_SendOpenCommand
25: (
26: DWORD flags,
27: MCI_OPEN_PARMS *mop
28: )
29: {
30: // パラメタの仮定
31: ASSERT( IsValidPtr( mop, sizeof( *mop ) ) );
32: ASSERT( IsValidStringPtr( mop->lpstrDeviceType ) );
33: ASSERT( !mop->lpstrElementName || IsValidStringPtr( mop->lpstrElementName ) );
34: ASSERT( !((HWND)(mop->dwCallback)) || IsValidWindow( (HWND)mop->dwCallback ) );
35:
36: return 0 == mciSendCommand( 0, MCI_OPEN, flags, (DWORD_PTR)mop ); //
37: }//MCI_SendOpenCommand
38:
39: //*********************************************************
40: // MCI_Open
41: // flags = MCI_OPEN_TYPE, MCI_OPEN_SHAREABLE, ...
42: //*********************************************************
43: bool
44: MCI_Open
45: (
46: HWND hWnd,
47: const char *device,
48: const char *element,
49: DWORD flags,
50: MCIDEVICEID *mciID
51: )
52: {
53: // パラメタの仮定
54: ASSERT( !hWnd || IsValidWindow( hWnd ) );
55: ASSERT( IsValidStringPtr( device ) );
56: ASSERT( !element || IsValidStringPtr( element ) );
57: ASSERT( IsValidPtr( mciID, sizeof( *mciID ) ) );
58:
59: MCI_OPEN_PARMS mop;
60: memzero( &mop, sizeof( mop ) );
61: mop.dwCallback = (DWORD_PTR)hWnd;
62: mop.lpstrDeviceType = device;
63: mop.lpstrElementName = element;
64: if ( !MCI_SendOpenCommand( flags, &mop ) )
65: return false; //
66:
67: *mciID = mop.wDeviceID;
68: return true;
69: }//MCI_Open
70:
71:
72: //******************************************************************************************************************
73: // MCI_CLOSE
74: //******************************************************************************************************************
75: //*********************************************************
76: // MCI_SendCloseCommand
77: //*********************************************************
78: bool
79: MCI_SendCloseCommand
80: (
81: MCIDEVICEID mciID,
82: DWORD flags,
83: MCI_GENERIC_PARMS *mgp
84: )
85: {
86: // パラメタの仮定
87: ASSERT( IsValidPtr( mgp, sizeof( *mgp ) ) );
88: ASSERT( !((HWND)(mgp->dwCallback)) || IsValidWindow( (HWND)mgp->dwCallback ) );
89:
90: return 0 == mciSendCommand( mciID, MCI_CLOSE, flags, (DWORD_PTR)mgp );
91: }//MCI_SendCloseCommand
92:
93: //*********************************************************
94: // MCI_Close
95: //*********************************************************
96: bool
97: MCI_Close
98: (
99: HWND hWnd,
100: MCIDEVICEID mciID,
101: DWORD flags
102: )
103: {
104: // パラメタの仮定
105: ASSERT( !hWnd || IsValidWindow( hWnd ) );
106:
107: MCI_GENERIC_PARMS mgp;
108: memzero( &mgp, sizeof( mgp ) );
109: mgp.dwCallback = (DWORD_PTR)hWnd;
110: return MCI_SendCloseCommand( mciID, flags, &mgp );
111: }//MCI_Close
112:
113:
114: //******************************************************************************************************************
115: // MCI_PLAY
116: //******************************************************************************************************************
117: //*********************************************************
118: // MCI_SendPlayCommand
119: //*********************************************************
120: bool
121: MCI_SendPlayCommand
122: (
123: MCIDEVICEID mciID,
124: DWORD flags,
125: MCI_PLAY_PARMS *mpp
126: )
127: {
128: // パラメタの仮定
129: ASSERT( IsValidPtr( mpp, sizeof( *mpp ) ) );
130: ASSERT( !((HWND)(mpp->dwCallback)) || IsValidWindow( (HWND)mpp->dwCallback ) );
131:
132: return 0 == mciSendCommand( mciID, MCI_PLAY, flags, (DWORD_PTR)mpp );
133: }//MCI_SendPlayCommand
134:
135: //*********************************************************
136: // MCI_Play
137: //*********************************************************
138: bool
139: MCI_Play
140: (
141: HWND hWnd,
142: MCIDEVICEID mciID,
143: DWORD flags,
144: DWORD dwFrom,
145: DWORD dwTo
146: )
147: {
148: // パラメタの仮定
149: ASSERT( !hWnd || IsValidWindow( hWnd ) );
150:
151: MCI_PLAY_PARMS mpp;
152: memzero( &mpp, sizeof( mpp ) );
153: mpp.dwCallback = (DWORD_PTR)hWnd;
154: mpp.dwFrom = dwFrom;
155: mpp.dwTo = dwTo;
156: return MCI_SendPlayCommand( mciID, flags, &mpp );
157: }//MCI_Play
158:
159:
160: //******************************************************************************************************************
161: // MCI_STOP
162: //******************************************************************************************************************
163: //*********************************************************
164: // MCI_SendStopCommand
165: //*********************************************************
166: bool
167: MCI_SendStopCommand
168: (
169: MCIDEVICEID mciID,
170: DWORD flags,
171: MCI_GENERIC_PARMS *mgp
172: )
173: {
174: // パラメタの仮定
175: ASSERT( IsValidPtr( mgp, sizeof( *mgp ) ) );
176: ASSERT( !((HWND)(mgp->dwCallback)) || IsValidWindow( (HWND)mgp->dwCallback ) );
177:
178: return 0 == mciSendCommand( mciID, MCI_STOP, flags, (DWORD_PTR)mgp );
179: }//MCI_SendStopCommand
180:
181: //*********************************************************
182: // MCI_Stop
183: //*********************************************************
184: bool
185: MCI_Stop
186: (
187: HWND hWnd,
188: MCIDEVICEID mciID,
189: DWORD flags
190: )
191: {
192: // パラメタの仮定
193: ASSERT( !hWnd || IsValidWindow( hWnd ) );
194:
195: MCI_GENERIC_PARMS mgp;
196: memzero( &mgp, sizeof( mgp ) );
197: mgp.dwCallback = (DWORD_PTR)hWnd;
198: return MCI_SendStopCommand( mciID, flags, &mgp );
199: }//MCI_Stop
200:
201:
202: //******************************************************************************************************************
203: // MCI_PAUSE
204: //******************************************************************************************************************
205: //*********************************************************
206: // MCI_SendPauseCommand
207: //*********************************************************
208: bool
209: MCI_SendPauseCommand
210: (
211: MCIDEVICEID mciID,
212: DWORD flags,
213: MCI_GENERIC_PARMS *mgp
214: )
215: {
216: // パラメタの仮定
217: ASSERT( IsValidPtr( mgp, sizeof( *mgp ) ) );
218: ASSERT( !((HWND)(mgp->dwCallback)) || IsValidWindow( (HWND)mgp->dwCallback ) );
219:
220: return 0 == mciSendCommand( mciID, MCI_PAUSE, flags, (DWORD_PTR)mgp );
221: }//MCI_SendPauseCommand
222:
223: //*********************************************************
224: // MCI_Pause
225: //*********************************************************
226: bool
227: MCI_Pause
228: (
229: HWND hWnd,
230: MCIDEVICEID mciID,
231: DWORD flags
232: )
233: {
234: // パラメタの仮定
235: ASSERT( !hWnd || IsValidWindow( hWnd ) );
236:
237: MCI_GENERIC_PARMS mgp;
238: memzero( &mgp, sizeof( mgp ) );
239: mgp.dwCallback = (DWORD_PTR)hWnd;
240: return MCI_SendPauseCommand( mciID, flags, &mgp );
241: }//MCI_Pause
242:
243:
244: //******************************************************************************************************************
245: // MCI_RESUME
246: //******************************************************************************************************************
247: //*********************************************************
248: // MCI_SendResumeCommand
249: //*********************************************************
250: bool
251: MCI_SendResumeCommand
252: (
253: MCIDEVICEID mciID,
254: DWORD flags,
255: MCI_GENERIC_PARMS *mgp
256: )
257: {
258: // パラメタの仮定
259: ASSERT( IsValidPtr( mgp, sizeof( *mgp ) ) );
260: ASSERT( !((HWND)(mgp->dwCallback)) || IsValidWindow( (HWND)mgp->dwCallback ) );
261:
262: return 0 == mciSendCommand( mciID, MCI_RESUME, flags, (DWORD_PTR)mgp );
263: }//MCI_SendResumeCommand
264:
265: //*********************************************************
266: // MCI_Resume
267: //*********************************************************
268: bool MCI_Resume( HWND hWnd, MCIDEVICEID mciID, DWORD flags )
269: {
270: // パラメタの仮定
271: ASSERT( !hWnd || IsValidWindow( hWnd ) );
272:
273: MCI_GENERIC_PARMS mgp;
274: memzero( &mgp, sizeof( mgp ) );
275: mgp.dwCallback = (DWORD_PTR)hWnd;
276: return MCI_SendResumeCommand( mciID, flags, &mgp );
277: }//MCI_Resume
278:
279:
280: //******************************************************************************************************************
281: // MCI_STATUS
282: //******************************************************************************************************************
283: //*********************************************************
284: // MCI_SendStatusCommand
285: //*********************************************************
286: bool
287: MCI_SendStatusCommand
288: (
289: MCIDEVICEID mciID,
290: DWORD flags,
291: MCI_STATUS_PARMS *msp
292: )
293: {
294: // パラメタの仮定
295: ASSERT( IsValidPtr( msp, sizeof( *msp ) ) );
296: ASSERT( !((HWND)(msp->dwCallback)) || IsValidWindow( (HWND)msp->dwCallback ) );
297:
298: return 0 == mciSendCommand( mciID, MCI_STATUS, flags, (DWORD_PTR)msp ); //
299: }//MCI_SendStatusCommand
300:
301: //*********************************************************
302: // MCI_GetTrackCount
303: //*********************************************************
304: bool
305: MCI_GetTrackCount
306: (
307: HWND hWnd,
308: MCIDEVICEID mciID,
309: DWORD flags,
310: DWORD *dwTracks
311: )
312: {
313: // パラメタの仮定
314: ASSERT( !hWnd || IsValidWindow( hWnd ) );
315: ASSERT( IsValidPtr( dwTracks, sizeof( *dwTracks ) ) );
316:
317: MCI_STATUS_PARMS msp;
318: memzero( &msp, sizeof( msp ) );
319: msp.dwCallback = (DWORD_PTR)hWnd;
320: msp.dwItem = MCI_STATUS_NUMBER_OF_TRACKS;
321: if ( !MCI_SendStatusCommand( mciID, MCI_STATUS_ITEM | flags, &msp ) )
322: return false; //
323:
324: //
325: *dwTracks = DWORD_PTR_TO_DWORD( msp.dwReturn );
326:
327: return true;
328: }//MCI_GetTrackCount
329:
330: //*********************************************************
331: // MCI_GetStatusPosition
332: //*********************************************************
333: bool
334: MCI_GetStatusPosition
335: (
336: HWND hWnd,
337: MCIDEVICEID mciID,
338: DWORD flags,
339: DWORD *dwPos
340: )
341: {
342: // パラメタの仮定
343: ASSERT( !hWnd || IsValidWindow( hWnd ) );
344: ASSERT( IsValidPtr( dwPos, sizeof( *dwPos ) ) );
345:
346: MCI_STATUS_PARMS msp;
347: memzero( &msp, sizeof( msp ) );
348: msp.dwCallback = (DWORD_PTR)hWnd;
349: msp.dwItem = MCI_STATUS_POSITION;
350: if ( !MCI_SendStatusCommand( mciID, MCI_STATUS_ITEM | flags, &msp ) )
351: return false; //
352:
353: //
354: *dwPos = DWORD_PTR_TO_DWORD( msp.dwReturn );
355:
356: return true;
357: }//MCI_GetStatusPosition
358:
359: //*********************************************************
360: // MCI_GetStatusMode
361: //*********************************************************
362: bool
363: MCI_GetStatusMode
364: (
365: HWND hWnd,
366: MCIDEVICEID mciID,
367: DWORD flags,
368: DWORD *dwMode
369: )
370: {
371: // パラメタの仮定
372: ASSERT( !hWnd || IsValidWindow( hWnd ) );
373: ASSERT( IsValidPtr( dwMode, sizeof( *dwMode ) ) );
374:
375: MCI_STATUS_PARMS msp;
376: memzero( &msp, sizeof( msp ) );
377: msp.dwCallback = (DWORD_PTR)hWnd;
378: msp.dwItem = MCI_STATUS_MODE;
379: if ( !MCI_SendStatusCommand( mciID, MCI_STATUS_ITEM | flags, &msp ) )
380: return false; //
381:
382: //
383: *dwMode = DWORD_PTR_TO_DWORD( msp.dwReturn );
384:
385: return true;
386: }//MCI_GetStatusMode
387:
388: //*********************************************************
389: // MCI_GetTimeFormat
390: // 時間情報の種類を取得する
391: // dwTimeFormat = MCI_FORMAT_TMSF, ...
392: //*********************************************************
393: bool
394: MCI_GetTimeFormat
395: (
396: HWND hWnd,
397: MCIDEVICEID mciID,
398: DWORD flags,
399: DWORD *dwTimeFormat
400: )
401: {
402: // パラメタの仮定
403: ASSERT( !hWnd || IsValidWindow( hWnd ) );
404: ASSERT( IsValidPtr( dwTimeFormat, sizeof( *dwTimeFormat ) ) );
405:
406: MCI_STATUS_PARMS msp;
407: memzero( &msp, sizeof( msp ) );
408: msp.dwCallback = (DWORD_PTR)hWnd;
409: msp.dwItem = MCI_STATUS_TIME_FORMAT;
410: if ( !MCI_SendStatusCommand( mciID, MCI_STATUS_ITEM | flags, &msp ) )
411: return false; //
412:
413: //
414: *dwTimeFormat = DWORD_PTR_TO_DWORD( msp.dwReturn );
415:
416: return true;
417: }//MCI_GetTimeFormat
418:
419: //*********************************************************
420: // MCI_GetTrackLength
421: //*********************************************************
422: bool
423: MCI_GetTrackLength
424: (
425: HWND hWnd,
426: MCIDEVICEID mciID,
427: int nTrack,
428: DWORD flags,
429: DWORD *dwLength
430: )
431: {
432: // パラメタの仮定
433: ASSERT( !hWnd || IsValidWindow( hWnd ) );
434: ASSERT( MCI_IsValidTrackNum( hWnd, mciID, nTrack ) );
435: ASSERT( IsValidPtr( dwLength, sizeof( *dwLength ) ) );
436:
437: MCI_STATUS_PARMS msp;
438: memzero( &msp, sizeof( msp ) );
439: msp.dwCallback = (DWORD_PTR)hWnd;
440: msp.dwItem = MCI_STATUS_LENGTH;
441: msp.dwTrack = nTrack;
442: if ( !MCI_SendStatusCommand( mciID, MCI_TRACK | MCI_STATUS_ITEM | flags, &msp ) )
443: return false; //
444:
445: //
446: *dwLength = DWORD_PTR_TO_DWORD( msp.dwReturn );
447:
448: return true;
449: }//MCI_GetTrackLength
450:
451: //*********************************************************
452: // MCI_GetTrackType
453: //*********************************************************
454: bool
455: MCI_GetTrackType
456: (
457: HWND hWnd,
458: MCIDEVICEID mciID,
459: int nTrack,
460: DWORD flags,
461: DWORD *dwType
462: )
463: {
464: // パラメタの仮定
465: ASSERT( !hWnd || IsValidWindow( hWnd ) );
466: ASSERT( MCI_IsValidTrackNum( hWnd, mciID, nTrack ) );
467: ASSERT( IsValidPtr( dwType, sizeof( *dwType ) ) );
468:
469: MCI_STATUS_PARMS msp;
470: memzero( &msp, sizeof( msp ) );
471: msp.dwCallback = (DWORD_PTR)hWnd;
472: msp.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
473: msp.dwTrack = nTrack;
474: if ( !MCI_SendStatusCommand( mciID, MCI_TRACK | MCI_STATUS_ITEM | flags, &msp ) )
475: return false; //
476:
477: //
478: *dwType = DWORD_PTR_TO_DWORD( msp.dwReturn );
479:
480: ASSERT( (MCI_CDA_TRACK_AUDIO == *dwType)
481: || (MCI_CDA_TRACK_OTHER == *dwType) );
482: return true;
483: }//MCI_GetTrackType
484:
485:
486: //******************************************************************************************************************
487: // MCI_SET
488: //******************************************************************************************************************
489: //*********************************************************
490: // MCI_SendSetCommand
491: //*********************************************************
492: bool
493: MCI_SendSetCommand
494: (
495: MCIDEVICEID mciID,
496: DWORD flags,
497: MCI_SET_PARMS *msp
498: )
499: {
500: // パラメタの仮定
501: ASSERT( IsValidPtr( msp, sizeof( *msp ) ) );
502: ASSERT( !((HWND)(msp->dwCallback)) || IsValidWindow( (HWND)msp->dwCallback ) );
503:
504: return 0 == mciSendCommand( mciID, MCI_SET, flags, (DWORD_PTR)msp );
505: }//MCI_SendSetCommand
506:
507: //*********************************************************
508: // MCI_SetTimeFormat
509: // 時間情報の種類を設定する
510: // dwTimeFormat = MCI_FORMAT_TMSF, ...
511: //*********************************************************
512: bool
513: MCI_SetTimeFormat
514: (
515: HWND hWnd,
516: MCIDEVICEID mciID,
517: DWORD flags,
518: DWORD dwTimeFormat
519: )
520: {
521: // パラメタの仮定
522: ASSERT( !hWnd || IsValidWindow( hWnd ) );
523:
524: MCI_SET_PARMS msp;
525: memzero( &msp, sizeof( msp ) );
526: msp.dwCallback = (DWORD_PTR)hWnd;
527: msp.dwTimeFormat = dwTimeFormat;
528: return MCI_SendSetCommand( mciID, MCI_SET_TIME_FORMAT | flags, &msp );
529: }//MCI_SetTimeFormat
530:
531: //*********************************************************
532: // MCI_DoorOpen
533: //*********************************************************
534: bool
535: MCI_DoorOpen
536: (
537: HWND hWnd,
538: MCIDEVICEID mciID,
539: DWORD flags
540: )
541: {
542: // パラメタの仮定
543: ASSERT( !hWnd || IsValidWindow( hWnd ) );
544:
545: MCI_SET_PARMS msp;
546: memzero( &msp, sizeof( msp ) );
547: msp.dwCallback = (DWORD_PTR)hWnd;
548: return MCI_SendSetCommand( mciID, MCI_SET_DOOR_OPEN | flags, &msp );
549: }//MCI_DoorOpen
550:
551: //*********************************************************
552: // MCI_DoorClose
553: //*********************************************************
554: bool
555: MCI_DoorClose
556: (
557: HWND hWnd,
558: MCIDEVICEID mciID,
559: DWORD flags
560: )
561: {
562: // パラメタの仮定
563: ASSERT( !hWnd || IsValidWindow( hWnd ) );
564:
565: MCI_SET_PARMS msp;
566: memzero( &msp, sizeof( msp ) );
567: msp.dwCallback = (DWORD_PTR)hWnd;
568: return MCI_SendSetCommand( mciID, MCI_SET_DOOR_CLOSED | flags, &msp );
569: }//MCI_DoorClose
570:
571:
572: //******************************************************************************************************************
573: // util
574: //******************************************************************************************************************
575: //*********************************************************
576: // MCI_IsValidTrackNum
577: //*********************************************************
578: bool
579: MCI_IsValidTrackNum
580: (
581: HWND hWnd,
582: MCIDEVICEID mciID,
583: int nTrack
584: )
585: {
586: // パラメタの仮定
587: ASSERT( !hWnd || IsValidWindow( hWnd ) );
588:
589: DWORD dwNum;
590: if ( !MCI_GetTrackCount( hWnd, mciID, MCI_WAIT, &dwNum ) )
591: return false; //
592:
593: return (0 < nTrack) && (nTrack <= (int)dwNum);
594: }//MCI_IsValidTrackNum
595:
596:
597: //** end **
598:
参照:
水無瀬の部屋 > sample > tools > mci > toolmci.cpp |
---|
このページは cpp2web が出力しました。
水無瀬 優 postmaster@katsura-kotonoha.sakura.ne.jp
http://katsura-kotonoha.sakura.ne.jp/prog/code/tools/mci/toolmci_cpp.shtml
>> Amazon.co.jp 『たまゆら童子』 へ
>> 楽天ブックス 『たまゆら童子』 へ