Gojira
Gojira

Reputation: 171

cannot convert from ‘QString’ to ‘LPCWSTR’ in Qt

I am working on an app where I need to display the file system format of the SD card. Since I couldnt find any Qt API’s for it, I choose a windows API GetVolumeInformation and did it as follows:

TCHAR volumeName[MAX_PATH + 1] = { 0 };
   TCHAR fileSystemName[MAX_PATH + 1] = { 0 };
   DWORD serialNumber = 0;
   DWORD maxComponentLen = 0;
   DWORD fileSystemFlags = 0;

   LPCWSTR path = deviceData->m_strPath;

   if (GetVolumeInformation(
       path,
       volumeName,
       ARRAYSIZE(volumeName),
       &serialNumber,
       &maxComponentLen,
       &fileSystemFlags,
       fileSystemName,
       ARRAYSIZE(fileSystemName)))
       {
                 qDebug()<<fileSystemName[0];
                 qDebug()<<fileSystemName[1];
                 qDebug()<<fileSystemName[2];
                 qDebug()<<fileSystemName[3];
                 qDebug()<<fileSystemName[4];
       }

path indicates the SD card path and when I run the app, it throws the following error: “cannot convert from ‘QString’ to ‘LPCWSTR’”. Where am i making a mistake??? Please help!!

Upvotes: 0

Views: 2958

Answers (1)

Reunanen
Reunanen

Reputation: 8001

You could try:

LPCWSTR path = deviceData->m_strPath.utf16();

Upvotes: 2

Related Questions