Dear Herfried,
Many thanks for your reply.
I need to get to the lpDesktop parameter of the STARTINFO
class - but this is not exposed in the 'managed
wrappers', so sadly, as I need to launch interactive
processes out of a windows service application, i have to
resort to the sordid business of the api ;-)
My working vb6 code is as follows:
API Declaration:
Private Declare Function CreateProcess Lib "kernel32"
Alias "CreateProcessA"
(ByVal lpApplicationName As String, ByVal lpCommandLine
As String, lpProcessAttributes As Any, lpThreadAttributes
As Any, ByVal bInheritHandles As Long, ByVal
dwCreationFlags As Any, lpEnvironment As Any, ByVal
lpCurrentDriectory As String, lpStartupInfo As
STARTUPINFO, lpProcessInformation As
PROCESS_INFORMATION) As Long
Function Call:
lngReply = CreateProcess(sNull, txtStart, ByVal 0&, ByVal
0&, 1&, NORMAL_PRIORITY_CLASS, ByVal 0&, sNull, sInfo,
pInfo)
This works just as desired, without problem.
The vb.net 'upgrade / migration' wizard converts the code
to as follows:
Private Declare Function CreateProcess Lib "kernel32"
Alias "CreateProcessA" (ByVal lpApplicationName As
String, ByVal lpCommandLine As String, ByRef
lpProcessAttributes As SECURITY_ATTRIBUTES, ByRef
lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal
bInheritHandles As Integer, ByVal dwCreationFlags As
Integer, ByRef lpEnvironment As Object, ByVal
lpCurrentDriectory As String, ByRef lpStartupInfo As
STARTUPINFO, ByRef lpProcessInformation As
PROCESS_INFORMATION) As Integer
NB: The lpEnvironment used to be an 'As Any' parameter, I
have tried it out as an object, as a string and as an
integer - all to no avail.
The function call I use is:
lngReply = CreateProcess(sNull, txtStart.Text, sa, sa, 1,
NORMAL_PRIORITY_CLASS, 0, sNull, sInfo, pInfo)
I know this is cheeky, but unless you can see a directly
observable error in my code, and if you believe that
CreateProcess can work in vb.net, please, all I need is
one simple self contained "hello world" example of vb.net
code that will work in isolation, successfully employing
a call to CreateProcess. I don't need my specific problem
fixing in my context - I am happy to apply the general to
my own specific needs - but as yet THERE HAS BEEN NO
EXAMPLE AT ALL in vb.net where CreateProcess executes
cleanly !
Please know that I appreciate your or anyones valuable
time and effort on my behalf in this instance. I have to
say, a sucesffuly answer though would be a treasure -
simply because as yet one does not seem to exist on the
internet.
Many many thanks in advance,
Paul.
[quoted text, click to view] >-----Original Message-----
>* "Paul Schenk" <pas@rttracking.com> scripsit:
>> 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)
>
>Did you have a look at the 'Process'
and 'ProcessStartInfo' classes?
>
>Post your declare of 'CreateProcess'.
>
>--
>Herfried K. Wagner [MVP]
><URL:
http://dotnet.mvps.org/> >.