Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

RenderFile() , wide char paramater

Posted on 2004-08-25
15
Medium Priority
?
371 Views
Last Modified: 2012-06-27
MSDN shows the following example for rendering a file in a filter graph:

hr = pGraph->RenderFile(L"C:\\Media\\Example.avi", 0);

my existing code manages movie filenames as LPCTSTR values. I have in place a placeholder method:

DWORD CImageView::LoadMovie(LPCTSTR a_lpszMovieName)

how can I cast my LPCTSTR movie name into something that RenderFile can use? Is that 'L' a macro of some type like _T ?

thanks
-Paul
0
Comment
Question by:PMH4514
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
15 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 11896384
You'll need to convert it to UNICODE, either by using

DWORD CImageView::LoadMovie(LPCTSTR a_lpszMovieName) {

    USES_CONVERSION:

    wchar_t* pwszMovieName = A2C ( a_lpszMovieName);
}

or using 'mbstowcs()' directly, e.g.


int nLen = strlen ( a_lpszMovieName);
wchar_t* pwsz = new wchar_t [ nLen];

mbstowcs ( pwsz, (LPTSTR) str, nLen);

hr = pGraph->RenderFile(pwsz, 0);

delete [] pwsz;

0
 

Author Comment

by:PMH4514
ID: 11896505
I'm wondering if there is anything about C++ that you *don't* know jkr????

thank you! You have been an invaluable resource to me :)

-Paul
0
 
LVL 86

Expert Comment

by:jkr
ID: 11896536
>> I'm wondering if there is anything about C++ that you *don't* know

Yes, actually a couple of things :o)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:PMH4514
ID: 11896563
>>Yes, actually a couple of things :o)
I'll do my best to stump ya :)

hmm.. ok, that works now! but.. damn, I'm missing something or this is too good to be true.. (and this should probably be a new thread) - but Render(..) and then IMediaControl -> Run() pops my AVI open in a window..

I need it to render in a designated space within my prop-sheet.
0
 

Author Comment

by:PMH4514
ID: 11896574
oh and your code should be:
    mbstowcs ( pwsz, (LPTSTR) a_lpszMovieName, nLen);
not       
    mbstowcs ( pwsz, (LPTSTR) str, nLen);

0
 
LVL 86

Expert Comment

by:jkr
ID: 11896624
Yup, you are right :o)
0
 

Author Comment

by:PMH4514
ID: 11896646
hmm.. actually I'm still having a problem with that.
a_lpszMovieName = "e:\images\p1\data\20040825\movies\Cap1_Movie001.AVI"

when I run your code:
      int nLen = strlen ( a_lpszMovieName);
      wchar_t* pwsz = new wchar_t [ nLen];
      mbstowcs ( pwsz, (LPTSTR) a_lpszMovieName, nLen);

and put pwsz in the variable watcher, I see a base address and it expands to "101"

when I then do: g_pGraph->RenderFile(pwsz, 0);  I get an error that it can't find the file.

I first tried your :

   USES_CONVERSION:
    wchar_t* pwszMovieName = A2C ( a_lpszMovieName);

but the compiler didn't know what A2C was..




0
 
LVL 86

Expert Comment

by:jkr
ID: 11896757
Are you using the above *literally*, i.e. *without* double backslashes?
0
 

Author Comment

by:PMH4514
ID: 11896809
yeah, the a_lpszMovieName  is passed in with single backslashes..
0
 
LVL 86

Expert Comment

by:jkr
ID: 11896880
OK, if it is passed in, that should be OK. I think I spotted the problem, it should be

int nLen = strlen ( a_lpszMovieName) + 1;
0
 

Author Comment

by:PMH4514
ID: 11896972
cool.. that did it.

what is A2C and why didn't my compiler know what it is?
0
 
LVL 86

Expert Comment

by:jkr
ID: 11897126
A2C is a macro used by ATL and lives in "atlconv.h".
0
 

Author Comment

by:PMH4514
ID: 11897223
thanks-
0
 
LVL 86

Expert Comment

by:jkr
ID: 11897325
Ooops, that thing should have been A2W in the first place :-(
0
 

Author Comment

by:PMH4514
ID: 11898107
I forgive you :)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question