Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old September 5th, 2003, 05:59 AM
King_bob King_bob is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 4 King_bob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
API CreateProcess

I am using the Api Function CreateProcess but I have no Idea what to do with the "lpEnvironment As Any" Value

the simple version of this code is as follows:

Option Explicit

Private Const NORMAL_PRIORITY_CLASS As Long = &H20


Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type

Private Type STARTUPINFO
cb As Long
lpReserved As Long
lpDesktop As Long
lpTitle As Long
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type

Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type

Private Declare Function CreateProcess Lib "kernel32.dll" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long

Sub Main()
Dim spud As Long
Dim SNfo As STARTUPINFO
Dim PNfo As PROCESS_INFORMATION
Dim SAtt As SECURITY_ATTRIBUTES

With SNfo
.cb = 1753357
' .cbReserved2 = Null
' .dwFillAttribute
' .dwFlags
.dwX = 100
' .dwXCountChars
.dwXSize = 100
.dwY = 100
' .dwYCountChars
.dwYSize = 100
' .hStdError
' .hStdInput
' .hStdOutput
' .lpDesktop = Null
' .lpReserved = Null
' .lpReserved2 = Null
.lpTitle = 1
.wShowWindow = 1
End With

With SAtt
.bInheritHandle = 1753357
.lpSecurityDescriptor = 1
.nLength = False
End With

spud = CreateProcess(vbNullString, "c:\one", SAtt, SAtt, False, NORMAL_PRIORITY_CLASS, 0, vbNullString, SNfo, PNfo)

Debug.Print spud
Debug.Print PNfo.hProcess
Debug.Print PNfo.dwProcessId
Debug.Print PNfo.dwThreadId
Debug.Print PNfo.hThread

End Sub





-----------------------------------------------------
in the line spud = CreateProcess(vbNullString, "c:\one", SAtt, SAtt, False, NORMAL_PRIORITY_CLASS, 0, vbNullString, SNfo, PNfo)

I set the value to 0, I have also tried Null (the default in c++) but that does not work eather....


HELP!?!

Reply With Quote
  #2  
Old September 8th, 2003, 08:39 PM
Dan Griffing Dan Griffing is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Montana
Posts: 1 Dan Griffing User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Using CreateProcess to Restart App

The App I'm working with is connected to vendor hardware through a vendor dll driver that needs restarting at the app level sometimes. How can a VB App restart itself? Can I use CreateProcess(....) followed immediately and lastly by a call to ExitProcess(...)?

Can this technique be used in general for App1 to start App2 and then die?

Reply With Quote
  #3  
Old September 9th, 2003, 08:56 AM
Onslaught Onslaught is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 34 Onslaught User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 44 sec
Reputation Power: 7
Possibly this page can help explain CreateProcess().

As far as your question Dan, I do not believe so. CreateProcess is used to open a process that you want to wait until it has finished before your application gains control again. You would probably want to check out ShellExecute() which there is a link to that in the link listed above.

Reply With Quote
  #4  
Old September 10th, 2003, 07:55 AM
King_bob King_bob is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 4 King_bob User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
THX

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > API CreateProcess


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump





 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek