473,385 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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
22 2488
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Gibby Koldenhof | last post by:
Hiya, I'm setting up some code in the spirit of Design Patterns, OOP, etc. All nice and well, it handles pretty much all OO style things and serves my purposes well. There's one last final...
7
by: Muscha | last post by:
My c# application has gone beserk, it consumes 700MB memory griding my machine to a halt. What is the quickest way for me to find out what's happening? Where do all the memory has gone? /m
22
by: ByteSize | last post by:
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,...
23
Niheel
by: Niheel | last post by:
In a word Please Don't OK I admit that was 2 words but nothing in software was ever specified properly. Here are the reasons why you should post in the forum rather than PMing a Community...
21
by: Goofy | last post by:
I see that the code behind is now a partial class. So where is the code associated with the server controls declaration etc ? Is this generated on the fly now, or am I missing something ? --...
9
by: Emin | last post by:
Dear Experts, I have a fairly simple query in which adding a where clause slows things down by at least a factor of 100. The following is the slow version of the query ...
25
by: sidd | last post by:
In the following code: int i = 5; ---it goes to .data segment int j; ---it goes to bss segment int main() { int c; int i = 5; ---stack
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.