A LPCSTR
is the same as const char *
.
Passing a C-style string like that to a function call is fine.
Returning a pointer to a local function variable is not fine, because this local variable doesn´t exist anymore after the function ends. As soon as you´re using the pointer in main
(or whereever the function was called), it points to a memory which doesn´t belong to you anymore, and the value may have changed already.
There are several possibilites, each with a downside:
Using only memory you got as parameter (eg. appNameP
, because this has to be something from outside and will still exist after the function ends). Downside: You need to pass something fitting for that purpose => the function signature or at least the requirements for the parameters changes, and you´ve to check/change how it is called.
Allocating something with new
. Downside: Somewhere later, outside, delete[]
have to be called.
Returning something like std::string
. Downside: As in #1, the function signature changes, and you´ve to change how it is called.
If InstallShield calls this function itself:
What InstallShield expects you to do should be somewhere in the documentation.