Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
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:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old September 5th, 2003, 04: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, 07: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, 07: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: 5
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, 06: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!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway