start_info.lpDesktop is LPWSTR entity, but it says this is const wchat_t*?
up vote
-1
down vote
favorite
I am a complete noob using C++, i just want to re-compile an exploit.
I got the error:
you can not assign a value of type "const wchar_t *" to an entity of type "LPWSTR"
c++ visual-c++
add a comment |
up vote
-1
down vote
favorite
I am a complete noob using C++, i just want to re-compile an exploit.
I got the error:
you can not assign a value of type "const wchar_t *" to an entity of type "LPWSTR"
c++ visual-c++
1
Please always post text rather than images of text.
– Jesper Juhl
Nov 10 at 20:26
LPWSTR
is defined aswchar_t*
, versusconst wchar_t*
. The error says you can't change a constant to mutable.
– Barmak Shemirani
Nov 10 at 20:26
Post a Minimal, Complete, and Verifiable example or there's not really anything we can do to help you.
– Jesper Juhl
Nov 10 at 20:27
They've been cracking down on such practices in VS2017. You can get the old behavior with Project > Properties > C/C++ > Language, "Conformance mode" = No. Or use wcscpy_s() to conform.
– Hans Passant
Nov 10 at 21:11
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I am a complete noob using C++, i just want to re-compile an exploit.
I got the error:
you can not assign a value of type "const wchar_t *" to an entity of type "LPWSTR"
c++ visual-c++
I am a complete noob using C++, i just want to re-compile an exploit.
I got the error:
you can not assign a value of type "const wchar_t *" to an entity of type "LPWSTR"
c++ visual-c++
c++ visual-c++
edited Nov 10 at 20:36
Remy Lebeau
326k18244430
326k18244430
asked Nov 10 at 19:57
ri ru
21
21
1
Please always post text rather than images of text.
– Jesper Juhl
Nov 10 at 20:26
LPWSTR
is defined aswchar_t*
, versusconst wchar_t*
. The error says you can't change a constant to mutable.
– Barmak Shemirani
Nov 10 at 20:26
Post a Minimal, Complete, and Verifiable example or there's not really anything we can do to help you.
– Jesper Juhl
Nov 10 at 20:27
They've been cracking down on such practices in VS2017. You can get the old behavior with Project > Properties > C/C++ > Language, "Conformance mode" = No. Or use wcscpy_s() to conform.
– Hans Passant
Nov 10 at 21:11
add a comment |
1
Please always post text rather than images of text.
– Jesper Juhl
Nov 10 at 20:26
LPWSTR
is defined aswchar_t*
, versusconst wchar_t*
. The error says you can't change a constant to mutable.
– Barmak Shemirani
Nov 10 at 20:26
Post a Minimal, Complete, and Verifiable example or there's not really anything we can do to help you.
– Jesper Juhl
Nov 10 at 20:27
They've been cracking down on such practices in VS2017. You can get the old behavior with Project > Properties > C/C++ > Language, "Conformance mode" = No. Or use wcscpy_s() to conform.
– Hans Passant
Nov 10 at 21:11
1
1
Please always post text rather than images of text.
– Jesper Juhl
Nov 10 at 20:26
Please always post text rather than images of text.
– Jesper Juhl
Nov 10 at 20:26
LPWSTR
is defined as wchar_t*
, versus const wchar_t*
. The error says you can't change a constant to mutable.– Barmak Shemirani
Nov 10 at 20:26
LPWSTR
is defined as wchar_t*
, versus const wchar_t*
. The error says you can't change a constant to mutable.– Barmak Shemirani
Nov 10 at 20:26
Post a Minimal, Complete, and Verifiable example or there's not really anything we can do to help you.
– Jesper Juhl
Nov 10 at 20:27
Post a Minimal, Complete, and Verifiable example or there's not really anything we can do to help you.
– Jesper Juhl
Nov 10 at 20:27
They've been cracking down on such practices in VS2017. You can get the old behavior with Project > Properties > C/C++ > Language, "Conformance mode" = No. Or use wcscpy_s() to conform.
– Hans Passant
Nov 10 at 21:11
They've been cracking down on such practices in VS2017. You can get the old behavior with Project > Properties > C/C++ > Language, "Conformance mode" = No. Or use wcscpy_s() to conform.
– Hans Passant
Nov 10 at 21:11
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
The lpDesktop
field is a LPWSTR
(wchar_t*
), not a LPCWSTR
(const wchar_t *
). A wide string literal is a const wchar_t[N]
(where N
is 16 in your example), which decays to const wchar_t *
. You cannot assign a pointer-to-const-data to a pointer-to-non-const-data. That is what the compiler is complaining about.
To assign a string literal to lpDesktop
, you need to cast it:
start_info.lpDesktop = (LPWSTR) L"WinSta0\Default";
Or better:
start_info.lpDesktop = const_cast<LPWSTR>(L"WinSta0\Default");
Otherwise, copy the data to a local non-const wchar_t
buffer and use that instead:
WCHAR szDesktop = L"WinSta0\Default";
start_info.lpDesktop = szDesktop;
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
The lpDesktop
field is a LPWSTR
(wchar_t*
), not a LPCWSTR
(const wchar_t *
). A wide string literal is a const wchar_t[N]
(where N
is 16 in your example), which decays to const wchar_t *
. You cannot assign a pointer-to-const-data to a pointer-to-non-const-data. That is what the compiler is complaining about.
To assign a string literal to lpDesktop
, you need to cast it:
start_info.lpDesktop = (LPWSTR) L"WinSta0\Default";
Or better:
start_info.lpDesktop = const_cast<LPWSTR>(L"WinSta0\Default");
Otherwise, copy the data to a local non-const wchar_t
buffer and use that instead:
WCHAR szDesktop = L"WinSta0\Default";
start_info.lpDesktop = szDesktop;
add a comment |
up vote
1
down vote
accepted
The lpDesktop
field is a LPWSTR
(wchar_t*
), not a LPCWSTR
(const wchar_t *
). A wide string literal is a const wchar_t[N]
(where N
is 16 in your example), which decays to const wchar_t *
. You cannot assign a pointer-to-const-data to a pointer-to-non-const-data. That is what the compiler is complaining about.
To assign a string literal to lpDesktop
, you need to cast it:
start_info.lpDesktop = (LPWSTR) L"WinSta0\Default";
Or better:
start_info.lpDesktop = const_cast<LPWSTR>(L"WinSta0\Default");
Otherwise, copy the data to a local non-const wchar_t
buffer and use that instead:
WCHAR szDesktop = L"WinSta0\Default";
start_info.lpDesktop = szDesktop;
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
The lpDesktop
field is a LPWSTR
(wchar_t*
), not a LPCWSTR
(const wchar_t *
). A wide string literal is a const wchar_t[N]
(where N
is 16 in your example), which decays to const wchar_t *
. You cannot assign a pointer-to-const-data to a pointer-to-non-const-data. That is what the compiler is complaining about.
To assign a string literal to lpDesktop
, you need to cast it:
start_info.lpDesktop = (LPWSTR) L"WinSta0\Default";
Or better:
start_info.lpDesktop = const_cast<LPWSTR>(L"WinSta0\Default");
Otherwise, copy the data to a local non-const wchar_t
buffer and use that instead:
WCHAR szDesktop = L"WinSta0\Default";
start_info.lpDesktop = szDesktop;
The lpDesktop
field is a LPWSTR
(wchar_t*
), not a LPCWSTR
(const wchar_t *
). A wide string literal is a const wchar_t[N]
(where N
is 16 in your example), which decays to const wchar_t *
. You cannot assign a pointer-to-const-data to a pointer-to-non-const-data. That is what the compiler is complaining about.
To assign a string literal to lpDesktop
, you need to cast it:
start_info.lpDesktop = (LPWSTR) L"WinSta0\Default";
Or better:
start_info.lpDesktop = const_cast<LPWSTR>(L"WinSta0\Default");
Otherwise, copy the data to a local non-const wchar_t
buffer and use that instead:
WCHAR szDesktop = L"WinSta0\Default";
start_info.lpDesktop = szDesktop;
answered Nov 10 at 20:42
Remy Lebeau
326k18244430
326k18244430
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242871%2fstart-info-lpdesktop-is-lpwstr-entity-but-it-says-this-is-const-wchat-t%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Please always post text rather than images of text.
– Jesper Juhl
Nov 10 at 20:26
LPWSTR
is defined aswchar_t*
, versusconst wchar_t*
. The error says you can't change a constant to mutable.– Barmak Shemirani
Nov 10 at 20:26
Post a Minimal, Complete, and Verifiable example or there's not really anything we can do to help you.
– Jesper Juhl
Nov 10 at 20:27
They've been cracking down on such practices in VS2017. You can get the old behavior with Project > Properties > C/C++ > Language, "Conformance mode" = No. Or use wcscpy_s() to conform.
– Hans Passant
Nov 10 at 21:11