0

This will be a foolishness, but this code to change the Drive letter of the Wide-String throws me an Acces violation when writting the new value. (0xC0000005)

wchar_t* disk2 = L"D";
wchar_t* wszDrive = L"\\\\.\\C:";
wszDrive[5] = *disk2; //here is the acces violation

I'm using the lattest version of Visual Studio 2019.

Also I tried this way:

wchar_t* disk2 = L"D";
wchar_t* wszDrive = L"\\\\.\\C:";
memcpy(&wszDrive[5], disk2, 2);

And this other way:

wchar_t* disk2 = L"D";
wchar_t* wszDrive = L"\\\\.\\C:";
memcpy(wszDrive+10, disk2, 2);
user1814720
  • 93
  • 1
  • 8

0 Answers0