By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,273 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,273 IT Pros & Developers. It's quick & easy.

Where have all the vb.Net experts Gone ???

P: n/a
Dear All,

Please, this is not meant to be offensive - but it is a challenge !!!

I have posted on over a dozen so called 'vb.net' expert / blog sites - in the vain hope of finding a complete, accurate and ACTUALLY FUNCTIONING snippet to demonsrate a successful api call to CreateProcess() using VB.NET.

So far NO ONE has taken up the challenge - not even MSDN or MS personnel. I have code that works in vb6, I have dilligently tried to convert to vb.net / AND look at the multitude of innacurate / incomplete / unsuccessful snippets of vb / c# / c++ in the hope of finding why my efforts in .Net fail - but sadly to no avail.

As far as I can tell, MS has removed the ability for a vb-er to use CreateProcess in basic now :( Please, PLEASE prove me wrong, and point me in the direction of light and happiness.

I am happy to go into detail if anyone is up for the challenge.....

thanks and regards in advance,
paul.
Jul 21 '05 #1
Share this Question
Share on Google+
22 Replies


P: n/a
Not sure where everyone has gone out there. Many of the experts sites offer
incentives, in the form of points, to get people to lend their time. Most of
these sites never materialized actually paying anyone for these points, as
the model did not bring in the millions they had planned. In these cases,
many experts have a variety of forums to donate their time, so why help
someone else make money if you are not going to be rewarded. For me,
personally, I find it much easier to come in her than check a website.

For true "processes", you have System.Diagnostics.Process. While it is
designed to watch a running process, you have the option to use the Start()
method to start an executable. For example:

Process.Start("IExplore.exe")

will start Internet Explorer.

Rather than follow up with the details here, I would post in
microsoft.public.dotnet.languages.vb, as the general group is not normally
hit heavily by subject matter experts.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
"ByteSize" <By******@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
Dear All,

Please, this is not meant to be offensive - but it is a challenge !!!

I have posted on over a dozen so called 'vb.net' expert / blog sites - in the vain hope of finding a complete, accurate and ACTUALLY FUNCTIONING
snippet to demonsrate a successful api call to CreateProcess() using VB.NET.
So far NO ONE has taken up the challenge - not even MSDN or MS personnel. I have code that works in vb6, I have dilligently tried to convert to vb.net
/ AND look at the multitude of innacurate / incomplete / unsuccessful
snippets of vb / c# / c++ in the hope of finding why my efforts in .Net
fail - but sadly to no avail.
As far as I can tell, MS has removed the ability for a vb-er to use CreateProcess in basic now :( Please, PLEASE prove me wrong, and point me
in the direction of light and happiness.
I am happy to go into detail if anyone is up for the challenge.....

thanks and regards in advance,
paul.

Jul 21 '05 #2

P: n/a
Hi Gregory,

Thanks for that quick answer in this newsgroup, we see you not often
answering in this newsgroup.
as the general group is not normally hit heavily by subject matter experts.


It could have been written as well a little bit else, you mean of course
with that subject matter experts I hope as well Jon Skeet, Bill Ryan, Miha,
Kevin Yu and others who are active in this newsgroup?

What does not mean that telling that the vb.Net experts are in the
language.vb newsgroup is incorrect.

Cor

Jul 21 '05 #3

P: n/a
Hi ByteSize,

Beneath three snippets.

(No API call, when there is a good dotNet class we try to avoid them using
Vb.net and there are so much dotNet classes that nobody seems to know them
all).

However when you have more vb net language questions, you can ask them in
microsoft.public.dotnet.languages.vb

(Although this is except the last almost exact the same in C#)

I hope this helps?

Cor

\\\
Dim p As New System.Diagnostics.ProcessStartInfo()
p.Verb = "print"
p.WindowStyle = ProcessWindowStyle.Hidden
p.FileName = "C:\filename.doc"
p.UseShellExecute = True
System.Diagnostics.Process.Start(p)
///
\\\
Dim p As New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = False
p.StartInfo.Arguments = "\?"
p.StartInfo.WorkingDirectory = "C:\mydir"
p.StartInfo.FileName = "myProg.exe"
p.Start()
///
\\\
Dim p As New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = True
p.StartInfo.Arguments = myargumentstring
p.StartInfo.WorkingDirectory = myworkdirectorystring
p.StartInfo.FileName =C:\myprogram
p.Start()
Dim sr As IO.StreamReader = p.StandardOutput
Dim sb As New System.Text.StringBuilder("")
Dim input As Integer = sr.Read
Do Until input = -1
sb.Append(ChrW(input))
input = sr.Read
Loop
///
Jul 21 '05 #4

P: n/a
Hi ByteSize

What do you mean
And so the challenge to the entire vb.net community of 'experts' remains

open and unanswered..... no one is able to get CreateProcess working in
vb.net - not even to start a measly single instance of
c:\windows\notepad.exe even..... I have tried and failed for days..... and
no one else has yet managed it....... so, it would appear to be a challenge
unanswerable.... . .... even by the best of the best ..... ;-)

I do not understand you. This runs very nice and is so very simple.

\\\
Public Class Main
Public Shared Sub Main()
Dim p As New Process
p.StartInfo.UseShellExecute = True
p.StartInfo.Arguments = "c:\windows\win.ini"
p.StartInfo.FileName = "notepad.exe"
p.Start()
End Sub
End Class
///

Cor
Jul 21 '05 #5

P: n/a
Dearest Cor,

This is why I said "only experts need apply".

YOU are using the Process object, and setting JUST SOME OF the StartInfo parameters. I HOWEVER, NEED to access the lpDesktop parameter of the StartInfo class. THE PROBLEM IS that the managed code base does NOT IMPLEMENT that part of the api. Yesssss, it has the obvious filename, commandline, arguments, redirectin/output parameters etc, etc, BUT IT IS MISSING half of the full set of parameters from the base api, for example, it does not implement the lpDesktop parameter of the StartInfo class - which is the ONE I NEED to set in order to enable a windows service application to launch an interactive application.

So, this is why the challenge remains unanswered. If / when anybody, anywhere, can offer-up a working snippet of code that demonstrates the use of the CreateProcess api function call in vb.net (i cannot use any simpler or more logical english than that), then only then will the challenge be bet with success and accolades of greatness to the provider.

If another 'expert' reads my posts and goes on to recomend I take a peek at the Process object - I will do a virtual puk*. Sorry to sound peevish - I know you mean well, and I am grateful for your thoughts, but......

warm regards,
paul.

"Cor Ligthert" wrote:
Hi ByteSize

What do you mean
And so the challenge to the entire vb.net community of 'experts' remains

open and unanswered..... no one is able to get CreateProcess working in
vb.net - not even to start a measly single instance of
c:\windows\notepad.exe even..... I have tried and failed for days..... and
no one else has yet managed it....... so, it would appear to be a challenge
unanswerable.... . .... even by the best of the best ..... ;-)

I do not understand you. This runs very nice and is so very simple.

\\\
Public Class Main
Public Shared Sub Main()
Dim p As New Process
p.StartInfo.UseShellExecute = True
p.StartInfo.Arguments = "c:\windows\win.ini"
p.StartInfo.FileName = "notepad.exe"
p.Start()
End Sub
End Class
///

Cor

Jul 21 '05 #6

P: n/a
Why only experts?
Where is the snippet of VB6 code that works in VB6 and your non working
translation to VB.net.
I am not familiar with CreateProcess API but if it works in VB6 it should
work in VB.net.

--
Mick Doherty
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
Jul 21 '05 #7

P: n/a
On Mon, 21 Jun 2004 05:18:02 -0700, "ByteSize" <By******@discussions.microsoft.com> wrote:

Dear All,

Please, this is not meant to be offensive - but it is a challenge !!!

I have posted on over a dozen so called 'vb.net' expert / blog sites - in the vain hope of finding a complete, accurate and ACTUALLY FUNCTIONING snippet to demonsrate a successful api call to CreateProcess() using VB.NET.

So far NO ONE has taken up the challenge - not even MSDN or MS personnel. I have code that works in vb6, I have dilligently tried to convert to vb.net / AND look at the multitude of innacurate / incomplete / unsuccessful snippets of vb / c# / c++ in the hope of finding why my efforts in .Net fail - but sadly to no avail.

As far as I can tell, MS has removed the ability for a vb-er to use CreateProcess in basic now :( Please, PLEASE prove me wrong, and point me in the direction of light and happiness.

I am happy to go into detail if anyone is up for the challenge.....

thanks and regards in advance,
paul.

Processes spawned from services typically run in the background as services. That is by design. Why
would you launch an interactive application from a service when it's highly likely that no one will
be available to respond to it?

AFAIK there is no native support for this under the .NET framework.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Jul 21 '05 #8

P: n/a
Hi Paul Schenk,

Are you the same one who asked some weeks ago how he could use his
commodore64 or something like that with VB.net?

Here a link to learn something about VBNet and Api's

http://msdn.microsoft.com/library/de...l/win32map.asp

Using Api's is exactly not using VBNet, so you are almost rigth, there are
no VBNet *Api* experts.

There are people like you who only can solve a multiply operation by a
repeated add in a loop, others take more modern instructions for it.

For the rest the same as Mick wrote.

Here you have a very simple API (which is not real VBNet) in this structure
should every API go.
\\\
Public Structure SYSTEMTIME
Public Year As Short
Public Month As Short
Public DayOfWeek As Short
Public Day As Short
Public Hour As Short
Public Minute As Short
Public Second As Short
Public Milliseconds As Short
End Structure
Public Declare Sub GetSystemTime _
Lib "kernel32" Alias "GetSystemTime" _
(ByRef lpSystemTime As SYSTEMTIME)
Public Declare Sub SetSystemTime _
Lib "kernel32" Alias "SetSystemTime" _
(ByRef lpSystemTime As SYSTEMTIME)
Private Sub Form1_Load(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim systime As SYSTEMTIME
GetSystemTime(systime)
MessageBox.Show(systime.Year.ToString())
MessageBox.Show(Now.ToString("MM/yyyy"))
End Sub
///
Cor
Jul 21 '05 #9

P: n/a
Hi Charles,

What has that to do with VBNnet
(I am the last who would tell you are no VBNet expert of course).

Cor

I'm no expert, but try the attached.

HTH

Charles

Jul 21 '05 #10

P: n/a
On Mon, 21 Jun 2004 05:18:02 -0700, ByteSize wrote:
Dear All,

Please, this is not meant to be offensive - but it is a challenge !!!

I have posted on over a dozen so called 'vb.net' expert / blog sites - in the vain hope of finding a complete, accurate and ACTUALLY FUNCTIONING snippet to demonsrate a successful api call to CreateProcess() using VB.NET.

So far NO ONE has taken up the challenge - not even MSDN or MS personnel. I have code that works in vb6, I have dilligently tried to convert to vb.net / AND look at the multitude of innacurate / incomplete / unsuccessful snippets of vb / c# / c++ in the hope of finding why my efforts in .Net fail - but sadly to no avail.

As far as I can tell, MS has removed the ability for a vb-er to use CreateProcess in basic now :( Please, PLEASE prove me wrong, and point me in the direction of light and happiness.

I am happy to go into detail if anyone is up for the challenge.....

thanks and regards in advance,
paul.


I am not an expert and have not used CreateProcess, but here is code from a
Win32 library that I ran across. It is written in C#, but perhaps it will
help you. If you would like the entire library, which has many many Win32
api fuctions, I would be happy to post/email it. It is about 88K zipped.
Feel free to e-mail me. Look at my signature for my email instructions

using HANDLE = System.IntPtr;
using HWND = System.IntPtr;

public struct STARTUPINFO
{
public int cb;
public string lpReserved;
public string lpDesktop;
public string lpTitle;
public int dwX;
public int dwY;
public int dwXSize;
public int dwYSize;
public int dwXCountChars;
public int dwYCountChars;
public int dwFillAttribute;
public int dwFlags;
public short wShowWindow;
public short cbReserved2;
public int lpReserved2;
public HANDLE hStdInput;
public HANDLE hStdOutput;
public HANDLE hStdError;
}

[DllImport("kernel32")] public static extern int CreateProcess(string
lpApplicationName, string lpCommandLine, ref SECURITY_ATTRIBUTES
lpProcessAttributes, ref SECURITY_ATTRIBUTES lpThreadAttributes, int
bInheritHandles, int dwCreationFlags, IntPtr lpEnvironment, string
lpCurrentDriectory, ref STARTUPINFO lpStartupInfo, ref PROCESS_INFORMATION
lpProcessInformation);

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Jul 21 '05 #11

P: n/a
Dear Cor,

Rather than pontificating, either answer the question as posed, or a valid alternative solution. The reason I am asking to run the old api stuff, rather than the shiny new managed code (which i adore and use extensively) is that MS has not encapsulated the full startinfo class parameters in the wrapper - and unfortunately I need to get to them.

Why ? Because i need to start applications on remote machines, for end users unable to start them themselves (don't ask - its a long story), they may not even be there, yet I stiull need to throw up a GUI Now, for me to be able to run an application without relying on the user being logged in, i need to run my base app as a service. This no-gui non-interactive service app needs to start interactive GUI apps. Now, service apps running under local system account which mine are, don't get the visible desktop by default, and must spawn their processes ONLY AFTER setting the lpdesktop parameter of the startinfo class appropriately.

So, this is why i say the managed code is insufficient here. Not cos i don't like it cos i do. Not cos i don't understand it cos i do very well. It is insufficient becuase MS has not done a full implementation and I have to use the raw api whilst having an app in vb..net.

So, what I need is a true expert, who can understand and appreciate the problem AS POSED, and respond with their kind hearts if they are able.

Many thanks in advance,

paul.

p.s. Cor, as for getting by in real world programing without using the api, and yet still wishing to take advantage of all that is excellent vb.net, I assume you program nothing more than office apps ? or nothing 'out there' in a professional challenging real world. I'm a little sorry to be mean with my statement, but frankly, you've whittered-on whilst a) not understanding the problem in the first place (presumably from not reading my posts fully) and b) Not been helpful (see point about not reading my posts). Really though, you do seem a decent chap, so lets call it a truce eh ? All I wish is an accurate answer to my fair and valid problem. Thanks, p.

"Cor Ligthert" wrote:
Hi Paul Schenk,

Are you the same one who asked some weeks ago how he could use his
commodore64 or something like that with VB.net?

Here a link to learn something about VBNet and Api's

http://msdn.microsoft.com/library/de...l/win32map.asp

Using Api's is exactly not using VBNet, so you are almost rigth, there are
no VBNet *Api* experts.

There are people like you who only can solve a multiply operation by a
repeated add in a loop, others take more modern instructions for it.

For the rest the same as Mick wrote.

Here you have a very simple API (which is not real VBNet) in this structure
should every API go.
\\\
Public Structure SYSTEMTIME
Public Year As Short
Public Month As Short
Public DayOfWeek As Short
Public Day As Short
Public Hour As Short
Public Minute As Short
Public Second As Short
Public Milliseconds As Short
End Structure
Public Declare Sub GetSystemTime _
Lib "kernel32" Alias "GetSystemTime" _
(ByRef lpSystemTime As SYSTEMTIME)
Public Declare Sub SetSystemTime _
Lib "kernel32" Alias "SetSystemTime" _
(ByRef lpSystemTime As SYSTEMTIME)
Private Sub Form1_Load(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim systime As SYSTEMTIME
GetSystemTime(systime)
MessageBox.Show(systime.Year.ToString())
MessageBox.Show(Now.ToString("MM/yyyy"))
End Sub
///
Cor

Jul 21 '05 #12

P: n/a
Dear Paul,

I could give you the very long story as to why I need to start interactive apps from a local system service - but lets just say I do, because I do - don't forget that it is a VERY LARGE WORLD OUT THERE, and problems DO COME in varieties. This is my problem for real. Now, what was that you said about a possible solution to the problem as posed ?

Many thaks,
Paul.

"Paul Clement" wrote:
On Mon, 21 Jun 2004 05:18:02 -0700, "ByteSize" <By******@discussions.microsoft.com> wrote:

¤ Dear All,
¤
¤ Please, this is not meant to be offensive - but it is a challenge !!!
¤
¤ I have posted on over a dozen so called 'vb.net' expert / blog sites - in the vain hope of finding a complete, accurate and ACTUALLY FUNCTIONING snippet to demonsrate a successful api call to CreateProcess() using VB.NET.
¤
¤ So far NO ONE has taken up the challenge - not even MSDN or MS personnel. I have code that works in vb6, I have dilligently tried to convert to vb.net / AND look at the multitude of innacurate / incomplete / unsuccessful snippets of vb / c# / c++ in the hope of finding why my efforts in .Net fail - but sadly to no avail.
¤
¤ As far as I can tell, MS has removed the ability for a vb-er to use CreateProcess in basic now :( Please, PLEASE prove me wrong, and point me in the direction of light and happiness.
¤
¤ I am happy to go into detail if anyone is up for the challenge.....
¤
¤ thanks and regards in advance,
¤ paul.

Processes spawned from services typically run in the background as services. That is by design. Why
would you launch an interactive application from a service when it's highly likely that no one will
be available to respond to it?

AFAIK there is no native support for this under the .NET framework.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)

Jul 21 '05 #13

P: n/a
Hi Chris,

Many thanks. I have seen similar and just oh so wish MS would provide a similar example for vb.net, becasue the standard c# to vb.net, (for the c# examples), and the vc++ to vb.net conversions (for the c++ examples I have found) as well as the vb6 to vb.net translations i have performed (for the working vb6 examples i have) none of them have eneded up executing correctly in vb.net :( I am sure it is my dim limited abilities that is failing me, and as of yet, I have not been able to find - nor any expert able to offer - a simple clean working example for vb.net :(

I appreciate you thought though,

regards,
paul.

"Chris Dunaway" <"dunawayc[[at]_lunchmeat" wrote:
On Mon, 21 Jun 2004 05:18:02 -0700, ByteSize wrote:
Dear All,

Please, this is not meant to be offensive - but it is a challenge !!!

I have posted on over a dozen so called 'vb.net' expert / blog sites - in the vain hope of finding a complete, accurate and ACTUALLY FUNCTIONING snippet to demonsrate a successful api call to CreateProcess() using VB.NET.

So far NO ONE has taken up the challenge - not even MSDN or MS personnel. I have code that works in vb6, I have dilligently tried to convert to vb.net / AND look at the multitude of innacurate / incomplete / unsuccessful snippets of vb / c# / c++ in the hope of finding why my efforts in .Net fail - but sadly to no avail.

As far as I can tell, MS has removed the ability for a vb-er to use CreateProcess in basic now :( Please, PLEASE prove me wrong, and point me in the direction of light and happiness.

I am happy to go into detail if anyone is up for the challenge.....

thanks and regards in advance,
paul.


I am not an expert and have not used CreateProcess, but here is code from a
Win32 library that I ran across. It is written in C#, but perhaps it will
help you. If you would like the entire library, which has many many Win32
api fuctions, I would be happy to post/email it. It is about 88K zipped.
Feel free to e-mail me. Look at my signature for my email instructions

using HANDLE = System.IntPtr;
using HWND = System.IntPtr;

public struct STARTUPINFO
{
public int cb;
public string lpReserved;
public string lpDesktop;
public string lpTitle;
public int dwX;
public int dwY;
public int dwXSize;
public int dwYSize;
public int dwXCountChars;
public int dwYCountChars;
public int dwFillAttribute;
public int dwFlags;
public short wShowWindow;
public short cbReserved2;
public int lpReserved2;
public HANDLE hStdInput;
public HANDLE hStdOutput;
public HANDLE hStdError;
}

[DllImport("kernel32")] public static extern int CreateProcess(string
lpApplicationName, string lpCommandLine, ref SECURITY_ATTRIBUTES
lpProcessAttributes, ref SECURITY_ATTRIBUTES lpThreadAttributes, int
bInheritHandles, int dwCreationFlags, IntPtr lpEnvironment, string
lpCurrentDriectory, ref STARTUPINFO lpStartupInfo, ref PROCESS_INFORMATION
lpProcessInformation);

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.

Jul 21 '05 #14

P: n/a
Hi Cor

I don't think I understand you. I attached a working VB.NET application that
launches notepad using the API as the OP requested.

Have I missed something?

Charles
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:O9****************@tk2msftngp13.phx.gbl...
Hi Charles,

What has that to do with VBNnet
(I am the last who would tell you are no VBNet expert of course).

Cor

I'm no expert, but try the attached.

HTH

Charles


Jul 21 '05 #15

P: n/a
I started to suspect that something was awry from Cor's reply. Here are the
relevant bits.

Create a new Windows Forms application, and copy the code extracts into a
module and form named accordingly.

<Module1>
Option Explicit On
Option Strict On

Imports System.Runtime.InteropServices

Module Module1

Public Const NORMAL_PRIORITY_CLASS As Integer = &H20

Public Structure SECURITY_ATTRIBUTES
Dim nLength As Integer
Dim lpSecurityDescriptor As IntPtr
Dim bInheritHandle As Boolean
End Structure

Public Structure STARTUPINFO
Dim cb As Integer
Dim lpReserved As String
Dim lpDesktop As String
Dim lpTitle As String
Dim dwX As Integer
Dim dwY As Integer
Dim dwXSize As Integer
Dim dwYSize As Integer
Dim dwXCountChars As Integer
Dim dwYCountChars As Integer
Dim dwFillAttribute As Integer
Dim dwFlags As Integer
Dim wShowWindow As Int16
Dim cbReserved2 As Int16
Dim lpReserved2 As Byte
Dim hStdInput As IntPtr
Dim hStdOutput As IntPtr
Dim hStdError As IntPtr
End Structure

Public Structure PROCESS_INFORMATION
Dim hProcess As IntPtr
Dim hThread As IntPtr
Dim dwProcessId As Integer
Dim dwThreadId As IntPtr
End Structure

<DllImport("kernel32.dll", SetlastError:=True, CharSet:=CharSet.Auto)> _
Public Function CreateProcess(ByVal lpApplicationName As String, _
ByVal lpCommandLine As String, _
ByRef lpProcessAttributes As SECURITY_ATTRIBUTES, _
ByRef lpThreadAttributes As SECURITY_ATTRIBUTES, _
ByVal bInheritHandles As Boolean, _
ByVal dwCreationFlags As Integer, _
ByVal lpEnvironment As IntPtr, _
ByVal lpCurrentDirectory As IntPtr, _
ByRef lpStartupInfo As STARTUPINFO, _
ByRef lpProcessInformation As PROCESS_INFORMATION) As Boolean
End Function

End Module
</Module1>

<Form1>
Option Explicit On
Option Strict On

Imports System.Runtime.InteropServices

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Name = "Form1"
Me.Text = "Form1"

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim sa As SECURITY_ATTRIBUTES
Dim si As STARTUPINFO
Dim pi As PROCESS_INFORMATION

sa.nLength = Marshal.SizeOf(sa)
sa.lpSecurityDescriptor = IntPtr.Zero

si.cb = Marshal.SizeOf(si)

Module1.CreateProcess(Nothing, "notepad.exe", sa, sa, True,
NORMAL_PRIORITY_CLASS, IntPtr.Zero, IntPtr.Zero, si, pi)

End Sub
End Class
</Form1>

HTH

Charles
"ByteSize" <By******@discussions.microsoft.com> wrote in message
news:02**********************************@microsof t.com...
Hi Charles,

Thanks for the reply. Sorry to be dim at my end, but, What Attached ? I can't see anything, i'm accessing this newgroup via IExplorer on MS's MSDN
vb newsgroups website - rather than though a mail client or similar.
Thanks in advance for your effort,
paul.
"Charles Law" wrote:
I'm no expert, but try the attached.

HTH

Charles
"ByteSize" <By******@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
Dear All,

Please, this is not meant to be offensive - but it is a challenge !!!

I have posted on over a dozen so called 'vb.net' expert / blog sites - in
the vain hope of finding a complete, accurate and ACTUALLY FUNCTIONING
snippet to demonsrate a successful api call to CreateProcess() using VB.NET.
So far NO ONE has taken up the challenge - not even MSDN or MS

personnel. I have code that works in vb6, I have dilligently tried to convert to vb.net / AND look at the multitude of innacurate / incomplete / unsuccessful
snippets of vb / c# / c++ in the hope of finding why my efforts in .Net
fail - but sadly to no avail.

As far as I can tell, MS has removed the ability for a vb-er to use

CreateProcess in basic now :( Please, PLEASE prove me wrong, and point me in the direction of light and happiness.

I am happy to go into detail if anyone is up for the challenge.....

thanks and regards in advance,
paul

Jul 21 '05 #16

P: n/a
VOTE CHARLES LAW - HE'S THE MAN !!!!!

Dear Charles,

Top work - many thanks. Ask a straight question, of a straight talking guy, and what did I get - a straight answer - excellent, top stuff, thank you.

Your code is indeed a clean 'createprocess' solution for vb.net - and you are the first / fastest to provide it - so this rates you as the most expert of experts :), if I haven't said thank you already, thank you.

Now, all I need to do is get back to my tricky app. and see how I can make my bigger picture work using your fabulous snippest of snippets........

warmest regards,
paul.

"Charles Law" wrote:
I started to suspect that something was awry from Cor's reply. Here are the
relevant bits.

Create a new Windows Forms application, and copy the code extracts into a
module and form named accordingly.

<Module1>
Option Explicit On
Option Strict On

Imports System.Runtime.InteropServices

Module Module1

Public Const NORMAL_PRIORITY_CLASS As Integer = &H20

Public Structure SECURITY_ATTRIBUTES
Dim nLength As Integer
Dim lpSecurityDescriptor As IntPtr
Dim bInheritHandle As Boolean
End Structure

Public Structure STARTUPINFO
Dim cb As Integer
Dim lpReserved As String
Dim lpDesktop As String
Dim lpTitle As String
Dim dwX As Integer
Dim dwY As Integer
Dim dwXSize As Integer
Dim dwYSize As Integer
Dim dwXCountChars As Integer
Dim dwYCountChars As Integer
Dim dwFillAttribute As Integer
Dim dwFlags As Integer
Dim wShowWindow As Int16
Dim cbReserved2 As Int16
Dim lpReserved2 As Byte
Dim hStdInput As IntPtr
Dim hStdOutput As IntPtr
Dim hStdError As IntPtr
End Structure

Public Structure PROCESS_INFORMATION
Dim hProcess As IntPtr
Dim hThread As IntPtr
Dim dwProcessId As Integer
Dim dwThreadId As IntPtr
End Structure

<DllImport("kernel32.dll", SetlastError:=True, CharSet:=CharSet.Auto)> _
Public Function CreateProcess(ByVal lpApplicationName As String, _
ByVal lpCommandLine As String, _
ByRef lpProcessAttributes As SECURITY_ATTRIBUTES, _
ByRef lpThreadAttributes As SECURITY_ATTRIBUTES, _
ByVal bInheritHandles As Boolean, _
ByVal dwCreationFlags As Integer, _
ByVal lpEnvironment As IntPtr, _
ByVal lpCurrentDirectory As IntPtr, _
ByRef lpStartupInfo As STARTUPINFO, _
ByRef lpProcessInformation As PROCESS_INFORMATION) As Boolean
End Function

End Module
</Module1>

<Form1>
Option Explicit On
Option Strict On

Imports System.Runtime.InteropServices

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Name = "Form1"
Me.Text = "Form1"

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim sa As SECURITY_ATTRIBUTES
Dim si As STARTUPINFO
Dim pi As PROCESS_INFORMATION

sa.nLength = Marshal.SizeOf(sa)
sa.lpSecurityDescriptor = IntPtr.Zero

si.cb = Marshal.SizeOf(si)

Module1.CreateProcess(Nothing, "notepad.exe", sa, sa, True,
NORMAL_PRIORITY_CLASS, IntPtr.Zero, IntPtr.Zero, si, pi)

End Sub
End Class
</Form1>

HTH

Charles
"ByteSize" <By******@discussions.microsoft.com> wrote in message
news:02**********************************@microsof t.com...
Hi Charles,

Thanks for the reply. Sorry to be dim at my end, but, What Attached ? I

can't see anything, i'm accessing this newgroup via IExplorer on MS's MSDN
vb newsgroups website - rather than though a mail client or similar.

Thanks in advance for your effort,
paul.
"Charles Law" wrote:
I'm no expert, but try the attached.

HTH

Charles
"ByteSize" <By******@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
> Dear All,
>
> Please, this is not meant to be offensive - but it is a challenge !!!
>
> I have posted on over a dozen so called 'vb.net' expert / blog sites - in the vain hope of finding a complete, accurate and ACTUALLY FUNCTIONING
snippet to demonsrate a successful api call to CreateProcess() using VB.NET. >
> So far NO ONE has taken up the challenge - not even MSDN or MS personnel. I have code that works in vb6, I have dilligently tried to convert to vb.net / AND look at the multitude of innacurate / incomplete / unsuccessful
snippets of vb / c# / c++ in the hope of finding why my efforts in .Net
fail - but sadly to no avail.
>
> As far as I can tell, MS has removed the ability for a vb-er to use
CreateProcess in basic now :( Please, PLEASE prove me wrong, and point me in the direction of light and happiness.
>
> I am happy to go into detail if anyone is up for the challenge.....
>
> thanks and regards in advance,
> paul


Jul 21 '05 #17

P: n/a
Charles Law has supplied a fully working example.

Isn't it annoying that you were so close.
ByRef lpEnvironment As Object ByVal lpEnvironment as IntPtr

Instead of declaring Aliases just use the Auto keyword and let the app
decide which to use:
Private Declare Function CreateProcess Lib "kernel32" Alias

"CreateProcessA" (...
Private Declare Auto Function CreateProcess lib "kernel32" (....

--
Mick Doherty
http://dotnetrix.co.uk
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.701 / Virus Database: 458 - Release Date: 07/06/2004
Jul 21 '05 #18

P: n/a
Hi Charles,

In the the language group was a message with the subject
.....(Only experts need apply ;-)

Nobody answered except Herfried with the message that he had placed an
answer in the upgrade group.

I never give an answer using an Api because that is for me the same as
someone helping who is asking where is the screenmemoryinterface from Dos in
windows located.

The answers from Paul Schenk where until that he aswered yesterday Mick
without any reason why he needed it.

Most anoying is that his answers are showing a lack of knowlegde while he is
throwing so much mud that helping him is absolute something I do not like to
do. (Although I did however that had to do with the answer from George,
however with VBNet classes of course and not a direct message).

Paul Clement came with a very good answer, what did mean for me, to look for
a better sollution.

And then the mud throwing reached his goal, you came with that complete Api
equivalent from the process class. That was why I did give this message to
you.

Maybe it is this one the same one who has flamed Scorpion that long time, he
is using different nicks.

Cor
Jul 21 '05 #19

P: n/a
Hi Cor

Yes, I saw the ... only experts ... tag and thought I might elevate myself,
just for a while ;-). Also, as I have spent so much time with interop on the
WebBrowser control, it seemed that I it could be of use here as well.

Anyway, I get so much help here myself that it is only right to chip in when
I can.

Charles
"Cor Ligthert" <no**********@planet.nl> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi Charles,

In the the language group was a message with the subject
....(Only experts need apply ;-)

Nobody answered except Herfried with the message that he had placed an
answer in the upgrade group.

I never give an answer using an Api because that is for me the same as
someone helping who is asking where is the screenmemoryinterface from Dos in windows located.

The answers from Paul Schenk where until that he aswered yesterday Mick
without any reason why he needed it.

Most anoying is that his answers are showing a lack of knowlegde while he is throwing so much mud that helping him is absolute something I do not like to do. (Although I did however that had to do with the answer from George,
however with VBNet classes of course and not a direct message).

Paul Clement came with a very good answer, what did mean for me, to look for a better sollution.

And then the mud throwing reached his goal, you came with that complete Api equivalent from the process class. That was why I did give this message to
you.

Maybe it is this one the same one who has flamed Scorpion that long time, he is using different nicks.

Cor

Jul 21 '05 #20

P: n/a
On Mon, 21 Jun 2004 14:25:01 -0700, ByteSize wrote:

Many thanks. I have seen similar and just oh so wish MS would provide a similar example for vb.net


The library I was referring to is written in C# but you can compile it into
a .dll and then just reference it and call it from VB.Net, so there's no
need to convert it. Let me know if you want it.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Jul 21 '05 #21

P: n/a
On Mon, 21 Jun 2004 14:21:01 -0700, "ByteSize" <By******@discussions.microsoft.com> wrote:

Dear Paul,

I could give you the very long story as to why I need to start interactive apps from a local system service - but lets just say I do, because I do - don't forget that it is a VERY LARGE WORLD OUT THERE, and problems DO COME in varieties. This is my problem for real. Now, what was that you said about a possible solution to the problem as posed ?

Many thaks,
Paul.

Actually my implication was to "find another solution". ;-)

My concern would be that at some point in the future this capability might be inhibited by .NET or
the OS for security reasons.
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Jul 21 '05 #22

P: n/a
Paul,
Have you looked at Adam Nathan's book ".NET and COM - The Complete
Interoperability Guide" from SAMS Press?

Adam has a chapter or two on calling API functions, both from C# & VB.NET,
plus he includes C# declarations for Win32 functions in GDI32.DLL,
KERNEL32.DLL, OLE32.DLL, SHELL32.DLL and USER32.DLL.

Hope this helps
Jay

"ByteSize" <By******@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com...
Dear All,

Please, this is not meant to be offensive - but it is a challenge !!!

I have posted on over a dozen so called 'vb.net' expert / blog sites - in the vain hope of finding a complete, accurate and ACTUALLY FUNCTIONING
snippet to demonsrate a successful api call to CreateProcess() using VB.NET.
So far NO ONE has taken up the challenge - not even MSDN or MS personnel. I have code that works in vb6, I have dilligently tried to convert to vb.net
/ AND look at the multitude of innacurate / incomplete / unsuccessful
snippets of vb / c# / c++ in the hope of finding why my efforts in .Net
fail - but sadly to no avail.
As far as I can tell, MS has removed the ability for a vb-er to use CreateProcess in basic now :( Please, PLEASE prove me wrong, and point me
in the direction of light and happiness.
I am happy to go into detail if anyone is up for the challenge.....

thanks and regards in advance,
paul.

Jul 21 '05 #23

This discussion thread is closed

Replies have been disabled for this discussion.