Please HElp With LPCWSTR

Hi..

Belive me when i say that i looked all over the internet for this and no clearifing result..

i try to use mciSendString function to play a file.. probem is that it has parameter LPCWSTR.. :(( .. i use WIN32 console application.. so i must read the path from the console..



CODE:

int _tmain(int argc, _TCHAR* argv[])
{
int error=0;
wstring path;

wchar_t* str2=L"play MediaFile";

error=mciSendString(path.c_str(),NULL, 0, NULL);

mciSendString(str2,NULL, 0, NULL);

}

i want my wstring to be read from teh console.. something like cin>>path; ...

anyway i cant find anyway to read the string from console and then pass it as LCPWSTR ....

can anyone HELP please



Answer this question

Please HElp With LPCWSTR

  • BryanF

    Yeah, I reminded myself with the URL, but it was well hidden, not a good page design. I knew the sample usually does not include it, but it's usually made clear at the bottom, more so than it was on this page.

    Yeah, LPSTR is char * ( ANSI string ), LPWSTR is short * ( from memory ), which is a unicode string, and LPTSTR is a macro that is either, depending on your build settings. So LPTSTR is the one to watch, if you use it and don't match it properly, your code won't build when the settings change.



  • BiohazrD

    You rock Dude!!

    it seams that i have some prbs .. can you show a qucik example Please.. and

    can you also include the librarie you include (#include TraLaLA) please

    Thanks MAn!!


  • Arstan

    A2W will do this conversion for you. _bstr_t will also do it.

    http://msdn.microsoft.com/library/en-us/wceatl/htm/atlapi2_42.asp frame=true



  • Luke Zhang - MSFT

     cgraus wrote:

    The include is atlconv.h

    void func( LPSTR lpsz )
    {
    USES_CONVERSION;
    ...
    LPWSTR x = A2W(lpsz)
    // Do something with x
    ...
    }

    ( from the page I referred you to )



    well i saw that page before you poested.. on MSDN.. but didnt know what to include...

    btw LPSTR is a pointer to a normal char array

    can i read LPSTR from console .. SORRY if asking dumm questions.. i`m new


  • Aaron Stern - MSFT

    The include is atlconv.h

    void func( LPSTR lpsz )
    {
    USES_CONVERSION;
    ...
    LPWSTR x = A2W(lpsz)
    // Do something with x
    ...
    }

    ( from the page I referred you to )



  • Jongo

    You need to link with the ATL library. Project properties, Configuration properties, General, Use of ATL = Static link to ATL


  • Kirk Hilse - Microsoft

    int _tmain(int argc, _TCHAR* argv[])
    {
    USES_CONVERSION;
    int error=0;
    char A[100];cin.get(A, 100);
    LPWSTR x = A2W((LPCSTR)A);

    wchar_t* str2=L"play MediaFile"; // Play MEdiaFile
    error=mciSendString(x, NULL, 0, NULL);
    }

    I get some errors:

    Error 1 error LNK2001: unresolved external symbol "unsigned int (__stdcall* ATL::g_pfnGetThreadACP)(void)" ( g_pfnGetThreadACP@ATL@@3P6GIXZA) playMP3.obj

    Error 2 fatal error LNK1120: 1 unresolved externals C:\Documents and Settings\Cisu\Desktop\c#p\playMP3\Debug\playMP3.exe 1


    Sorry again.. if i`m beeing a DUMM



  • RensV

    well.. this works..

    int _tmain(int argc, _TCHAR* argv[])
    {
    int error=0;
    wchar_t* str1=L"open d:/a.mp3 type mpegvideo alias MediaFile";
    wchar_t* str2=L"play MediaFile";
    error=mciSendString(str1, NULL, 0, NULL);
    mciSendString(str2,NULL, 0, NULL);
    }
    actualy the mciSendString protototype is like this:

    mciSendString(LPCWSTR, LPWSTR, int, int /* Pointer */);

    do ypu have an yahoo ID maybe we could talk real time and solve the problem FASTER.. mine is : angel_wiza


  • kamo

    http://msdn2.microsoft.com/zh-CN/library/87zae4a3(VS.80).aspx doesn't seem to indicate that any lib is needed.

    Perhaps it's something that mciSendString requires



  • Please HElp With LPCWSTR