conversion

hey guys I am trying to compile my project but I have this error

error C2664: 'CreateFileW' : cannot convert parameter 1 from 'const char [12]' to 'LPCWSTR'

this error in this code

if (UpdateResource(hUpdate, RT_RCDATA, MAKEINTRESOURCE(20), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), sData->pKey.c_str(), sData->KeySize)==0)


Note: I am using multi Byte Character Set in my project properties so where is the problem ?


UpdateResource takes TCHAR's
UpdateResourceA takes char's
UpdateResourceW takes wchar_t's

If you're using char arrays, you have to use the char array version of the function.

Try UpdateResourceA(...)
Indeed I am using char arrays because sData->pKey.c_str() is a char array I used the char array version how ever I still get the same error ..
here is the edited code


 
if (UpdateResourceA(hUpdate, RT_RCDATA, MAKEINTRESOURCE(20), MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), sData->pKey.c_str(), sData->KeySize)==0
)

still the error is

error C2664: 'UpdateResourceA' : cannot convert parameter 5 from 'const char *' to 'LPVOID'
The data is to be passed a void*, not a const char*.

MSDN wrote:
lpData [in, optional]

Type: LPVOID

The resource data to be inserted into the file indicated by hUpdate. If the resource is one of the predefined types, the data must be valid and properly aligned. Note that this is the raw binary data to be stored in the file indicated by hUpdate, not the data provided by LoadIcon, LoadString, or other resource-specific load functions. All data containing strings or text must be in Unicode format. lpData must not point to ANSI data.

If lpData is NULL and cbData is 0, the specified resource is deleted from the file indicated by hUpdate.
The issue here is because LPVOID is not const, so it's possible for UpdateResourceA to modify the contents of that memory.

HOWEVER, MSDN says that it's an "in" parameter and doesn't say anything that would suggest that UpdateResourceA actually modifies this memory. So maybe this is just a problem with the API?
sorry Zhuge I couldnt get u .. u said the data to be passed should be void .. and the probelm with this data ... sData->pkey .. this is a string value it is a key ... from example sData->pKey = test
how CAn I change this from string to Void .. ? so I can pass it correctly through hUpdate?
Topic archived. No new replies allowed.