visual c++ - error C2664: 'int LSexecuteScriptLng(void *,const char *) -


// salam001dlg.cpp : implementation file //  #include "stdafx.h" #include "salam001.h" #include "salam001dlg.h" #include "dlgproxy.h" #include "afxdialogex.h"  #ifdef _debug #define new debug_new #endif   // csalam001dlg dialog   implement_dynamic(csalam001dlg, cdialogex);  csalam001dlg::csalam001dlg(cwnd* pparent /*=null*/)     : cdialogex(csalam001dlg::idd, pparent) {     m_hicon = afxgetapp()->loadicon(idr_mainframe);     m_pautoproxy = null; }  csalam001dlg::~csalam001dlg() {     // if there automation proxy dialog, set     //  pointer dialog null, knows     //  dialog has been deleted.     if (m_pautoproxy != null)         m_pautoproxy->m_pdialog = null; }  void csalam001dlg::dodataexchange(cdataexchange* pdx) {     cdialogex::dodataexchange(pdx); }  begin_message_map(csalam001dlg, cdialogex)     on_wm_close()     on_wm_paint()     on_wm_querydragicon() end_message_map()   // csalam001dlg message handlers  bool csalam001dlg::oninitdialog() {     cdialogex::oninitdialog();      // set icon dialog.  framework automatically     //  when application's main window not dialog     seticon(m_hicon, true);         // set big icon     seticon(m_hicon, false);        // set small icon      // todo: add initialization here      return true;  // return true  unless set focus control }  // if add minimize button dialog, need code below //  draw icon.  mfc applications using document/view model, //  automatically done framework.  void csalam001dlg::onpaint() {     if (isiconic())     {         cpaintdc dc(this); // device context painting          sendmessage(wm_iconerasebkgnd, reinterpret_cast<wparam>(dc.getsafehdc()), 0);          // center icon in client rectangle         int cxicon = getsystemmetrics(sm_cxicon);         int cyicon = getsystemmetrics(sm_cyicon);         crect rect;         getclientrect(&rect);         int x = (rect.width() - cxicon + 1) / 2;         int y = (rect.height() - cyicon + 1) / 2;          // draw icon         dc.drawicon(x, y, m_hicon);     }     else     {         cdialogex::onpaint();     } }  // system calls function obtain cursor display while user drags //  minimized window. hcursor csalam001dlg::onquerydragicon() {     return static_cast<hcursor>(m_hicon); }  // automation servers should not exit when user closes ui //  if controller still holds on 1 of objects.  these //  message handlers make sure if proxy still in use, //  ui hidden dialog remains around if //  dismissed.  void csalam001dlg::onclose() {     if (canexit())         cdialogex::onclose(); }  void csalam001dlg::onok() {//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////      int nerror, npointersnow;     double dstatus, dn_mu, dsol_inv, dsol_rot;     cstring csscript, cs;      // user's staffing requirements our dialog box     //updatedata();      // load staffing requirements lingo transfer array.     // lingo uses double precision values.     dn_mu = 5.0;     //n_mu[0] = (double)n_mu;       // create lingo environment object     plsenvlingo plingo;     plingo = lscreateenvlng();     if (!plingo)     {         afxmessagebox(_t("unable create lingo environment"));         return;     }      // open lingo's log file       nerror = lsopenlogfilelng(plingo, "c:\\lingo8\\lingo.log");     if (nerror) goto errorexit;      // pass memory transfer pointers lingo     // @pointer(1)     nerror = lssetpointerlng(plingo, &dn_mu, &npointersnow);     if (nerror) goto errorexit;     // @pointer(2)     nerror = lssetpointerlng(plingo, &dsol_inv, &npointersnow);     if (nerror) goto errorexit;     // @pointer(3) /*  nerror = lssetpointerlng(plingo, &dsol_rot, &npointersnow);     if (nerror) goto errorexit; */     // @pointer(3)     nerror = lssetpointerlng(plingo, &dstatus, &npointersnow);     if (nerror) goto errorexit;      // here script want lingo run     csscript = l"set echoin 1\n";     csscript = csscript + l"take \\salam002\\lingo1-3.lng\n"    ;     csscript = csscript + l"go\n";     csscript = csscript + l"quit\n";      // run script     dstatus = -1.e0;     nerror = lsexecutescriptlng(plingo, ( lpctstr ) csscript);      // close log file     lscloselogfilelng(plingo);      // problems?     if (nerror || dstatus)     {          // had problem            afxmessagebox( _t("unable solve!"));      }     else {          // went ok ... load results dialog box     //  m_csstartmon.format("%d", (int)dstart[0]);           updatedata(false);      }      goto exit;  errorexit:     cs.format(_t("lingo errorcode: %d"), nerror);     afxmessagebox(cs);     return;  exit:     lsdeleteenvlng(plingo);  /////////////////////////////////////////////////////////////////////////////////////////////////////////  }  void csalam001dlg::oncancel() {     if (canexit())         cdialogex::oncancel(); }  bool csalam001dlg::canexit() {     // if proxy object still around, automation     //  controller still holding on application.  leave     //  dialog around, hide ui.     if (m_pautoproxy != null)     {         showwindow(sw_hide);         return false;     }      return true; } 

i need fix problem in following line :

nerror = lsexecutescriptlng(plingo, ( lpctstr ) csscript); 

the error message :

error c2664: 'int lsexecutescriptlng(void *,const char )' : cannot convert argument 2 'lpctstr' 'const char

please me.

it means says: cannot convert 2-byte-character one-byte character. need declare , use of char variables. since project settings set unicode, tchar map char, , cstring map cstringw. have options:

  • declare needed variables char (or derivation of char, example cstringa)
  • (not advised) change project settings use multi-byte.
  • don't ever forcefully type cast it. forcing float* , int* - wont work!

see this article


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -