More vb.Net Create Process Problems

  • Thread starter paul schenk via .NET 247
  • Start date
P

paul schenk via .NET 247

(Type your message here)

--------------------------------
From: paul schenk

Hi All :)

Would be grateful of advice please. I have code in VB6 working as follows:

lngReply = CreateProcess(sNull, txtStart, ByVal 0&, ByVal 0&, 1&, _
NORMAL_PRIORITY_CLASS, ByVal 0&, sNull, sInfo, pInfo)

but alas, the 'equivelant' vb.Net code translated as:


lngReply = CreateProcess(sNull, txtStart.Text, sa, sa, 1, _
NORMAL_PRIORITY_CLASS, 0, sNull, sInfo, pInfo)


does not execute cleanly. That is, although the CreateProcess returns 'successfully', and populates the sInfo structure with valid data, the application (e.g. c:\windows\notepad.exe) 'fails during initialisation' and terminates.

The only 'meaningful' difference between the working vb6 and non-working vb.net code, is the substitution of vb6's 'As Any' Win32API declaration parameterss with 'AS Securities_Attributes' structures, which I have defined thus:

Structure SECURITY_ATTRIBUTES
Dim nLength As Integer
Dim lpSecurityDescriptor As Integer
Dim bInheritHandle As Integer
End Structure

and are passed-in called 'sa', as noted above.

Please, can someone offer either a correction for my error, or a good code example / reference for calling CreateProcess from vb.net.

NB: I need to use CreateProcess rather than the Process component in the managed code, as I need to set some 'lower level' start info parameters, which I can only get at using the API directly :(

Many Thanks in advance,
Paul.
 
C

Chris Tacke, eMVP

Since the security attributes are not supported in CE, just pass it null or
zero. You might consider looking at the OpenNETCF Process class which wraps
this (and a whole lot more).

www.opennetcf.org

-Chris


paul schenk via .NET 247 said:
(Type your message here)

--------------------------------
From: paul schenk

Hi All :)

Would be grateful of advice please. I have code in VB6 working as follows:

lngReply = CreateProcess(sNull, txtStart, ByVal 0&, ByVal 0&, 1&, _
NORMAL_PRIORITY_CLASS, ByVal 0&, sNull, sInfo, pInfo)

but alas, the 'equivelant' vb.Net code translated as:


lngReply = CreateProcess(sNull, txtStart.Text, sa, sa, 1, _
NORMAL_PRIORITY_CLASS, 0, sNull, sInfo, pInfo)


does not execute cleanly. That is, although the CreateProcess returns
'successfully', and populates the sInfo structure with valid data, the
application (e.g. c:\windows\notepad.exe) 'fails during initialisation' and
terminates.
The only 'meaningful' difference between the working vb6 and non-working
vb.net code, is the substitution of vb6's 'As Any' Win32API declaration
parameterss with 'AS Securities_Attributes' structures, which I have defined
thus:
Structure SECURITY_ATTRIBUTES
Dim nLength As Integer
Dim lpSecurityDescriptor As Integer
Dim bInheritHandle As Integer
End Structure

and are passed-in called 'sa', as noted above.

Please, can someone offer either a correction for my error, or a good code
example / reference for calling CreateProcess from vb.net.
NB: I need to use CreateProcess rather than the Process component in the
managed code, as I need to set some 'lower level' start info parameters,
which I can only get at using the API directly :(
 
G

Guest

Hi Chris,

Many thanks for your reply. Unfortunately, I am using regular vb.net in VS2003. Confusion was caused by me posting on your ce board - my apologies.

However, the problem remains.... as passing 0 or null doesn't fix things :(

Sorry to be cheeky but i'm still at a loss. Frankly, honestly, I have not seen ANYWHERE yet, after several days looking, of ANY example - using vb.Net - of a CreateProcess function that works - not in MSDN / KB, nor any of the multitude of 'guru' sites.....

If you or anyone knows different, I would be grateful in the extreme for a simple hello world example of CreateProcess, that actually works in vb.Net

Appreciative Thanks,
Paul.




Chris Tacke said:
Since the security attributes are not supported in CE, just pass it null or
zero. You might consider looking at the OpenNETCF Process class which wraps
this (and a whole lot more).

www.opennetcf.org

-Chris


paul schenk via .NET 247 said:
(Type your message here)

--------------------------------
From: paul schenk

Hi All :)

