mfc >> Forced to build UNICODE binary?

by KidLogik » Thu, 04 Dec 2003 09:51:07 GMT

Hello!

I am using the DirectShow api. I am curious as to if I must build
this application to support unicode. There is a method that I must
call ->

IGraphBuilder::RenderFile(LPCWSTR,LPCWSTR);

which takes 2 unicode strings etc.

My question is, since this method does not take any TCHARs, am I
forced to #define __UNICODE? I seem to be able to build the
application without unicode by using the L() marco ->

player.LoadFile(L"C:\\somefile.avi");

But this only works when using a literal. I would like to just pass a
CString instead. This leads me to believe that I do not need to build
a unicode application just to support that one method. Am I wrong
here? I am very confused.


mfc >> Forced to build UNICODE binary?

by Andrew Fedoniouk » Thu, 04 Dec 2003 10:22:10 GMT


Hi,

Don't need to declare UNICODE in this case, as you can use:

void some_function(LPCTSTR lpsz1, LPCTSTR lpsz2 )
{
USES_CONVERSION;
IGraphBuilder::RenderFile(T2W(lpsz1),T2W(lpsz2));
}

See MSDN : "String Conversion Macros"

Andrew Fedoniouk.
http://TerraInformatica.com











mfc >> Forced to build UNICODE binary?

by CheckAbdoul » Thu, 04 Dec 2003 10:26:25 GMT

You can convert your ansi string to a unicode string using the A2W macro
and pass it to the function. Something like

SomeFunc()
{
USES_CONVERSION; // do a #include "afxpriv2.h"

CString sFile( TEXT("SomeFile.txt") );
CString sPlayList( TEXT("SomeList.xyz") );

LPCWSTR sFile_U= A2W( sFile.GetBuffer(MAX_PATH+1) );
LPCWSTR sPlayList_U= A2W( sPlayList.GetBuffer(MAX_PATH+1) );

sFile.ReleaseBuffer(0);
sPlayList.ReleaseBuffer(0);

IGraphBuilder::RenderFile(sFile,sPlayList);

}

--
Cheers
Check Abdoul [VC++ MVP]
-----------------------------------







Forced to build UNICODE binary?

by KidLogik » Thu, 04 Dec 2003 10:51:52 GMT

Awesome! Thanks Andrew :)




Forced to build UNICODE binary?

by KidLogik » Thu, 04 Dec 2003 10:55:44 GMT

Thanks CheckAbdoul. Everything is working great now :)


On Wed, 3 Dec 2003 21:26:25 -0500, "CheckAbdoul" <checkabdoul at mvps





Similar Threads

1. Post-Build Step Always Forces Project Build

2. conflict between Unicode and non-Unicode builds?

We just had a really strange error that took a while to diagnose.

An ISAPI extension running under IIS tried to CoCreateInstance a
particular COM component and was getting a failed HRESULT for "Access
is denied".  While this was not happening under Windows 2000, IIS 6.0
on Windows 2003 wouldn't work all the time.  On one server we could
get it to work by switching IIS 6.0 to use 5.0 Isolation mode and
setting the ISAPI extension to Low isolation, but on another server
this didn't seem to have an effect.

The break came for us when I tried running Sysinternal's Filemon
utility and noticed an "Access is denied" on the MFC71.DLL
(non-Unicode) immediately after accessing our COM DLL.  The ISAPI DLL
was linked against MFC71U.DLL, so I suspected this might be the
problem.  (Don't ask why server-side components are linked with MFC,
neither you nor I will like the answer.)  Swapping this COM DLL out
with a Unicode build of the same component, making it link against
MFC71U.DLL instead, appeared to fix the problem.

I am not enough of a COM or MFC guru to understand this conflict.  Is
this a known issue?  Google has been uninformative all day on this
subject, though perhaps I'm not using the right search terms.  My
guess is that because this was an in-process COM server, it loaded the
MFC71.DLL into the same process space as MFC71U.DLL, causing some kind
of conflict in the internals of MFC, and that we might also address
this by using this component out-of-process.  (Or by removing MFC and
going full-Unicode on all components.  Politics and logic don't always
see eye-to-eye.)

Any insight into this behavior would be welcome.

3. Forcing String Literal as Wide Character Unicode

4. Forced to use "Rebuild" (Build doesn't work)

I just put C# express editiion on my son's computer so he can learn how to 
code, and we've run into a weird problem.

Whenever he makes a change to his code and hits F6 (build) the IDE reports 
that the build succeded.  However, when he runs the program (Start without 
debugging), the new build IS NOT being run.  He has to actually choose 
Build|Rebuild Solution from the menu for the new build to run.  Just 
building with F6, or running with F5 or Ctrl F5 won't do it.

This is very annoying.  Does anyone know how to fix this problem?



Thanks,

Mac 


5. How do I properly configure a MAPI C++ Project for a Unicode build:

6. Building binary with a version number and meta data

On Feb 6, 12:45爌m, puzzlecracker < XXXX@XXXXX.COM > wrote:
> I'm building a c# app, and want to include a standard version and
> other relavant info, like a build data. Hence a user can do ./app.exe -
> r 爋r click on help via gui and will have the info available.
>
> What is the standard pattern for that? I imagine that some of that
> should be read from the file.

Have a look at AssemblyVersionAttribute, Application.ProductName, and
Application.ProductVersion in MSDN.

7. Building binary with a version number and meta data - CSharp/C#

8. Same code build twice => diff binary

Hi all,

I am using Win2k, VS. NET 7.1 (MS development Environment 2003 7.1.3088)
and I noticed that by building the exact same code twice the generated
binaries are different (not much, but they are). To be sure I tried a
simple application like void main(){} and 2 times rebuilding the project
gets 2 different binaries.

Has anybody any clue why this happens?
Could I somehow change a setting or something to remove those diff (I
mean from the same code to get identical binaries)?

Thanks in advance,
Viv