CreateProcess problem and CString to char* conversion
-
I'm trying to run a program using CreateProcess, but I am unable to run the program due to getting a 998 error, or an "Invalid access to memory location." error. I know the reason for this is because of how CreateProcess handles path names. Here's my call to CreateProcess: CreateProcess(appPath,cmdLineInfo,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi); It should work like a charm, but the problem lies within the path specified in the appPath String. This is what is in the CString appPath: "C:\Directory_1\Directory secion 2\executable.exe" Create Process doesn't handle the seperated folder name properly. How can I correct this??? In addition: How do you convert a CString to a LPTSTR??? Any help is GREATLY appreciated. Thanks!
-
I'm trying to run a program using CreateProcess, but I am unable to run the program due to getting a 998 error, or an "Invalid access to memory location." error. I know the reason for this is because of how CreateProcess handles path names. Here's my call to CreateProcess: CreateProcess(appPath,cmdLineInfo,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi); It should work like a charm, but the problem lies within the path specified in the appPath String. This is what is in the CString appPath: "C:\Directory_1\Directory secion 2\executable.exe" Create Process doesn't handle the seperated folder name properly. How can I correct this??? In addition: How do you convert a CString to a LPTSTR??? Any help is GREATLY appreciated. Thanks!
will1383 wrote: Create Process doesn't handle the seperated folder name properly. How can I correct this??? Just a guess, but how about enclosing the file name in quotes. If that don't work, how about converting the path to 8.3 format using
GetShortPathName()
. will1383 wrote: How do you convert a CString to a LPTSTR???CString::GetBuffer()
will return anLPTSTR
. Just be sure to callReleaseBuffer()
when you are done.
[
](http://www.canucks.com)Sonork 100.11743 Chicken Little "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 Within you lies the power for good - Use it!
-
I'm trying to run a program using CreateProcess, but I am unable to run the program due to getting a 998 error, or an "Invalid access to memory location." error. I know the reason for this is because of how CreateProcess handles path names. Here's my call to CreateProcess: CreateProcess(appPath,cmdLineInfo,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi); It should work like a charm, but the problem lies within the path specified in the appPath String. This is what is in the CString appPath: "C:\Directory_1\Directory secion 2\executable.exe" Create Process doesn't handle the seperated folder name properly. How can I correct this??? In addition: How do you convert a CString to a LPTSTR??? Any help is GREATLY appreciated. Thanks!
-
(LPTSTR)(LPTCSTR)myString; Works but not recommended or safe. I Touched Osama Bin Ladens Bushy Beard
-
(LPTSTR)(LPTCSTR)myString; Works but not recommended or safe. I Touched Osama Bin Ladens Bushy Beard
-
before i knew about getbuffer i have used this kind of type casting to modify the data also, never gave me any problem but not doing it now.:rolleyes: I Touched Osama Bin Ladens Bushy Beard
-
before i knew about getbuffer i have used this kind of type casting to modify the data also, never gave me any problem but not doing it now.:rolleyes: I Touched Osama Bin Ladens Bushy Beard
-
I'm trying to run a program using CreateProcess, but I am unable to run the program due to getting a 998 error, or an "Invalid access to memory location." error. I know the reason for this is because of how CreateProcess handles path names. Here's my call to CreateProcess: CreateProcess(appPath,cmdLineInfo,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi); It should work like a charm, but the problem lies within the path specified in the appPath String. This is what is in the CString appPath: "C:\Directory_1\Directory secion 2\executable.exe" Create Process doesn't handle the seperated folder name properly. How can I correct this??? In addition: How do you convert a CString to a LPTSTR??? Any help is GREATLY appreciated. Thanks!
Its very simple to convert a CString to LPTSTR, Just use CString str; str.operator LPCTSTR ( ); The "operator LPCTSTR ( )" will return a char pointer to the string data. ;) Best Regards, Jijo. Yesterday is history, Tomorrow is a mystery, But today is a present.
-
before i knew about getbuffer i have used this kind of type casting to modify the data also, never gave me any problem but not doing it now.:rolleyes: I Touched Osama Bin Ladens Bushy Beard
Well that is a BAD thing. However, casting to (LPTSTR) to deal with some MS API routines that can not or do not have the arguments defined as (LPCTSTR) works just find AS LONG AS you know the API will not write to the string. Many API's have arguments that have double duties and thus can not be defined as (LPCTSTR). Tim Smith I'm going to patent thought. I have yet to see any prior art.