G
G
German2018-06-09 22:41:43
C++ / C#
German, 2018-06-09 22:41:43

How to pass argument of type string or char array to function from win api?

I am using Visual Studio 2017.
Here is the code snippet:

#include "stdafx.h"
#include <iostream>
#include <string>
#include <windows.h>
#include <shellapi.h>
#include <mmsystem.h>
#pragma comment(lib, "WinMM.Lib")

using namespace std;

int main()
{
  string aaa = "C:\\";
  cout << (GetDriveType(aaa)==DRIVE_CDROM);
  return 0;
}

Errors that occur:
5b1c2d6e9d4db988525371.png
How to pass "C:\\" through a variable of type string?
I will also be grateful if you tell me how to do the same with a char array, for example
char aaa[4] = "C:\\";

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question