int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
PlaySoundA("a.wav", NULL, SND_FILENAME | SND_ASYNC);
return 0;
}
:[al@myhost kalba]$ g++ ./playsound.cpp
./playsound.cpp:1: error: expected initializer before 'WinMain'
PlaySoundA("a.wav", NULL, SND_FILENAME | SND_ASYNC);
or this:
char b[999999];
WAVEFORMATEX wfex;HWAVEOUT hwo;
HMMIO m_hmmio; // MM I/O handle for the WAVE
MMCKINFO m_ck; // Multimedia RIFF chunk
MMCKINFO m_ckRiff; // Use in opening a WAVE file
DWORD m_dwSize=0; // The size of the wave file
WAVEHDR whdr;
HANDLE hDoneEvent = CreateEventA(NULL, FALSE, FALSE, "DONE_EVENT");
wfex.wFormatTag = WAVE_FORMAT_PCM;
wfex.nChannels = 1;
wfex.nSamplesPerSec = 22050;
wfex.nAvgBytesPerSec = 44100;
wfex.nBlockAlign = 2;
wfex.wBitsPerSample = 16;
waveOutOpen(&hwo, WAVE_MAPPER, &wfex,(DWORD) hDoneEvent, 0,CALLBACK_EVENT);
m_hmmio = mmioOpen("a.wav", NULL, MMIO_ALLOCBUF | MMIO_READ );
MMCKINFO ckIn; // chunk info. for general use.
mmioDescend( m_hmmio, &m_ckRiff, NULL, 0 );
mmioDescend( m_hmmio, &ckIn, &m_ckRiff,MMIO_FINDCHUNK );
mmioSeek( m_hmmio, m_ckRiff.dwDataOffset + sizeof(FOURCC),SEEK_SET );
m_ck.ckid = mmioFOURCC('d', 'a', 't', 'a');
mmioDescend( m_hmmio, &m_ck, &m_ckRiff,MMIO_FINDCHUNK );// )
m_dwSize =m_ck.cksize;
MMIOINFO mmioinfoIn; // current status of m_hmmio
mmioGetInfo( m_hmmio, &mmioinfoIn, 0 );
for(DWORD cT=0;cT<m_dwSize;cT++) {
if(mmioinfoIn.pchNext==mmioinfoIn.pchEndRead) {
mmioAdvance( m_hmmio, &mmioinfoIn, MMIO_READ );
}
*((BYTE*)b+cT)=*((BYTE*)mmioinfoIn.pchNext);
mmioinfoIn.pchNext++;
}
mmioClose(m_hmmio,0);
ZeroMemory(&whdr, sizeof(WAVEHDR));
whdr.lpData=b;
whdr.dwBufferLength =m_dwSize;
waveOutPrepareHeader(hwo, &whdr, sizeof(WAVEHDR));
waveOutWrite(hwo, &whdr, sizeof(WAVEHDR));
while (!(whdr.dwFlags & WHDR_DONE)) {
WaitForSingleObject(hDoneEvent, INFINITE);
}
waveOutUnprepareHeader(hwo, &whdr, sizeof(WAVEHDR));
waveOutClose(hwo);
But I use Quincy (http://codecutter.net/tools/quincy/)with Wine and creating that .exe files.
Quincy not create 'makefile' (I not understand why me need 'makefile' edit and from were I can get it?) files, it create 'filename.o' files only.
And I understoond, then read Wine text, that with Wine (http://www.winehq.com/) possible convert Windows code to Linux, but do not known how.
How convert Windows code to Linux with Wine?
Ise's advice is a good way to get started if you're not already familiar with the code: comment out the spots where Windows-specific headers are included then fix what breaks.
]]>So there is no exact replacement for this header-file. And I don't know which functions windows.h provides. I don't use windows (neither in coding nor in daily use).
'string' exists on both, it's a standard c++ header.
How you manage makefiles and so on, look at the website of automake and autoconf: http://www.gnu.org/software/autoconf/ http://www.gnu.org/software/automake/
]]>is it plain c++ code or are there any MFC classes included or any other windows libraries?? If not, just compile it under Linux and look for errors to fix.
Another tip: Look at right typo of the includes. For windows lower cases are the same as upper cases.
Write your own makefile to manage the compilation, or use autoconf/automake to handle it.
Have fun....
Daniel
]]>