|
i can't understand this:
#define IOC_VENDOR 0x18000000
where,
what's 0x18000000?
anyone can help me?
thanks a lot.
|
|
|
|
|
|
But i need to understand what it means.
|
|
|
|
|
it mean that you define the macro IOC_VENDOR which will value 0x18000000.
a #define macro replace every occurence of IOC_VENDOR in the source code before the real compilation time (this is called a preprocessor directive obviously) by the value associated...
that means, in your code, you use explicit IOC_VENDOR, but the compiler will handle actually 0x18000000 (which is the hexadecimal for 402653184).
|
|
|
|
|
|
Hi,
How to add multiple colors in progress control.
|
|
|
|
|
See here[^]
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
Actually i want to fill four different colors in progress control each occupying 25% of the total space.Based on certain conditions the colors should be displayed.Is there any idea.
|
|
|
|
|
Did you bother to click on the link I provided you with? Hasn't the author done the same thing in that article?
|
|
|
|
|
Hi
all's
I am making an application in VC++ and my requirment is
to upload CV in database (Its would work like file in HTML)
can any one please told me about this
Thanking You
|
|
|
|
|
Can you use FTP?
CFtpConnection manages the FTP connection to directly manipulate the files on the server.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi to all,
I want to design code in C++ that will transfer (Generated) Data on particular Bitrate (say 3 Kbits/sec) & repeat the (Generated) Data within a particular period (say 2 sec.s) < i.e to Transfer Data reapeating leass than 2 seconds with Bitrate of 3 Kbits/sec).
Can anyone help me for this,
or can anyone suggest me a algorithm/code to transfer data at particular rate?
I tried it using 'MachineCycle', but as I am using it in loop, it takes lost of processing due to lack of 'Sleep()' command for less than 1 second.
|
|
|
|
|
Maybe you have to use a Multimedia Timer . A nice article about is here [^] (I know, is for .NET , but Multimedia Timer is also available using standard API).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
how to read and write files in flash memory of usb flash drive using mfc? anyone who knows please help me
|
|
|
|
|
What is so special about writing a file into usb? Can't you simply use CFile?
|
|
|
|
|
see its my task to read all the files from usb and display it
|
|
|
|
|
My question was how different is reading a file from USB than reading a file from the hard disk? Can't you use CFile? What exactly are you unable to do?
|
|
|
|
|
those file will be in flash memory. how to read and write from it
|
|
|
|
|
Use CFile to read and write from and to files. You can work with files using CFile . You need not worry if the file is located in hard disk or a flash drive.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
somebody would tell me why the following codes would failed at the calling:
lpDirectSound->CreateSoundBuffer(&BufferDesc,&pSoundBuffer,NULL);
CString strFile_in="sound.wav";<br />
LPVOID lpPtr1=NULL;<br />
LPVOID lpPtr2=NULL;<br />
HRESULT hr;<br />
DWORD dwLen1,dwLen2;<br />
LPVOID lp_mMemory=NULL;
LPVOID lpData=NULL;
LPWAVEFORMATEX lpWaveFormat=NULL;
DWORD dwSize=0;
CFile file;<br />
DWORD dwFileSize;
if(!file.Open(strFile_in,CFile::modeRead|CFile::shareDenyNone))<br />
{<br />
AfxMessageBox("Open the media file failed!");<br />
return ;<br />
}<br />
dwFileSize=file.Seek(0L,CFile::end);
file.Seek(0L,CFile::begin);
lp_mMemory=GlobalAlloc(GMEM_FIXED,dwFileSize);<br />
if(lp_mMemory==NULL)<br />
{<br />
AfxMessageBox("Allocate memory failed!");<br />
file.Close();<br />
return ;<br />
}<br />
if(file.ReadHuge(lp_mMemory,dwFileSize)!=dwFileSize)<br />
{<br />
AfxMessageBox("Read file error!");<br />
file.Close();<br />
GlobalFree(lp_mMemory);
return ;<br />
}<br />
file.Close();
<br />
LPDWORD lpdFile,lpdEnd;<br />
DWORD dwRiff,dwType,dwLen;<br />
lpdFile=(DWORD*)lp_mMemory;<br />
dwRiff=*lpdFile++;<br />
dwLen=*lpdFile++;<br />
dwType=*lpdFile++;<br />
if(dwRiff!=mmioFOURCC('R','I','F','F'))<br />
{<br />
AfxMessageBox("This is not a RIFF file!");<br />
GlobalFree(lp_mMemory);<br />
return ;<br />
}<br />
if(dwType!=mmioFOURCC('W','A','V','E'))<br />
{<br />
AfxMessageBox("This is not a WAVE file!");<br />
GlobalFree(lp_mMemory);<br />
return ;<br />
}<br />
<br />
lpdEnd=(DWORD*)((BYTE*)lp_mMemory+dwFileSize-4);<br />
BOOL bEnd=FALSE;<br />
while((lpdFile<lpdEnd)&&(!bEnd))<br />
{<br />
dwType=*lpdFile++;<br />
dwLen=*lpdFile++;<br />
switch(dwType)<br />
{<br />
case mmioFOURCC('f','m','t',' '):
if(!lpWaveFormat)<br />
{<br />
if(dwLen<sizeof(LPWAVEFORMATEX))<br />
{<br />
AfxMessageBox("There is some wrong in the file struct!");<br />
return ;<br />
}<br />
else<br />
lpWaveFormat=(LPWAVEFORMATEX)lpdFile;<br />
}<br />
break;<br />
case mmioFOURCC('d','a','t','a'):
if(!lpData||!dwSize)<br />
{<br />
lpData=(LPBYTE)lpdFile;<br />
dwSize=dwLen;<br />
if(lpWaveFormat)<br />
bEnd=TRUE;<br />
}<br />
break;<br />
}<br />
<br />
lpdFile=(DWORD*)((BYTE*)lpdFile+((dwLen+1)&~1));<br />
}<br />
<br />
DSBUFFERDESC BufferDesc;<br />
memset(&BufferDesc,0,sizeof(BufferDesc));<br />
BufferDesc.lpwfxFormat=(LPWAVEFORMATEX)lpWaveFormat;<br />
BufferDesc.dwSize=sizeof(DSBUFFERDESC);<br />
BufferDesc.dwBufferBytes=dwSize;<br />
BufferDesc.dwFlags=0;<br />
<br />
LPDIRECTSOUND lpDirectSound;<br />
hr=::DirectSoundCreate(0,&lpDirectSound,NULL);<br />
if(hr!=DS_OK)<br />
{<br />
AfxMessageBox("Create DirectSound failed!");<br />
GlobalFree(lp_mMemory);<br />
return ;<br />
}<br />
hr=lpDirectSound->SetCooperativeLevel(this->GetSafeHwnd(),DSSCL_NORMAL);<br />
if(hr!=DS_OK)<br />
{<br />
AfxMessageBox("SetCooperativeLevel failed!");<br />
}<br />
lpDirectSound->Initialize(NULL);<br />
LPDIRECTSOUNDBUFFER pSoundBuffer=NULL;<br />
hr=lpDirectSound->CreateSoundBuffer(&BufferDesc,&pSoundBuffer,NULL);<br />
if(hr==DS_OK)<br />
{<br />
hr=pSoundBuffer->Lock(0,dwSize,&lpPtr1,&dwLen1,&lpPtr2,&dwLen2,0);<br />
if(hr==DS_OK)<br />
{<br />
memcpy(lpPtr1,lpData,dwLen1);<br />
if(dwLen2>0)<br />
{<br />
BYTE* pData=(BYTE*)lpData+dwLen1;<br />
lpData=(void*)pData;<br />
memcpy(lpPtr2,lpData,dwLen2);<br />
}<br />
}<br />
pSoundBuffer->Unlock(lpPtr1,dwLen1,lpPtr2,dwLen2);<br />
DWORD dwFlags=0;<br />
pSoundBuffer->Play(0,0,dwFlags);<br />
}<br />
else<br />
{<br />
AfxMessageBox("Create buffer failed!");<br />
switch(hr)<br />
{<br />
case DSERR_ALLOCATED:<br />
AfxMessageBox("DSERR_ALLOCATED ");<br />
break;<br />
case DSERR_BADFORMAT:<br />
AfxMessageBox("DSERR_BADFORMAT ");<br />
break;<br />
case DSERR_INVALIDPARAM:<br />
AfxMessageBox("DSERR_INVALIDPARAM ");<br />
break;<br />
case DSERR_NOAGGREGATION:<br />
AfxMessageBox("DSERR_NOAGGREGATION ");<br />
break;<br />
case DSERR_OUTOFMEMORY :<br />
AfxMessageBox("DSERR_OUTOFMEMORY ");<br />
break;<br />
case DSERR_UNINITIALIZED:<br />
AfxMessageBox("DSERR_UNINITIALIZED");<br />
break;<br />
case DSERR_UNSUPPORTED :<br />
AfxMessageBox("DSERR_UNSUPPORTED ");<br />
break;<br />
case DSERR_INVALIDCALL:<br />
AfxMessageBox("DSERR_INVALIDCALL");<br />
break;<br />
}<br />
}<br />
GlobalFree(lp_mMemory);
Thanks
|
|
|
|
|
What error are you getting?
I'll look at your code if you edit your post and wrap the code in "pre" tags instead of "code"
tags.
The unindented, red text makes my eyes bleed
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I'm sorry.I will have a try to using 'pre' this time
CString strFile_in="sound.wav";
LPVOID lpPtr1=NULL;
LPVOID lpPtr2=NULL;
HRESULT hr;
DWORD dwLen1,dwLen2;
LPVOID lp_mMemory=NULL;
LPVOID lpData=NULL;
LPWAVEFORMATEX lpWaveFormat=NULL;
DWORD dwSize=0;
CFile file;
DWORD dwFileSize;
if(!file.Open(strFile_in,CFile::modeRead|CFile::shareDenyNone))
{
AfxMessageBox("Open the media file failed!");
return ;
}
dwFileSize=file.Seek(0L,CFile::end);
file.Seek(0L,CFile::begin);
lp_mMemory=GlobalAlloc(GMEM_FIXED,dwFileSize);
if(lp_mMemory==NULL)
{
AfxMessageBox("Allocate memory failed!");
file.Close();
return ;
}
if(file.ReadHuge(lp_mMemory,dwFileSize)!=dwFileSize)
{
AfxMessageBox("Read file error!");
file.Close();
GlobalFree(lp_mMemory);
return ;
}
file.Close();
LPDWORD lpdFile,lpdEnd;
DWORD dwRiff,dwType,dwLen;
lpdFile=(DWORD*)lp_mMemory;
dwRiff=*lpdFile++;
dwLen=*lpdFile++;
dwType=*lpdFile++;
if(dwRiff!=mmioFOURCC('R','I','F','F'))
{
AfxMessageBox("This is not a RIFF file!");
GlobalFree(lp_mMemory);
return ;
}
if(dwType!=mmioFOURCC('W','A','V','E'))
{
AfxMessageBox("This is not a WAVE file!");
GlobalFree(lp_mMemory);
return ;
}
lpdEnd=(DWORD*)((BYTE*)lp_mMemory+dwFileSize-4);
BOOL bEnd=FALSE;
while((lpdFile{
dwType=*lpdFile++;
dwLen=*lpdFile++;
switch(dwType)
{
case mmioFOURCC('f','m','t',' '):
if(!lpWaveFormat)
{
if(dwLen {
AfxMessageBox("There is some wrong in the file struct!");
return ;
}
else
lpWaveFormat=(LPWAVEFORMATEX)lpdFile;
}
break;
case mmioFOURCC('d','a','t','a'):
if(!lpData||!dwSize)
{
lpData=(LPBYTE)lpdFile;
dwSize=dwLen;
if(lpWaveFormat)
bEnd=TRUE;
}
break;
}
lpdFile=(DWORD*)((BYTE*)lpdFile+((dwLen+1)&~1));
}
DSBUFFERDESC BufferDesc;
memset(&BufferDesc,0,sizeof(BufferDesc));
BufferDesc.lpwfxFormat=(LPWAVEFORMATEX)lpWaveFormat;
BufferDesc.dwSize=sizeof(DSBUFFERDESC);
BufferDesc.dwBufferBytes=dwSize;
BufferDesc.dwFlags=0;
LPDIRECTSOUND lpDirectSound;
hr=::DirectSoundCreate(0,&lpDirectSound,NULL);
if(hr!=DS_OK)
{
AfxMessageBox("Create DirectSound failed!");
GlobalFree(lp_mMemory);
return ;
}
hr=lpDirectSound->SetCooperativeLevel(this->GetSafeHwnd(),DSSCL_NORMAL);
if(hr!=DS_OK)
{
AfxMessageBox("SetCooperativeLevel failed!");
}
lpDirectSound->Initialize(NULL);
LPDIRECTSOUNDBUFFER pSoundBuffer=NULL;
hr=lpDirectSound->CreateSoundBuffer(&BufferDesc,&pSoundBuffer,NULL);
if(hr==DS_OK)
{
hr=pSoundBuffer->Lock(0,dwSize,&lpPtr1,&dwLen1,&lpPtr2,&dwLen2,0);
if(hr==DS_OK)
{
memcpy(lpPtr1,lpData,dwLen1);
if(dwLen2>0)
{
BYTE* pData=(BYTE*)lpData+dwLen1;
lpData=(void*)pData;
memcpy(lpPtr2,lpData,dwLen2);
}
}
pSoundBuffer->Unlock(lpPtr1,dwLen1,lpPtr2,dwLen2);
DWORD dwFlags=0;
pSoundBuffer->Play(0,0,dwFlags);
}
else
{
AfxMessageBox("Create buffer failed!");
switch(hr)
{
case DSERR_ALLOCATED:
AfxMessageBox("DSERR_ALLOCATED ");
break;
case DSERR_BADFORMAT:
AfxMessageBox("DSERR_BADFORMAT ");
break;
case DSERR_INVALIDPARAM:
AfxMessageBox("DSERR_INVALIDPARAM ");
break;
case DSERR_NOAGGREGATION:
AfxMessageBox("DSERR_NOAGGREGATION ");
break;
case DSERR_OUTOFMEMORY :
AfxMessageBox("DSERR_OUTOFMEMORY ");
break;
case DSERR_UNINITIALIZED:
AfxMessageBox("DSERR_UNINITIALIZED");
break;
case DSERR_UNSUPPORTED :
AfxMessageBox("DSERR_UNSUPPORTED ");
break;
case DSERR_INVALIDCALL:
AfxMessageBox("DSERR_INVALIDCALL");
break;
}
}
GlobalFree(lp_mMemory);
|
|
|
|
|
Thanks
And what error are you getting?
Mark
Indentation is your friend!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
there,the calling function:
lpDirectSound->CreateSoundBuffer(&BufferDesc,&pSoundBuffer,NULL);
would return a value: DSERR_INVALIDCALL!
|
|
|
|
|
In BufferDesc, is BufferDesc.lpwfxFormat valid? What are the values in the WAVEFORMATEX struct
pointed to by BufferDesc.lpwfxFormat?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|