• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 374
  • Last Modified:

RenderFile() , wide char paramater

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
PMH4514
Asked:
PMH4514
  • 8
  • 7
1 Solution
 
jkrCommented:
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
 
PMH4514Author Commented:
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
 
jkrCommented:
>> I'm wondering if there is anything about C++ that you *don't* know

Yes, actually a couple of things :o)
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
PMH4514Author Commented:
>>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
 
PMH4514Author Commented:
oh and your code should be:
    mbstowcs ( pwsz, (LPTSTR) a_lpszMovieName, nLen);
not       
    mbstowcs ( pwsz, (LPTSTR) str, nLen);

0
 
jkrCommented:
Yup, you are right :o)
0
 
PMH4514Author Commented:
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
 
jkrCommented:
Are you using the above *literally*, i.e. *without* double backslashes?
0
 
PMH4514Author Commented:
yeah, the a_lpszMovieName  is passed in with single backslashes..
0
 
jkrCommented:
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
 
PMH4514Author Commented:
cool.. that did it.

what is A2C and why didn't my compiler know what it is?
0
 
jkrCommented:
A2C is a macro used by ATL and lives in "atlconv.h".
0
 
PMH4514Author Commented:
thanks-
0
 
jkrCommented:
Ooops, that thing should have been A2W in the first place :-(
0
 
PMH4514Author Commented:
I forgive you :)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now