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
2
votes
2 answers

JNA mapping LPCSTR on windows platform

I am working on call one DLL api for C/C++ with JNA. The function API in DLL is short DKT_init(LPCSTR name). I made the corresponding java method as public short DKT_init(String name); But when I call it, the DLL API return a parameter error. I…
Aolphin
  • 21
  • 2
2
votes
4 answers

convert std::string to LPCSTR with trailing or leading '\0'

How can I convert std::string to LPCSTR while preserving '\0' characters? I want to use the result on OPENFILENAME.lpstrFilter which requires the filter to contain '\0' as delimiters. std::string.c_str() seems to strip and trim '\0' Thanks in…
Jake
  • 11,273
  • 21
  • 90
  • 147
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

std::ostringstream to LPCSTR?

How can I convert a std::ostringstream to LPCSTR? std::ostringstream oss; [...] LPCSTR result = oss.str(); Result: Error: No suitable conversion function from "std::basic_string, std::allocator>" to "LPCSTR"…
Tom Doodler
  • 1,471
  • 2
  • 15
  • 41
2
votes
1 answer

How do i convert HWND to LPCSTR in C++

What should i do to convert a HWND data type to LPCSTR. I need to print it to debug window using OutputDebugStringA function
Jasir
  • 677
  • 1
  • 8
  • 26
2
votes
3 answers

how can convert LPCSTR string into LPCTSTR string?

i am trying to convert a LPCSTR string into LPCTSTR string. i want to concatenate two string,when i try like this LPCTSTR str1 = L"Raja" LPCSTR str2 = "Kumar" wcscat_s(str1,(LPCTSTR)str2); i found the o/p like Raja....r(junkvalues)....how can…
Rajakumar
  • 442
  • 1
  • 9
  • 21
2
votes
1 answer

C++ /cli Convert LPCSTR to System::String^

I'm having a problem with converting LPCSTR to System::String^, though i am able to convert System::String to LPCSTR with Marshal. But how can i convert LPCSTR to System::String^ Thank You
Miguel P
  • 1,262
  • 6
  • 23
  • 48
1
vote
3 answers

C++ LPCTSTR to char*

I am using visual studio 2010 MFC to build a C++ program. My program calls a DLL that is not apart of the project and it accepts a char*. I have a function that gets a string in a format of LPCTSTR. I have been on google for about two hours now, and…
Landin Martens
  • 3,283
  • 12
  • 43
  • 61
1
vote
1 answer

Errors when trying to create a blank window in C++ / difference between LPCWSTR and LPCSTR, WinAPI

I have followed several tutorials, and am attempting to make a basic C++ game, starting with getting the window running. When I try to run my code, I get a series of errors regarding the type of string, and no matter which tutorial I follow, I end…
1
vote
3 answers

C++ concat LPCTSTR

I am implementing a custom action for a WindowsCE CAB file, and I need to concat a LPCTSTR to get a proper path to an exe. My custom action receives a LPCTSTR as an argument. So (pseudocode): extern "C" codeINSTALL_EXIT MYCUSTOMACTION_API…
jonathanpeppers
  • 26,115
  • 21
  • 99
  • 182
1
vote
1 answer

Int to PCSTR for Winsock DEFAULT_PORT

I a menu that displays first thing when running my winsock application, I'd like to be able to choose a port on startup but I am having problems converting int to PCSTR or any other type of conversion as I have tried a few. Here is some code: My…
1
vote
1 answer

Directx error DrawTextA and LPCSTR and HDC

in Debug mode I get this: Severity Code Description Project File Line Error C2660 'DrawTextA': function does not take 4 arguments Win32Project6 c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp …
user3742860
  • 100
  • 2
  • 13
1
vote
1 answer

How do I pass a LPCSTR to a c++ function convert to string and return a LPCSTR?

I have a C++ API function that is called by Install Shield via InstallScript: SQLHELPER_API LPCSTR GetAvailableAppName(LPCSTR appNameP) { //return "this works just fine"; std::string newAppName = "I work, maybe?"; LPCSTR returnVal =…
TruthOf42
  • 2,017
  • 4
  • 23
  • 38
1
vote
1 answer

How to use mciSendString("play path",0,0,0) with exe path?

I'm using mciSendString("play path repeat",0,0,0) to play music in my project and I'm using it specially for playing multiple sounds in the same time. The problem is that I want to put the sounds in the executable path so I used a function to get…
Ali Essam
  • 502
  • 1
  • 7
  • 17
0
votes
0 answers

Explicitly deleted functions

we are migrating code to VS 2019 from legacy code We have an overloaded function on operator '<<' that is invoking basic_ostream function when executing the following lines. CStringArray asLine; using ostream = basic_ostream
Madhu Rao
  • 1
  • 1