Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. question in using TCHAR*

question in using TCHAR*

Scheduled Pinned Locked Moved Managed C++/CLI
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Stick
    wrote on last edited by
    #1

    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?

    M 1 Reply Last reply
    0
    • S Stick

      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?

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      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")

      S 1 Reply Last reply
      0
      • M Mark Salsbery

        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")

        S Offline
        S Offline
        Stick
        wrote on last edited by
        #3

        Thanks for the links. Turns out the problem was that I had UNICODE defined and didnt' know it.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups