2 pages: [1] [2]
HostWeb Forums » Microsoft Personal Operating Systems » microsoft.public.pocketpc.developer » CreateProcess crashes launched application

Topic: CreateProcess crashes launched application

Reply | New Topic | This is SPAM | This is Offensive

Submitted: 5/31/2006 9:20:06 AM

By: fangorn.mail
I'm trying to launch an application from an application I wrote. I'm
using CreateProcess like this:

if (CreateProcess(tnew_file, NULL, NULL, NULL, NULL, 0, NULL, NULL,
NULL, myProcInfo) == 0) {
sprintf(logmsg, "failed to launch (%d)", GetLastError());
WriteToSerial(logmsg);
}

tnew_file is a TCHAR specifying the path to the executable I'm wanting
to launch.
I'm trying to launch an application called hc.exe. The strange thing is
that when I use the above code, I do not see an error message but I do
see a windows message that says that hc.exe has performed an invalid
operation. But when I just go through file explorer and find the icon
for hc.exe and double click it, it starts without crashing and runs
fine.

Why would an application crash being started with CreateProcess but not
when just run?


Replies below ↓

Replies

Reply | New Topic | This is SPAM | This is Offensive

Submitted: 5/31/2006 11:10:05 AM

By: fangorn.mail

Re: CreateProcess crashes launched application


I declare myProcInfo like this:

LPPROCESS_INFORMATION myProcInfo;

And populate tnew_file like this:

status = mbstowcs(tnew_file, localFilename, strlen(localFilename)+1);
len = 2*(strlen(localFilename)+1);
tnew_file[len] = '\0';

where localFilename is \Storage Card\hc.exe and yes, hc.exe does exist.
The problem is not that the file hc.exe isn't found, it's that it
crashes when launched.


Reply | New Topic | This is SPAM | This is Offensive

Submitted: 5/31/2006 12:21:12 PM

By: fangorn.mail

Re: CreateProcess crashes launched application

In reading the help, I decided to try sending NULL instead of a
PROCESS_INFORMATION type. I tried this and still got an exception. So
then I created a new Hello World application - NO MFC. The application
I had been trying to launch used MFC, but did nothing at init. When I
tried to launch the none MFC application, it worked and did not crash.
This is strange to me, but the application I'll be launching in the end
isn't being written with MFC, so maybe I just lucked out here. Have you
seen a difference like that between MFC and non-MFC?


Reply | New Topic | This is SPAM | This is Offensive

Submitted: 5/31/2006 1:10:37 PM

By: ctacke/>"

Re: CreateProcess crashes launched application

How about showing us where you actually put data into tnew_file and your
declaration for myProcInfo.

-Chris



"Fangorn" <fangorn.mail@gmail.com> wrote in message
news:1149092406.609893.289020@y43g2000cwc.googlegroups.com...
> I'm trying to launch an application from an application I wrote. I'm
> using CreateProcess like this:
>
> if (CreateProcess(tnew_file, NULL, NULL, NULL, NULL, 0, NULL, NULL,
> NULL, myProcInfo) == 0) {
> sprintf(logmsg, "failed to launch (%d)", GetLastError());
> WriteToSerial(logmsg);
> }
>
> tnew_file is a TCHAR specifying the path to the executable I'm wanting
> to launch.
> I'm trying to launch an application called hc.exe. The strange thing is
> that when I use the above code, I do not see an error message but I do
> see a windows message that says that hc.exe has performed an invalid
> operation. But when I just go through file explorer and find the icon
> for hc.exe and double click it, it starts without crashing and runs
> fine.
>
> Why would an application crash being started with CreateProcess but not
> when just run?
>



Reply | New Topic | This is SPAM | This is Offensive

Submitted: 5/31/2006 3:00:15 PM

By: ctacke/>"

Re: CreateProcess crashes launched application

The filename stuff seems like a convoluted way to get there but it should
work. myProcInfo however is a problem based on just this code. You created
a pointer, so you've allocated 4 bytes for that, but where's your allocation
of the actual space for the structure? The CreateProcess call is probably
trying to fill the PROCESS_INFORMATION struct members, making an invalid
access and going down in flames.

-Chris



"Fangorn" <fangorn.mail@gmail.com> wrote in message
news:1149099005.538626.25320@f6g2000cwb.googlegroups.com...
>
> I declare myProcInfo like this:
>
> LPPROCESS_INFORMATION myProcInfo;
>
> And populate tnew_file like this:
>
> status = mbstowcs(tnew_file, localFilename, strlen(localFilename)+1);
> len = 2*(strlen(localFilename)+1);
> tnew_file[len] = '\0';
>
> where localFilename is \Storage Card\hc.exe and yes, hc.exe does exist.
> The problem is not that the file hc.exe isn't found, it's that it
> crashes when launched.
>



Contents
Home
Forums
About Us
Contact Us
Web Hosting:
Hosting Providers
How to choose a name
What is a Hosting Provider
Hosting Types
Choosing the right plan
 
Search
 
Login to HostWeb.com
Email
Password
If you do not have an account with us yet, join now - it's FREE!