PDA

View Full Version : cannot convert parameter 2 from 'char [80]' to 'LPWSTR'



sabeesh
4th December 2007, 05:37
Hi,
I am using QT-4.3 and Using Visual Studio-2005 for compiling. I need to find the Web camera in windows. For that I use this command,


char szDeviceName[80];
char szDeviceVersion[80];

for(int iPos = 0; iPos<2; iPos++)
{
if (capGetDriverDescription( iPos, szDeviceName, sizeof (szDeviceName),
szDeviceVersion,
sizeof (szDeviceVersion)
))

qDebug()<< " driverName " << driverName;
}

when I try this, at the time of compiling VS-2005 display an error like this,

'capGetDriverDescriptionW' : cannot convert parameter 2 from 'char [80]' to 'LPWSTR'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Please help me to solve this probs

MarkoSan
4th December 2007, 05:45
Why don't you use QString, if you are working with Qt?

sabeesh
4th December 2007, 05:52
Hi,
When I use QString, then the error display like this,

'capGetDriverDescriptionW' : cannot convert parameter 2 from 'QString' to 'LPWSTR'

Please Help me
:(

MarkoSan
4th December 2007, 05:59
So, I think (I am not that good in MFC programming), but LPWSTR is long pointer to wide string. You are trying to convert a string to pointer, which is not possible. Try to:
char szDeviceName[80];
char szDeviceVersion[80];change to


char* szDeviceName;
char* szDeviceVersion;

Take a look at
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=514603&SiteID=1

ChristianEhrlicher
4th December 2007, 06:44
As we're in an unicode environment you have to use WCHAR instead char.
or QString with .utf16()

spud
4th December 2007, 14:21
or call capGetDriverDescriptionA explicitly...