CeCreateProcess and WaitForSingleObject problem?

D

Dan Tanzer

I need a little help.
I am trying to get the space off of the storage card from the Pocket PC
using Rapi. Since i have not found a direct API (RAPI) to do this i wrote a
small .net compact framework exe to call GetDiskFreeSpaceEx create a file
with the data and then copy the file from the pocket pc to the PC. I am able
to run the CeCreateProcess with no problem and create the file but i cant
get the WaitForSingbject to wait for it to complete, it always fails wiht
the same message.
"Cannot create a file when that file already exists".
I thought it was the GetDiskFreeSpaceEx so i commented out all of the code
in my sample program "test.exe" and it fails with the same message.

Here is the code i am using .
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
public static extern int CeCreateProcess (string lpApplicationName, int
notused, int Res1, int Res2, int Res3, int dwCreationFlags, int Res4, int
Res5, int Res6,ref PROCESS_INFORMATION lpProcessInformation);

Rapi.PROCESS_INFORMATION pi = new Rapi.PROCESS_INFORMATION();
int x = Rapi.CeCreateProcess( @"\Program
files\zerama\test.exe",0,0,0,0,0,0,0,0, ref pi);
int ret = Rapi.WaitForSingleObject(pi.hProcess ,100000);
Rapi.CeCloseHandle(pi.hProcess);
Rapi.CeCloseHandle(pi.hThread);

Any Ideas?

Dan Tanzer
(e-mail address removed)
www.zerama.net
 
A

Alex Feinman [MVP]

I must be missing something here. So, you create a process *on the device*
using CeCreateProcess, and get the *device* process handle. ANd now you are
trying to use it with WaitForSingleObject on the *desktop*???
 
D

Dan Tanzer

Yes, I am trying to use the *device* process handle with WaitForSinglObject
but it always fails with the message
"Cannot create a file when that file already exists".

Also i forgot to add this in my last post but here is the WaitForSinglObject
Dllimport i used, if that helps any.
[DllImport("kernel32.dll", EntryPoint="WaitForSingleObject", SetLastError =
true)]
public static extern int WaitForSingleObject(IntPtr hHandle, uint
dwMilliseconds);

Dan



Alex Feinman said:
I must be missing something here. So, you create a process *on the device*
using CeCreateProcess, and get the *device* process handle. ANd now you are
trying to use it with WaitForSingleObject on the *desktop*???

Dan Tanzer said:
I need a little help.
I am trying to get the space off of the storage card from the Pocket PC
using Rapi. Since i have not found a direct API (RAPI) to do this i
wrote
a
small .net compact framework exe to call GetDiskFreeSpaceEx create a file
with the data and then copy the file from the pocket pc to the PC. I am able
to run the CeCreateProcess with no problem and create the file but i cant
get the WaitForSingbject to wait for it to complete, it always fails wiht
the same message.
"Cannot create a file when that file already exists".
I thought it was the GetDiskFreeSpaceEx so i commented out all of the code
in my sample program "test.exe" and it fails with the same message.

Here is the code i am using .
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
public static extern int CeCreateProcess (string lpApplicationName, int
notused, int Res1, int Res2, int Res3, int dwCreationFlags, int Res4, int
Res5, int Res6,ref PROCESS_INFORMATION lpProcessInformation);

Rapi.PROCESS_INFORMATION pi = new Rapi.PROCESS_INFORMATION();
int x = Rapi.CeCreateProcess( @"\Program
files\zerama\test.exe",0,0,0,0,0,0,0,0, ref pi);
int ret = Rapi.WaitForSingleObject(pi.hProcess ,100000);
Rapi.CeCloseHandle(pi.hProcess);
Rapi.CeCloseHandle(pi.hThread);

Any Ideas?

Dan Tanzer
(e-mail address removed)
www.zerama.net
 
A

Alex Feinman [MVP]

Well, that simply won't work - Windows kernel on the desktop doesn't know
about device processes.

Dan Tanzer said:
Yes, I am trying to use the *device* process handle with WaitForSinglObject
but it always fails with the message
"Cannot create a file when that file already exists".

Also i forgot to add this in my last post but here is the WaitForSinglObject
Dllimport i used, if that helps any.
[DllImport("kernel32.dll", EntryPoint="WaitForSingleObject", SetLastError =
true)]
public static extern int WaitForSingleObject(IntPtr hHandle, uint
dwMilliseconds);

Dan



Alex Feinman said:
I must be missing something here. So, you create a process *on the device*
using CeCreateProcess, and get the *device* process handle. ANd now you are
trying to use it with WaitForSingleObject on the *desktop*???

Dan Tanzer said:
I need a little help.
I am trying to get the space off of the storage card from the Pocket PC
using Rapi. Since i have not found a direct API (RAPI) to do this i
wrote
a
small .net compact framework exe to call GetDiskFreeSpaceEx create a file
with the data and then copy the file from the pocket pc to the PC. I
am
able
to run the CeCreateProcess with no problem and create the file but i cant
get the WaitForSingbject to wait for it to complete, it always fails wiht
the same message.
"Cannot create a file when that file already exists".
I thought it was the GetDiskFreeSpaceEx so i commented out all of the code
in my sample program "test.exe" and it fails with the same message.

Here is the code i am using .
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
public static extern int CeCreateProcess (string lpApplicationName, int
notused, int Res1, int Res2, int Res3, int dwCreationFlags, int Res4, int
Res5, int Res6,ref PROCESS_INFORMATION lpProcessInformation);

Rapi.PROCESS_INFORMATION pi = new Rapi.PROCESS_INFORMATION();
int x = Rapi.CeCreateProcess( @"\Program
files\zerama\test.exe",0,0,0,0,0,0,0,0, ref pi);
int ret = Rapi.WaitForSingleObject(pi.hProcess ,100000);
Rapi.CeCloseHandle(pi.hProcess);
Rapi.CeCloseHandle(pi.hThread);

Any Ideas?

Dan Tanzer
(e-mail address removed)
www.zerama.net
 
D

Dan Tanzer

Alex,
Well in that case, is there anyway to get the storage card total space and
available space that i may have missed.what i would like to do is similar to
the process the windows media player is doing in the "copy to device"
screen, if you notice it retrieves the file list and space information?

Dan

Alex Feinman said:
Well, that simply won't work - Windows kernel on the desktop doesn't know
about device processes.

Dan Tanzer said:
Yes, I am trying to use the *device* process handle with WaitForSinglObject
but it always fails with the message
"Cannot create a file when that file already exists".

Also i forgot to add this in my last post but here is the WaitForSinglObject
Dllimport i used, if that helps any.
[DllImport("kernel32.dll", EntryPoint="WaitForSingleObject",
SetLastError
=
true)]
public static extern int WaitForSingleObject(IntPtr hHandle, uint
dwMilliseconds);

Dan



Alex Feinman said:
I must be missing something here. So, you create a process *on the device*
using CeCreateProcess, and get the *device* process handle. ANd now
you
are
trying to use it with WaitForSingleObject on the *desktop*???

I need a little help.
I am trying to get the space off of the storage card from the Pocket PC
using Rapi. Since i have not found a direct API (RAPI) to do this i wrote
a
small .net compact framework exe to call GetDiskFreeSpaceEx create a file
with the data and then copy the file from the pocket pc to the PC. I am
able
to run the CeCreateProcess with no problem and create the file but i cant
get the WaitForSingbject to wait for it to complete, it always fails wiht
the same message.
"Cannot create a file when that file already exists".
I thought it was the GetDiskFreeSpaceEx so i commented out all of
the
code
in my sample program "test.exe" and it fails with the same message.

Here is the code i am using .
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
public static extern int CeCreateProcess (string lpApplicationName, int
notused, int Res1, int Res2, int Res3, int dwCreationFlags, int
Res4,
int
Res5, int Res6,ref PROCESS_INFORMATION lpProcessInformation);

Rapi.PROCESS_INFORMATION pi = new Rapi.PROCESS_INFORMATION();
int x = Rapi.CeCreateProcess( @"\Program
files\zerama\test.exe",0,0,0,0,0,0,0,0, ref pi);
int ret = Rapi.WaitForSingleObject(pi.hProcess ,100000);
Rapi.CeCloseHandle(pi.hProcess);
Rapi.CeCloseHandle(pi.hThread);

Any Ideas?

Dan Tanzer
(e-mail address removed)
www.zerama.net
 
P

Peter Foot [MVP]

I think the answer here is to write a custom dll for the device (It'll have
to be a native dll mind) to perform this routine and use CeRapiInvoke to
call a function to query this information directly on the device and return
the result.

Peter

--
Peter Foot
Windows Embedded MVP
OpenNETCF.org Senior Advisor
www.inthehand.com | www.opennetcf.org

Dan Tanzer said:
Alex,
Well in that case, is there anyway to get the storage card total space and
available space that i may have missed.what i would like to do is similar to
the process the windows media player is doing in the "copy to device"
screen, if you notice it retrieves the file list and space information?

Dan

Alex Feinman said:
Well, that simply won't work - Windows kernel on the desktop doesn't know
about device processes.

Dan Tanzer said:
Yes, I am trying to use the *device* process handle with WaitForSinglObject
but it always fails with the message
"Cannot create a file when that file already exists".

Also i forgot to add this in my last post but here is the WaitForSinglObject
Dllimport i used, if that helps any.
[DllImport("kernel32.dll", EntryPoint="WaitForSingleObject",
SetLastError
=
true)]
public static extern int WaitForSingleObject(IntPtr hHandle, uint
dwMilliseconds);

Dan



I must be missing something here. So, you create a process *on the device*
using CeCreateProcess, and get the *device* process handle. ANd now you
are
trying to use it with WaitForSingleObject on the *desktop*???

I need a little help.
I am trying to get the space off of the storage card from the
Pocket
PC
using Rapi. Since i have not found a direct API (RAPI) to do this i
wrote
a
small .net compact framework exe to call GetDiskFreeSpaceEx create a
file
with the data and then copy the file from the pocket pc to the PC.
I
am
able
to run the CeCreateProcess with no problem and create the file but i
cant
get the WaitForSingbject to wait for it to complete, it always fails
wiht
the same message.
"Cannot create a file when that file already exists".
I thought it was the GetDiskFreeSpaceEx so i commented out all of the
code
in my sample program "test.exe" and it fails with the same message.

Here is the code i am using .
[DllImport("rapi.dll", CharSet=CharSet.Unicode)]
public static extern int CeCreateProcess (string
lpApplicationName,
int
notused, int Res1, int Res2, int Res3, int dwCreationFlags, int Res4,
int
Res5, int Res6,ref PROCESS_INFORMATION lpProcessInformation);

Rapi.PROCESS_INFORMATION pi = new Rapi.PROCESS_INFORMATION();
int x = Rapi.CeCreateProcess( @"\Program
files\zerama\test.exe",0,0,0,0,0,0,0,0, ref pi);
int ret = Rapi.WaitForSingleObject(pi.hProcess ,100000);
Rapi.CeCloseHandle(pi.hProcess);
Rapi.CeCloseHandle(pi.hThread);

Any Ideas?

Dan Tanzer
(e-mail address removed)
www.zerama.net
 
Top