none
Error C2664: cannot convert from const char [38] to LPCWSTR

    Question

  • Hi everyone,

    obviously, I'm new here and need some help. But anyway, I'm writing a program that locates an intercom sending UDP signals over a network, connects to it and sends and recieves audio. I'll have you know that I havn't had a lot of experience with VC++, mostly C, Javascript and VB in the past (this project just kinda got thrown at me).  I keep getting error C2664: 'LoadLibraryW': cannot convert parameter 1 from 'const char [38]' to 'LPCWSTR'. And a second error that is the same except a char [15] on the line below it. I have tried several things but cannot get rid of it.

     

    Here is a snippet from CPanelControlpp.cpp:

     

    BOOL CPanelControlPP:SurprisenInitDialog ()

    {

    CDialog:SurprisenInitDialog();

     

    m_hLib = LoadLibrary("..\\..\\DAPassThru\\Debug\\DAPassThru.dll");

    if( m_hLib || (m_hLib = LoadLibrary("DAPassThru.dll")) )

    {

    if( !LoadProcs() )

    WriteDebugString("Could NOT get all proc addresses");

     

    if( m_DllVersion )

    m_DllVersion( &m_Major, &m_Minor, &m_Release );

     

    if( m_Open )

    m_Open( &m_hAC, &m_uFlags, &CallBack, NULL );

     

    if( m_SetDebug )

    m_SetDebug( TRUE );

    }

    else

    // outputDebug("Failed to open DAPassThru Dll");

     

    m_sockaddr_in.sin_port = htons(3000);

    m_Start( m_hAC, &m_sockaddr_in,

     

    THREAD_BASE_PRIORITY_MAX+12, "", "", NULL, NULL);

     

    ListView_SetExtendedListViewStyle(m_listIcoms.m_hWnd,

    LVS_EX_FULLROWSELECT |

    // LVS_EX_CHECKBOXES |

    LVS_EX_SUBITEMIMAGES |

    LVS_EX_GRIDLINES |

    LVS_EX_SUBITEMIMAGES );

    // LVS_EX_FLATSB |

    // LVS_EX_HEADERDRAGDROP );

     

    // Columns for list box

    m_listIcoms.InsertColumn(COL_ICON, (LPCTSTR), "",LVCFMT_LEFT,20,-1)

    m_listIcoms.InsertColumn(COL_LOCATION,(LPCTSTR), "Location",LVCFMT_LEFT,165,-1)

    m_listIcoms.InsertColumn(COL_STATUS,(LPCTSTR), "Status",LVCFMT_LEFT,101,-1)

    m_listIcoms.InsertColumn(COL_DOOR, (LPCTSTR), "Door/Gate",LVCFMT_LEFT,62,-1)

    m_listIcoms.InsertColumn(COL_ADDRESS,(LPCTSTR), "IP Address",LVCFMT_LEFT,107,-1)

    m_imageList.Create(61, 16, ILC_COLOR16, 2, 2);

    }

     

    Note: m_hLib is defined in CPanelControl.h in this snippet:

     

    protected:

    HMODULE         m_hLib;

    struct sockaddr_in m_sockaddr_in;

    int m_Major, m_Minor, m_Release;

    Open                 m_Open;

    Close                m_Close;

    Start                 m_Start;

    Stop                 m_Stop;

    DllVersion         m_DllVersion;

    SetDebug         m_SetDebug;

    Disconnect       m_Disconnect;

    CreateGroup     m_CreateGroup;

    DeleteGroup     m_DeleteGroup;

    SelectIntercom m_SelectIntercom;

    StartAudio       m_StartAudio;

    SendAudio      m_SendAudio;

    EndAudio        m_EndAudio;

    GetGPIOValues m_GetGPIOValues;

    SetGPIOValue   m_SetGPIOValue;

    iComCount        m_iComCount;

    FirstIcom           m_FirstIcom;

    NextIcom          m_NextIcom;

    GetIcom           m_GetIcom;

    OpenDoor         m_OpenDoor;

    SetVolume       m_SetVolume;

    ForwardIcom    m_ForwardIcom;

    RetrieveIcom    m_RetrieveIcom;

    ListenIcom      m_ListenIcom;

    DeleteServerCQ m_DeleteServerCQ;

    TransferAudio     m_TransferAudio;

     

     

    Not sure what I'm missing. Any help would be greatly appreciated. Thanks guys.

     

    Wednesday, June 06, 2007 5:28 PM

Answers

All replies

  • Read through http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=849851&SiteID=1, and tell me if it's still unclear Smile
    Wednesday, June 06, 2007 6:30 PM
  • Excellent. That definatley fixed it. Thanks for the reply.
    Wednesday, June 06, 2007 7:06 PM
  •  rbickert wrote:
    Excellent. That definatley fixed it. Thanks for the reply.

    You're welcome Smile

    Wednesday, June 06, 2007 7:17 PM
  • I am curious if you've had success with your implemention of the DAPassthru.dll.  I can be reached at billy_mathis@yahoo.com

    Tuesday, September 11, 2007 12:19 AM
  • @einaros
    you got my problem solved too. thanks :)
    • Edited by Vibhanshu Wednesday, August 27, 2008 11:40 AM spelling mistake
    Wednesday, August 27, 2008 11:40 AM
  • Thanks Einaros, it fixed my problem )
    Monday, October 26, 2009 9:42 AM
  • Thank you very much. I was always struggling with deliberately casting the strings in many function arguments. Sometimes even I used to change the function names to the unicode names as defined in MSDN (eg. CreateFileA instead of just Createfile). This explanation of yours gave me a lot of relief.

     

    Thanks again,

    Mohan

    Thursday, December 29, 2011 4:36 PM
  • What is the answer? The resource cannot be found now. Please.
    Wednesday, August 29, 2012 8:26 PM
  • What is the answer? The resource cannot be found now. Please.

    Server Error in '/' Application.

    The resource cannot be found.

    Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

    Requested URL: /error/error404.aspx

    I also want the answer!

    Friday, November 02, 2012 3:35 AM

  • I also want the answer!

    Most likely your code is assuming that the Character Set being used is MBCS (Multi-Byte Character Set). By default VS 2010 and VS 2012 uses Unicode.

    For a quick fix, right click on the project name, Properties, Configuration Properties, General and change the Character Set from "Use Unicode Character Set" to "Use Multi-Byte Character Set".

    Friday, November 02, 2012 3:57 AM