|
I didn't write this file, it's on the visual C++ CDRom...
Hmmm... could you please post the piece of code where mmsystem.h is included? (especially the previous lines to #include <mmsystem.h> ) Thanx
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
#if !defined(AFX_MCI_H_098R22G3234_23453_235124_123A44HQ13451_INCLUDED_)
#define AFX_MCI_H_098R22G3234_23453_235124_123A44HQ13451_INCLUDED_
#include <mmsystem.h>
class CMsf {
public:
CMsf() {
m_dwMsf = 0;
}
CMsf(DWORD dwMsf) {
m_dwMsf = dwMsf;
}
CMsf(BYTE minute, BYTE second, BYTE frame) {
m_dwMsf = MCI_MAKE_MSF(minute, second, frame);
}
operator DWORD() const {return m_dwMsf;}
BYTE GetMinute() const { return MCI_MSF_MINUTE(m_dwMsf); }
BYTE GetSecond() const { return MCI_MSF_SECOND(m_dwMsf); }
BYTE GetFrame() const { return MCI_MSF_FRAME(m_dwMsf); }
protected:
DWORD m_dwMsf;
};
class CTmsf {
public:
CTmsf() {
m_dwTmsf = 0;
}
CTmsf(DWORD dwTmsf) {
m_dwTmsf = dwTmsf;
}
CTmsf(BYTE track, BYTE minute, BYTE second, BYTE frame) {
m_dwTmsf = MCI_MAKE_TMSF(track, minute, second, frame);
}
operator DWORD() const {return m_dwTmsf;}
BYTE GetTrack() const { return MCI_TMSF_TRACK(m_dwTmsf); }
BYTE GetMinute() const { return MCI_TMSF_MINUTE(m_dwTmsf); }
BYTE GetSecond() const { return MCI_TMSF_SECOND(m_dwTmsf); }
BYTE GetFrame() const { return MCI_TMSF_FRAME(m_dwTmsf); }
protected:
DWORD m_dwTmsf;
};
//////////////////////////////////////////////////////////////////////////
// The CMciDevice class is the base class for all MCI devices
//
class CMciDevice {
public:
// Common modes
static const DWORD ModeNotReady;
static const DWORD ModePause;
static const DWORD ModePlay;
static const DWORD ModeStop;
static const DWORD ModeOpen;
static const DWORD ModeRecord;
static const DWORD ModeSeek;
// Common status items
static const DWORD StatusReady;
static const DWORD StatusMediaPresent;
static const DWORD StatusMode;
static const DWORD StatusNumberOfTracks;
// Common capabilites
static const DWORD GetdevcapsCanEject;
static const DWORD GetdevcapsCanPlay;
static const DWORD GetdevcapsCanRecord;
static const DWORD GetdevcapsCanSave;
static const DWORD GetdevcapsCompound;
static const DWORD GetdevcapsDeviceType;
static const DWORD GetdevcapsHasAudio;
static const DWORD GetdevcapsHasVideo;
static const DWORD GetdevcapsUsesFiles;
// Device Info
static const DWORD InfoProduct;
// Device types
static const DWORD DevtypeAnimation;
static const DWORD DevtypeCdaudio;
static const DWORD DevtypeDat;
static const DWORD DevtypeDigitalvideo;
static const DWORD DevtypeOther;
static const DWORD DevtypeOverlay;
static const DWORD DevtypeScanner;
static const DWORD DevtypeSequencer;
static const DWORD DevtypeVcr;
static const DWORD DevtypeVideodisc;
static const DWORD DevtypeWaveaudio;
// Construction/Destruction
CMciDevice();
~CMciDevice();
// Open/Close: All derived classes must implement them
virtual DWORD Open(DWORD dwDeviceType, BOOL bShareable = FALSE);
virtual DWORD Open(LPCSTR lpstrName, BOOL bShareable = FALSE);
virtual DWORD Close();
// Attaches the device to a MCI device already opened
inline void Attach(UINT wDeviceID);
// Gets device ID
MCIDEVICEID GetDeviceID() const;
// Closes all open MCI devices: wait until devices are closed
static DWORD CloseAll();
// Retrieves a device static information
DWORD GetDevCaps(DWORD dwDevcaps, BOOL bItem = FALSE);
// Retrieves a device status item
virtual DWORD GetStatus(DWORD dwStatusItem);
// Retrieves the device mode
virtual DWORD GetMode();
// Retrieves a string information from the device
virtual DWORD GetInfo(DWORD dwInfo, LPSTR lpstrReturn, DWORD dwRetSize);
// Get/Set Callback Window
HWND GetCallbackHwnd() const;
void SetCallbackWnd(CWnd* pWnd);
void SetCallbackWnd(HWND hWnd);
// Sets MCI error report on/off
void ReportErrors(BOOL bReport = TRUE);
protected:
// mciSendCommand with error handling
DWORD SendCommand(UINT uMsg, DWORD fdwCommand, DWORD dwParam);
// MCI error report
static void ShowError(DWORD dwError);
MCIERROR GetLastError() const;
// Data members
protected:
MCIDEVICEID m_wDeviceID; // The device ID
HWND m_hMainWnd; // The callback window handle
private:
MCIERROR m_dwLastError; // The last error code
BOOL m_bReportErrors; // Report MCI errors?
};
#endif // !defined(AFX_MCI_H_098R22G3234_23453_235124_123A44HQ13451_INCLUDED_)
|
|
|
|
|
This is also a header file, right? Could you please post the .cpp where all this gets included? (It is not necessary that you post the entire file, just till the offending inclusion).
Also, please tick on the "Display this message as-is (no HTML)" checkbox right below the edit area --otherwise '<' characters mess up with the HTML.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sorry but I don't know which part of the code I have to give you so I prefer to give you the all thing...
SORRY FOR THE INCONVENIENCE
#include "stdafx.h"
#include "mci.h"
//////////////////////////////////////////////////////////////////////////
// CMciDevice implementation
//
// Common Modes
const DWORD CMciDevice::ModeNotReady = MCI_MODE_NOT_READY;
const DWORD CMciDevice::ModePause = MCI_MODE_PAUSE;
const DWORD CMciDevice::ModePlay = MCI_MODE_PLAY;
const DWORD CMciDevice::ModeStop = MCI_MODE_STOP;
const DWORD CMciDevice::ModeOpen = MCI_MODE_OPEN;
const DWORD CMciDevice::ModeRecord = MCI_MODE_RECORD;
const DWORD CMciDevice::ModeSeek = MCI_MODE_SEEK;
// Common status
const DWORD CMciDevice::StatusReady = MCI_STATUS_READY;
const DWORD CMciDevice::StatusMediaPresent = MCI_STATUS_MEDIA_PRESENT;
const DWORD CMciDevice::StatusMode = MCI_STATUS_MODE;
const DWORD CMciDevice::StatusNumberOfTracks = MCI_STATUS_NUMBER_OF_TRACKS;
// Common capabilites
const DWORD CMciDevice::GetdevcapsCanEject = MCI_GETDEVCAPS_CAN_EJECT;
const DWORD CMciDevice::GetdevcapsCanPlay = MCI_GETDEVCAPS_CAN_PLAY;
const DWORD CMciDevice::GetdevcapsCanRecord = MCI_GETDEVCAPS_CAN_RECORD;
const DWORD CMciDevice::GetdevcapsCanSave = MCI_GETDEVCAPS_CAN_SAVE;
const DWORD CMciDevice::GetdevcapsCompound = MCI_GETDEVCAPS_COMPOUND_DEVICE;
const DWORD CMciDevice::GetdevcapsDeviceType = MCI_GETDEVCAPS_DEVICE_TYPE;
const DWORD CMciDevice::GetdevcapsHasAudio = MCI_GETDEVCAPS_HAS_AUDIO;
const DWORD CMciDevice::GetdevcapsHasVideo = MCI_GETDEVCAPS_HAS_VIDEO;
const DWORD CMciDevice::GetdevcapsUsesFiles = MCI_GETDEVCAPS_USES_FILES;
const DWORD CMciDevice::InfoProduct = MCI_INFO_PRODUCT;
const DWORD CMciDevice::DevtypeAnimation = MCI_DEVTYPE_ANIMATION;
const DWORD CMciDevice::DevtypeCdaudio = MCI_DEVTYPE_CD_AUDIO;
const DWORD CMciDevice::DevtypeDat = MCI_DEVTYPE_DAT;
const DWORD CMciDevice::DevtypeDigitalvideo = MCI_DEVTYPE_DIGITAL_VIDEO;
const DWORD CMciDevice::DevtypeOther = MCI_DEVTYPE_OTHER;
const DWORD CMciDevice::DevtypeOverlay = MCI_DEVTYPE_OVERLAY;
const DWORD CMciDevice::DevtypeScanner = MCI_DEVTYPE_SCANNER;
const DWORD CMciDevice::DevtypeSequencer = MCI_DEVTYPE_SEQUENCER;
const DWORD CMciDevice::DevtypeVcr = MCI_DEVTYPE_VCR;
const DWORD CMciDevice::DevtypeVideodisc = MCI_DEVTYPE_VIDEODISC;
const DWORD CMciDevice::DevtypeWaveaudio = MCI_DEVTYPE_WAVEFORM_AUDIO;
CMciDevice::CMciDevice() {
m_wDeviceID = NULL;
m_hMainWnd = NULL;
m_bReportErrors = FALSE;
}
CMciDevice::~CMciDevice() {
}
// Open by device name (obtained by the registry or system.ini)
DWORD CMciDevice::Open(LPCSTR lpstrName, BOOL bShareable /*=FALSE*/)
{
ASSERT(lpstrName != NULL);
DWORD dwReturn;
MCI_OPEN_PARMS mciOpenParms;
// Open a device by specifying the device name.
mciOpenParms.lpstrDeviceType = lpstrName;
DWORD dwFlags = MCI_OPEN_TYPE|MCI_WAIT;
if (bShareable) dwFlags |= MCI_OPEN_SHAREABLE;
dwReturn = SendCommand(MCI_OPEN, dwFlags, (DWORD)(LPVOID) &mciOpenParms);
if (dwReturn == 0) {
// The device opened successfully; get the device ID.
m_wDeviceID = mciOpenParms.wDeviceID;
}
return dwReturn;
}
// Open by device type
DWORD CMciDevice::Open(DWORD dwDeviceType, BOOL bShareable /*=FALSE*/)
{
DWORD dwReturn;
MCI_OPEN_PARMS mciOpenParms;
// Opens a device by specifying a device-type constant.
mciOpenParms.lpstrDeviceType = (LPCSTR) dwDeviceType;
DWORD dwFlags = MCI_OPEN_TYPE|MCI_OPEN_TYPE_ID|MCI_WAIT;
if (bShareable) dwFlags |= MCI_OPEN_SHAREABLE;
dwReturn = SendCommand(MCI_OPEN, dwFlags,
(DWORD)(LPVOID) &mciOpenParms);
if (dwReturn == 0) {
// The device opened successfully; get the device ID.
m_wDeviceID = mciOpenParms.wDeviceID;
}
return dwReturn;
}
// Closes the device
DWORD CMciDevice::Close() {
MCI_GENERIC_PARMS mciGenericParms;
mciGenericParms.dwCallback = (DWORD) m_hMainWnd;
return SendCommand(MCI_CLOSE, 0, (DWORD) &mciGenericParms);
}
// Gets the current callback window
HWND CMciDevice::GetCallbackHwnd() const {
return m_hMainWnd;
}
// Set the current callback window
void CMciDevice::SetCallbackWnd(CWnd *pWnd) {
ASSERT(pWnd != NULL);
m_hMainWnd = pWnd->GetSafeHwnd();
}
// Set the current callback window
void CMciDevice::SetCallbackWnd(HWND hWnd) {
ASSERT(hWnd != NULL);
m_hMainWnd = hWnd;
}
// Attaches the MCI device to a device already opened
void CMciDevice::Attach(UINT wDeviceID) {
m_wDeviceID = wDeviceID;
}
// Gets the device ID
MCIDEVICEID CMciDevice::GetDeviceID() const {
return m_wDeviceID;
}
// mciSendCommand with error handling
DWORD CMciDevice::SendCommand(UINT uMsg, DWORD fdwCommand, DWORD dwParam) {
DWORD dwReturn;
if (dwReturn = mciSendCommand(m_wDeviceID, uMsg, fdwCommand, dwParam)) {
m_dwLastError = dwReturn;
if (m_bReportErrors)
ShowError(dwReturn);
}
return dwReturn;
}
MCIERROR CMciDevice::GetLastError() const {
return m_dwLastError;
}
// Generic MCI_GETDEVCAPS_ITEM command: good for all devices
DWORD CMciDevice::GetDevCaps(DWORD dwDevcaps, BOOL bItem /*=FALSE*/) {
MCI_GETDEVCAPS_PARMS mciCapsParms;
mciCapsParms.dwCallback = (DWORD) m_hMainWnd;
mciCapsParms.dwReturn = 0;
if (bItem) {
mciCapsParms.dwItem = dwDevcaps;
dwDevcaps |= MCI_GETDEVCAPS_ITEM;
}
SendCommand(MCI_GETDEVCAPS, dwDevcaps, (DWORD) &mciCapsParms);
return mciCapsParms.dwReturn;
}
// Generic MCI_INFO command
DWORD CMciDevice::GetInfo(DWORD dwInfo, LPSTR lpstrReturn, DWORD dwRetSize) {
MCI_INFO_PARMS mciInfoParms;
mciInfoParms.dwCallback = (DWORD) m_hMainWnd;
mciInfoParms.lpstrReturn = lpstrReturn;
mciInfoParms.dwRetSize = dwRetSize;
return SendCommand(MCI_INFO, dwInfo, (DWORD) &mciInfoParms);
}
// Set error report on/off
void CMciDevice::ReportErrors(BOOL bReport /*=TRUE*/) {
m_bReportErrors = bReport;
}
// Uses mciGetErrorString to get a textual description of an MCI error.
// Displays the error description using MessageBox.
void CMciDevice::ShowError(DWORD dwError)
{
char szErrorBuf[MAXERRORLENGTH];
MessageBeep(MB_ICONEXCLAMATION);
CWnd* pMainWnd = AfxGetApp()->m_pMainWnd;
ASSERT(pMainWnd != NULL);
HWND hMainWnd = pMainWnd->GetSafeHwnd();
if(mciGetErrorString(dwError, (LPSTR) szErrorBuf, MAXERRORLENGTH)) {
MessageBox(hMainWnd, szErrorBuf, _T("MCI Error"),
MB_ICONEXCLAMATION);
}
else
MessageBox(hMainWnd, _T("Unknown Error"), _T("MCI Error"),
MB_ICONEXCLAMATION);
}
// Closes all MCI devices opened by the application.
// Waits until devices are closed before returning.
DWORD CMciDevice::CloseAll()
{
DWORD dwReturn;
if (dwReturn = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_CLOSE, MCI_WAIT, NULL))
ShowError(dwReturn);
return dwReturn;
}
DWORD CMciDevice::GetMode() {
return GetStatus(StatusMode);
}
// Generic MCI_STATUS command
DWORD CMciDevice::GetStatus(DWORD dwItem) {
MCI_STATUS_PARMS mciStatusParms;
mciStatusParms.dwCallback = (DWORD) m_hMainWnd;
mciStatusParms.dwItem = dwItem;
mciStatusParms.dwReturn = 0;
SendCommand(MCI_STATUS, MCI_STATUS_ITEM, (DWORD) &mciStatusParms);
return mciStatusParms.dwReturn;
}
|
|
|
|
|
It's all very weird. Your code seems fine at first glance. Try the following:- Switch off the precompiled headers option for the project and do a "Rebuild all".
- If this fails, please post your
stdafx.h (if we go on like this, I'll be able to steal your project ).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sorry but I found these codes in a tutorial at
http://codeguru.earthweb.com/multimedia/cd_audio.shtml
I don't have a lot of experience with C++
I only know some bases
In fact, I have to make a program that play a CD audio, transorm the datas in a specific norm and send them through Fast ethernet to an other computer...
And I m lost in all these functions and classes...
I m trying to find some codes to play a CD , control a buffer... I know it's going to be hard ...
Do you know any good books on these topics ?
and I don't know how to switch off the precompiler header ....
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
//#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows 95 Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
|
|
|
|
|
Hey starn, this was tough Apparently there's a problem with mmsystem.h in VC++ 6.0. Follow this article in Usenet explaining how to solve it.
The guy talks about "preprocesor settings". I guess you won't know where those are (because you didn't know how to switch precompiled headers off either). Select Project->Settings, there you'll find lots of stuff, including the preprocessor settings and the precompiled headers options. Give yourself sometime to get used to the IDE.
Good luck with your project.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I just woke up, I m from Belgium and I couldn't wait for your answer last night because my friends came to pick me up to go out.I haven't tried your solution yet but I wanted to thank you a lot !!!
I'll tell you if it's working or not, thanks again
|
|
|
|
|
I couldn't wait for your answer last night because my friends came to pick me up to go out.
Same here I posted this answer just before going out for a couple of drinks --my friends were running out of patience.
I'll tell you if it's working or not, thanks again
Please do it. You are welcome.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I m sorry to tell you that I still got the 2 same errors... And I think I did everything correctly...
You're from Spain, I love Spain soooo much! I went to Madrid a few month ago, crazy city!!and we went , me and my girlfriend, to Ibiza twice the past two years.
Anyway, thanks for trying to solve my problem.My ears are wide open if you have an other solution
At least, I know that I m not the only one that got this problem...
|
|
|
|
|
Oh, this is becoming personal Usually this kind of errors don't last that long...
I'd try to load the offending project from the URL you provided some messages ago, but on weekends I've got no IDE handy.
Do a search on groups.google.com for "mmsystem.h C2146". Apparently a lot of people have run into the same problem in the past. Try to follow the advice given there. Sorry I couldn't be more helpful. Good luck!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
thanks a lot, i'll try that, have a nice week-end...
|
|
|
|
|
I have done a fair chunk of reading and writing from/to files, but I was wondering if there is anyway of not specifying the input buffer's size when you are reading in. For instance, I would like to read in an entire line, but I don't want to read it into a TCHAR x[1000], I want to read it into something more flexible.
how would i do this?
|
|
|
|
|
Read into a CString.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
Holy christ nice timing Nish!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
This is unfair my answer gets listed the last, yet its associated time is prior than the others' !!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
This is unfair my answer gets listed the last, yet its associated time is prior than the others' !!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Joaquín M López Muñoz wrote:
my answer gets listed the last, yet its associated time is prior than the others' !!
Thats cause you used STL in your answer.
Chris M might not like that much.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
LOL
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
CFile myFile("theFile.dat", options);
int nSize = 663;
char* buff = new char[nSize];
myFile.Read(&buff, nSize);
delete [] buff;
I think this is what yer after...
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
If you are into iostream s, this is the way:
std::istream in;
std::string str;
...
std::getline(in,str);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
That's definitely the way I'd do it (you need an ifstream though not an istream) you get all the flexibility in the world and code re-use goes up 'cos you're not having to talk MFC. You can always use .c_str() on it if you need to get down and dirty. Why does anybody use anything else?
I hear The Prisoner and 7of9 aren't getting along too well these days.
|
|
|
|
|
how do you run two for's at once?
|
|
|
|
|
int i = 0 ;
int j = 0 ;
for ( ; i < 10 && j < 10 ; ++i, ++j)
{
}
Maybe that would do the job. I originally put i++, j++, but then I thought "Holy crap, I'll get blasted by all those c++ efficiency coders out there"
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
Please step to the rear of the car and make room for more victims. - John Simmons the Outlaw programmer, 1st Feb 2002, in the lounge
|
|
|
|
|
|