Would be grateful of advice please. I have code in VB6 working as follows:

lngReply = CreateProcess(sNull, txtStart, ByVal 0&, ByVal 0&, 1&, _
NORMAL_PRIORITY_CLASS, ByVal 0&, sNull, sInfo, pInfo)

but alas, the 'equivelant' vb.Net code translated as:


lngReply = CreateProcess(sNull, txtStart.Text, sa, sa, 1, _
NORMAL_PRIORITY_CLASS, 0, sNull, sInfo, pInfo)


does not execute cleanly. That is, although the CreateProcess returns
'successfully', and populates the sInfo structure with valid data, the
application (e.g. c:\windows\notepad.exe) 'fails during initialisation' and
terminates.
The only 'meaningful' difference between the working vb6 and non-working
vb.net code, is the substitution of vb6's 'As Any' Win32API declaration
parameterss with 'AS Securities_Attributes' structures, which I have defined
thus:
Structure SECURITY_ATTRIBUTES
Dim nLength As Integer
Dim lpSecurityDescriptor As Integer
Dim bInheritHandle As Integer
End Structure

and are passed-in called 'sa', as noted above.

Please, can someone offer either a correction for my error, or a good code
example / reference for calling CreateProcess from vb.net.
NB: I need to use CreateProcess rather than the Process component in the
managed code, as I need to set some 'lower level' start info parameters,
which I can only get at using the API directly :(
 
G

Guest

Hi Chris,

Many thanks for your reply. Unfortunately, I am using regular vb.net in VS2003. Confusion was caused by me posting on your ce board - my apologies.

However, the problem remains.... as passing 0 or null doesn't fix things :(

Sorry to be cheeky but i'm still at a loss. Frankly, honestly, I have not seen ANYWHERE yet, after several days looking, of ANY example - using vb.Net - of a CreateProcess function that works - not in MSDN / KB, nor any of the multitude of 'guru' sites.....

If you or anyone knows different, I would be grateful in the extreme for a simple hello world example of CreateProcess, that actually works in vb.Net

Appreciative Thanks,
Paul.

Chris Tacke said:
Since the security attributes are not supported in CE, just pass it null or
zero. You might consider looking at the OpenNETCF Process class which wraps
this (and a whole lot more).

www.opennetcf.org

-Chris


paul schenk via .NET 247 said:
(Type your message here)

--------------------------------
From: paul schenk

Hi All :)

Would be grateful of advice please. I have code in VB6 working as follows:

lngReply = CreateProcess(sNull, txtStart, ByVal 0&, ByVal 0&, 1&, _
NORMAL_PRIORITY_CLASS, ByVal 0&, sNull, sInfo, pInfo)

but alas, the 'equivelant' vb.Net code translated as:


lngReply = CreateProcess(sNull, txtStart.Text, sa, sa, 1, _
NORMAL_PRIORITY_CLASS, 0, sNull, sInfo, pInfo)


does not execute cleanly. That is, although the CreateProcess returns
'successfully', and populates the sInfo structure with valid data, the
application (e.g. c:\windows\notepad.exe) 'fails during initialisation' and
terminates.
The only 'meaningful' difference between the working vb6 and non-working
vb.net code, is the substitution of vb6's 'As Any' Win32API declaration
parameterss with 'AS Securities_Attributes' structures, which I have defined
thus:
Structure SECURITY_ATTRIBUTES
Dim nLength As Integer
Dim lpSecurityDescriptor As Integer
Dim bInheritHandle As Integer
End Structure

and are passed-in called 'sa', as noted above.

Please, can someone offer either a correction for my error, or a good code
example / reference for calling CreateProcess from vb.net.
NB: I need to use CreateProcess rather than the Process component in the
managed code, as I need to set some 'lower level' start info parameters,
which I can only get at using the API directly :(
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top