c++ errors ( cannot convert parameter 2 from 'char [32]' to 'int')

Posted on 2007-10-08
Last Modified: 2013-12-04
I am getting the following errors in my code (from an override):

.\TotalControl.cpp(36) : error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [32]' to 'LPWSTR'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
.\TotalControl.cpp(37) : error C2664: 'HRESULT (char *,int)' : cannot convert parameter 2 from 'char [32]' to 'int'
        There is no context in which this conversion is possible



#include <windows.h>
#include <stdio.h>
#include "stdafx.h"
#include "KC0Mapper.h"
#include "VdjPlugin.h"
#include "vdjDevice.h"

// Mapper class
class KC0DefaultMapper : public IVdjPluginDevice

      HRESULT __stdcall GetDeviceType(int *type);
      HRESULT __stdcall OnGetPluginInfo(TVdjPluginInfo *infos);
      HRESULT __stdcall OnSlider(int chan,int slider,int absvalue,int relvalue);


// Set device type
HRESULT KC0DefaultMapper::GetDeviceType(int *type)

HRESULT KC0DefaultMapper::OnSlider(int chan,int slider,int absvalue,int relvalue)
      char cmd[32];

            case KC0_SLID_CROSSFADER:
            wsprintf(cmd,"video_crossfade %d",absvalue);

// Return information about plugin
HRESULT KC0DefaultMapper::OnGetPluginInfo(TVdjPluginInfo *infos)
      static char st[128];

      infos->PluginName = ".";
      infos->Author = ".";
      infos->Description = ".";
      infos->Flag = 0;

      infos->Bitmap = LoadBitmap(hInstance,MAKEINTRESOURCE(100));

      return S_OK;
Question by:makman111
    LVL 4

    Accepted Solution

    From just looking at this code, there are two separate issues I think.

    For the first error:
    Try changing from wsprintf to sprintf.

    For the second error:
    HRESULT (char *,int) seems to be the prototype for the function SendCommand, however you are providing (int, char*). Switch your params around and that should work. SendCommand(cmd,chan). I'm making guesses since I don't have the function prototype to reference.
    LVL 86

    Assisted Solution

    >>error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [32]' to >>'LPWSTR'

    To me that looks like the project is set to use UNICODE, yet the code doesn't - try to turn off UNICODE in your project settings or make that the ANSI version explicitly:

    wsprintfA(cmd,"video_crossfade %d",absvalue);

    Yet changing the settings will save you a lot of changes like the above.

    Author Comment

    Use Multi-Byte Character Set?
    LVL 86

    Assisted Solution

    Yes, that would be the setting ;o)

    Author Comment

    Can you look at (below) as well?  I think you are correct, but the errors below are preventing me from seeing to total solution.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
    The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now