LPCWSTR - Pointer to const wchar_t string
Questions tagged [lpcwstr]
62 questions
32
votes
5 answers
cannot convert parameter 1 from 'char' to 'LPCWSTR'
I keep getting this error:
cannot convert parameter 1 from 'char' to 'LPCWSTR'
int main(int argc, char argv[])
{
// open port for I/O
HANDLE h = CreateFile(argv[1],GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);
if(h ==…

sebastian
- 1,528
- 8
- 26
- 38
7
votes
4 answers
Cannot convert parameter 1 from 'const wchar_t *' to 'LPCTSTR' in MFC / C++ project
I get a compilation error on the line:
MessageBox(e.getAllExceptionStr().c_str(), _T("Error initializing the sound player"));
Error 4 error C2664: 'CWnd::MessageBoxA' : cannot convert parameter 1 from 'const wchar_t *' to 'LPCTSTR' …

gornvix
- 3,154
- 6
- 35
- 74
5
votes
2 answers
String to LPCWSTR in c++
I'm trying to convert from string to LPCWSTR (I use multi-bite).
1) For example:
LPCWSTR ToLPCWSTR(string text)
{
LPCWSTR sw = (LPCWSTR)text.c_str();
return sw;
}
2) This returns Chinese characters:
LPCWSTR ToLPCWSTR(string text)
{
…

Jose
- 129
- 2
- 4
- 9
5
votes
1 answer
C++ get the length of LPCWSTR and LPVOID
The winapi function WinHttpSendRequest() wants the size of the second parameter in the third one and the size of the fourth parameter in the fifth one.
How can I calculate it?
I have a function wrapped around it and I pass the strings directly,…

Forivin
- 14,780
- 27
- 106
- 199
4
votes
3 answers
Visual Studio 2010 Arduino cpp Error: argument of type "char *" is incompatible with parameter of type "LPCWSTR"
I'm trying to set up an arduino uno for serial port communication with a C++ program in visual studio 2010. I'm working from the code found here: http://playground.arduino.cc/Interfacing/CPPWindows
Unfortunately, the .cpp file gives me the following…

X__
- 89
- 2
- 8
4
votes
4 answers
Cast (const) char * to LPCWSTR
I'm trying to use FindWindow() from WinAPI, and I want to ask an input for window's title from the user:
char *input;
cout << "Window title: ";
cin >> input;
Pretty standard.
Now then, how do I convert this to LPCWSTR for FindWindow()?
I've already…

Markus Meskanen
- 19,939
- 18
- 80
- 119
3
votes
1 answer
Convert wstringstream to LPCWSTR
I am a beginner at Winapi and I am trying to convert wstringstream to LPCWSTR like this (inside WM_PAINT):
wstringstream ws;
ws << "my text" << endl;
LPCWSTR myWindowOutput = ws.str().c_str();
hdc = BeginPaint(hWnd, &ps);
TextOut(hdc, 150, 305,…

Johan
- 863
- 3
- 13
- 28
3
votes
2 answers
Concatenate two WCHAR_T arrays in C++
Dealing with these insane strings and arrays is giving me a headache...
Here's my code so far
wchar_t mypath[MAX_PATH];
wchar_t temppath[MAX_PATH];
GetModuleFileName(0, mypath, MAX_PATH);
GetTempPath(MAX_PATH, temppath);
CreateDirectory(???,…

43.52.4D.
- 950
- 6
- 14
- 28
3
votes
3 answers
Cannot convert parameter 2 from 'const char [14]' to 'LPCWSTR'
I am getting this error:
cannot convert parameter 2 from 'const char [14]' to 'LPCWSTR'
With the code below. It is supposed to be C but at best visual studio 2012 offers an empty c++ project:
#include "windows.h"
int WINAPI WinMain (HINSTANCE…

Furkan Gözükara
- 22,964
- 77
- 205
- 342
2
votes
1 answer
FileCopyExW reports last error as ERROR_NOT_SUPPORTED - what does this mean in terms of FileCopyExW
Context:
I need to scan for, gather information and copy some media files from specific directories.
I have been having quite some trouble with some files not being detected, etc
Problem:
Warning to reader: As seen on the screenshot and noted in a…

CybeX
- 2,060
- 3
- 48
- 115
2
votes
1 answer
Visual C++: Convert data type PCSTR to LPCWSTR
I have the following C++ code that retrieves header request information from an HttpContext instance:
public:
REQUEST_NOTIFICATION_STATUS
OnBeginRequest(
IN IHttpContext * pHttpContext,
IN IHttpEventProvider * pProvider
)
{
…

lfaletti
- 46
- 5
2
votes
1 answer
How to pass a char* to the GetModuleHandle function?
I'm just trying to get the module information based on a string that can very well be something like "somefile.exe".
MODULEINFO GetModuleInfo(char *szModule)
{
MODULEINFO modinfo = {0};
HMODULE hModule = GetModuleHandle(szModule);
…

Gera
- 65
- 5
2
votes
3 answers
Asisgn LPCWSTR array from std::wstring
I am creating a dynamic array of LPCWSTR, and want to assign values at run time.
I have following code :
cin>>count
LPCWSTR * lpwcstrArray = new LPCWSTR[count]();
for (int i = 0; i < count; i++)
{
// some logic to create different wstring on…

l'-'l
- 428
- 1
- 7
- 18
2
votes
1 answer
Printing LPCWSTR string to file
I wrote a program where i stores list of filenames in a structure which i have to print it in a file.The type of filenames are in LPCWSTR and am stucking with problems that only the address of filename is printed if using ofstream class.I also tried…

WarriorPrince
- 157
- 2
- 13
2
votes
3 answers
Adding two LPCWSTR variables
I'm trying to add two LPCWSTR Variables as in
Shader = L"shader.fx"
Path = L"Source/Shaders/"
return Path + Shader
I've tried a thousand different ways, but my latest has been this
LPCWSTR ShaderFile = GetShader(L"shader.fx");
....
LPCWSTR…

Matt
- 175
- 2
- 12