Questions tagged [lpcstr]

Use this tag for questions related to the LPCSTR data type.

LPCSTR is a common data type used in Windows programming for representing strings. Its name is an acronym that stands for Long Pointer to Const String. From the corresponding MSDN page:

An LPCSTR is a 32-bit pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters.

This type is declared as follows:

typedef const char* LPCSTR;
56 questions
0
votes
3 answers

Weird behavior while converting a std::string to a LPCSTR

I was playing with some strings when I stumbled upon a weird behavior while converting a std::string to a LPCSTR. I have written a small test application to demonstrate : #include #include #include using namespace…
Frank
  • 147
  • 2
  • 10
0
votes
1 answer

char[] vs LPCSTR strange behavior

Could you please explain why, in order to convert a char array like this: char strarr[5] = {65,83,67,73,73}; //ASCII Into LPCSTR to be accepted by GetModuleHandleA() and GetProcAddress(), I have to first append 0 to the end ? i.e. I have: char…
Fit Dev
  • 3,413
  • 3
  • 30
  • 54
0
votes
3 answers

The return value of a LPCSTR function becomes trashy

I was coding a simple XOR encryption program and then I noticed that the return value of a function is not the kind I expect to see. I just can't find a problem in my code, could anyone help me? Here's the program code: #include "windows.h" #include…
-1
votes
1 answer

The LPCSTR type string is garbled or displayed error

I have a LPCSTR that I want to convert to std::string or char*. LPCSTR strName; _tprintf(_T("%s\n"), strName); I'm trying to get all the audio equipment on the computer and displayed, but to get the LPCSTR type of direct output is garbled, use the…
H S T
  • 27
  • 5
-2
votes
1 answer

cannot convert 'const wchar_t*' to 'LPCSTR' {aka 'const char*'}

Please help me with this code, I don't know how to change it so I can fix it and run it std::wstring stemp = std::wstring(filename.begin(), filename.end()); hBitmapG = (HBITMAP)LoadImage(GetModuleHandle(NULL), stemp.c_str(), IMAGE_BITMAP, …
-2
votes
1 answer

trying to make a window in c++, errors with assigning strings, LPCSTR / LPCWSTR stuff

iv'e been googling for hours, nothing seems to work. i'm not splitting my stuff into .h and .cpp because weird stuff happens for some reason, but that's beside the point i am getting the following errors: cannot convert 'const wchar_t [16]' to…
Aerbon
  • 13
  • 2
-2
votes
1 answer

Learning reversing via C++, but what does this line do?

typedef int(__stdcall *__MessageBoxA)(HWND, LPCSTR, LPCSTR, UINT); As I said, im trying to learn how to reverse engineer programs using C++ / Assembly, so I'm going through some open source projects I found on the internet. But can anyone explain…
Wes
  • 11
  • 1
  • 3
-2
votes
4 answers

double to const char * by function

R=10; LPCSTR cs; string s; stringstream ss; ss<
newandlost
  • 935
  • 2
  • 10
  • 21
-2
votes
1 answer

How to convert from a string to LPCSTR, if at all? (C++)

Possible Duplicate: How to convert std::string to LPCSTR? I'm interested in making a function which will go through a range of pages on a website and download the information from each one. For example - mywebsite.com/?page=1,…
-3
votes
1 answer

Assigning Variable to CreateFileA file name

I'm creating a .bmp file using this CreateFileA method HANDLE hFile = CreateFileA("Screenshot01.bmp", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); At the moment is static and just keeps re-writing the old file. I want to call…
Ezrar
  • 23
  • 2
-3
votes
2 answers

Program appends L to variable name using TCHAR type and TEXT macro

I'm trying to get the Program Files path, append it another bit of path and then run it. TCHAR programsdir[MAX_PATH]; SHGetFolderPath(NULL,CSIDL_PROGRAM_FILESX86,NULL,NULL,programsdir); PathAppend(programsdir, TEXT("\\bin\\program.exe")); LPCSTR…
Or Weinberger
  • 7,332
  • 23
  • 71
  • 116
1 2 3
4