-
LPCSTR and WinExec()
The WinExec() function is as follows;
UINT WinExec( LPCSTR lpCmdLine, // address of command line
UINT uCmdShow // window style for new application);
}
If I am running a program from the directory c:\temp how can I execute the file
\windows\notepad.exe. I don't understand how to put the address of the command
line in this LPCSTR variable and I don't understand what kind of variable
LPCSTR is?
Any response is appreciated.
-
Re: LPCSTR and WinExec()
LPCSTR is equivalent to a const char*.
It basically means that WinExec expects a character array which won't be changed inside of WinExec. This guarantees you that the array you pass to WinExec will be the same before you call it and after it returns.
The opposite of LPCSTR is LPSTR which is used by functions which do change the character array internally.
Alvaro
-
Re: LPCSTR and WinExec()
The first place to look to answer this sort of question is the VC++ documentation:
LPCSTR: Same as LPSTR, except used for read-only string pointers. Defined as (const char FAR*).
LPSTR: A 32-bit pointer to a character string
const char cmdLine[] = "\\windows\\notepad.exe";
UINT result = WinExec(cmdLine, SW_SHOW);
if (result < 32)
{
// handle error
}
Dave