question in using TCHAR*
-
Hi, I'm a bit new to this TCHAR stuff, so I'm confused as to how to do what I need to do. I created a struct struct gaugeSound { int buffer; TCHAR* filename; // char* filename; bool loop; bool isLoaded; }; That I originally stored a filename in as a char*, but later changed to TCHAR* to try to deal with this issue. This has not worked. With the above struct, I do this: gaugeSound sound_EngOut = { 0, L"sound\\B206B-III\\Loop_EngOut.wav", true, false }; (here I added the 'L', but originally I just used a char*) Then I try to do this: LoadWaveFile(sound_EngOut.buffer, sound_EngOut.filename); sound_EngOut.isLoaded = true; however the LoadWaveFile() function was defined like this: extern "C" VOID LoadWaveFile( WORD BufferN, TCHAR* strFileName ) { // Create the sound buffer object from the wave file data if( FAILED( CreateStaticBuffer( BufferN, strFileName ) ) ) { return; } else // The sound buffer was successfully created { // Fill the buffer with wav data FillBuffer(BufferN); } } so originally I changed it to this: //extern "C" VOID LoadWaveFile( WORD , const char* ); but since that didn't work I am trying to go with the original again. Yet... there is a problem.... as in this function... HRESULT CreateStaticBuffer( WORD BufferN, TCHAR* strFileName ) { HRESULT hr; // Free any previous globals SAFE_DELETE( g_pWaveSoundRead [BufferN]); SAFE_RELEASE( g_pDSBuffer [BufferN]); // Create a new wave file class g_pWaveSoundRead[BufferN]= new CWaveSoundRead(); // Load the wave file if( FAILED( g_pWaveSoundRead[BufferN]->Open( strFileName ) ) ) the Open() call above requires (in WaveRead.cpp) a CHAR* !!!!!! So, it seems that I have no clue how to use this DirectSound code that has been programmed with TCHAR*, especially since when I use the 'L', the above function can then not be called. Help! What the heck am I supposed to begin doing?
-
Hi, I'm a bit new to this TCHAR stuff, so I'm confused as to how to do what I need to do. I created a struct struct gaugeSound { int buffer; TCHAR* filename; // char* filename; bool loop; bool isLoaded; }; That I originally stored a filename in as a char*, but later changed to TCHAR* to try to deal with this issue. This has not worked. With the above struct, I do this: gaugeSound sound_EngOut = { 0, L"sound\\B206B-III\\Loop_EngOut.wav", true, false }; (here I added the 'L', but originally I just used a char*) Then I try to do this: LoadWaveFile(sound_EngOut.buffer, sound_EngOut.filename); sound_EngOut.isLoaded = true; however the LoadWaveFile() function was defined like this: extern "C" VOID LoadWaveFile( WORD BufferN, TCHAR* strFileName ) { // Create the sound buffer object from the wave file data if( FAILED( CreateStaticBuffer( BufferN, strFileName ) ) ) { return; } else // The sound buffer was successfully created { // Fill the buffer with wav data FillBuffer(BufferN); } } so originally I changed it to this: //extern "C" VOID LoadWaveFile( WORD , const char* ); but since that didn't work I am trying to go with the original again. Yet... there is a problem.... as in this function... HRESULT CreateStaticBuffer( WORD BufferN, TCHAR* strFileName ) { HRESULT hr; // Free any previous globals SAFE_DELETE( g_pWaveSoundRead [BufferN]); SAFE_RELEASE( g_pDSBuffer [BufferN]); // Create a new wave file class g_pWaveSoundRead[BufferN]= new CWaveSoundRead(); // Load the wave file if( FAILED( g_pWaveSoundRead[BufferN]->Open( strFileName ) ) ) the Open() call above requires (in WaveRead.cpp) a CHAR* !!!!!! So, it seems that I have no clue how to use this DirectSound code that has been programmed with TCHAR*, especially since when I use the 'L', the above function can then not be called. Help! What the heck am I supposed to begin doing?
It's up to you, as always to use the proper data types in C++. The type TCHAR's actual type will vary depending on if you've defined _UNICODE, _MBCS, or neither. If you choose to use the generic text mappings, and you use an API that requires a different type char, then you'll need to convert strings to the appropriate type before passing them, or use the appropriate type string literals. Here's a link to the docs: Using Generic-Text Mappings[^]
"Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")
-
It's up to you, as always to use the proper data types in C++. The type TCHAR's actual type will vary depending on if you've defined _UNICODE, _MBCS, or neither. If you choose to use the generic text mappings, and you use an API that requires a different type char, then you'll need to convert strings to the appropriate type before passing them, or use the appropriate type string literals. Here's a link to the docs: Using Generic-Text Mappings[^]
"Great job, team. Head back to base for debriefing and cocktails." (Spottswoode "Team America")