converting char[260] to char[]
ok, I''m just about finished with my DirectAudio class except for one small thing. I can''t convert
file[]
to
WCHAR wstrFileName[260]
everything I can think of compiles fine, but doesn''t work. The code by itself,
WCHAR wstrFileName[MAX_PATH] = L"wavefile.wav";
works fine. any ideas how to make this work?
thanks,
Joe
JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
What are you trying to do exactly? Convert from char[260] to char[] like your subject line says or from WCHAR[] to char[]? Post some code if you''re not sure what you need...
ok, I''ll post my LoadFile function. It''s basically ripped strait from the DirectX8 help file.
thanks,
Joe
JoeMont001@aol.com www.polarisoft.n3.net
int cDX8Audio::LoadFile(const char path[], const char file[]){ // Find the Windows media directory. CHAR strPath[MAX_PATH]; GetWindowsDirectory( strPath, MAX_PATH ); strcat( strPath, path ); WCHAR wstrSearchPath[MAX_PATH]; // Convert to Unicode. MultiByteToWideChar( CP_ACP, 0, strPath, -1, wstrSearchPath, MAX_PATH ); // Set the search directory. g_pLoader->SetSearchDirectory( GUID_DirectMusicAllTypes, // Types of files sought. wstrSearchPath, // Where to look. FALSE // Don''t clear object data. );//***************HERE*************************//how can I make wstrFileName equal to file[]?//this is the code in the documentation WCHAR wstrFileName[MAX_PATH] = L"wavefile.wav"; if (FAILED(g_pLoader->LoadObjectFromFile( CLSID_DirectMusicSegment, // Class identifier. IID_IDirectMusicSegment8, // ID of desired interface. wstrFileName, // Filename. (LPVOID*) &g_pSegment // Pointer that receives interface. ))) { MessageBox( NULL, "Media not found, sample will now quit.", "DMusic Tutorial", MB_OK ); return 0; } return 1;}
thanks,
Joe
JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
There are various string procedures to go between char, wide char and multi-byte strings. If you are using VC++, in your source type strcpy, put the cursor over "strcpy" and hit F1 (this is all from recent memory, mind you). You should get the description for strcpy and the wide/multi variants. One will go between char and wide char. If your source string is a legitimate string (null terminated), the right variant should work. It''s always a good idea to do a strlen on the source or use "strncpy" variant to make sure you don''t overflow your destination array and piss on something else.
Post your progress.
TheViper
Post your progress.
TheViper
thanks for an answer. I did get it fixed though. I just took out the conversion. I changed const char file to WCHAR file and took wstrFileName completely.
JoeMont001@aol.com www.polarisoft.n3.net
JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Does this mean that file[] was really a WCHAR in the calling procedure? If so, these are the things which must be included in your description. Your code segment only shows the definition of cDX8Audio::LoadFile and not the caller. This could be misleading and cause investigation down a path which would never solve your problem. Complete information is important.
TheViper
TheViper
well, I changed it after I figured out it would be alot easier with file being a WCHAR.
JoeMont001@aol.com www.polarisoft.n3.net
JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement