Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trouble when using Win32
Message
De
19/01/1999 11:54:49
Fausto Garcia
Independent Developer
Lima, Pérou
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Titre:
Trouble when using Win32
Divers
Thread ID:
00177640
Message ID:
00177640
Vues:
68
We've got the following example sequence of 6 steps which are supposed to launch a "child process". It's coded using VB, but we do work with Visual FoxPro, so we need to replicate the code. We're having trouble with structure difinitions, because we've not found a way to pass the structure parameters (We tried by defining the structure as a STRING with no results).

Here are the steps of the example:


1. Create a new project in Visual Basic. Form1 is created by default.

2. Add a Command Button control to Form1. Command1 is created by default.

3. Add the following code to the Click event for Command1:
Private Sub Command1_Click()
Dim AppToLaunch As String
AppToLaunch = "c:\windows\notepad.exe"
Call ExecuteAndWait(AppToLaunch)
End Sub

4. Create a new subroutine called ExecuteAndWait. Add the following code to this subroutine:
Public Sub ExecuteAndWait(cmdline$)
Dim NameOfProc As PROCESS_INFORMATION
Dim NameStart As STARTUPINFO
Dim X As Long

NameStart.cb = Len(NameStart)
X = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS,
0&, 0&, NameStart, NameOfProc)
X = WaitForSingleObject(NameOfProc.hProcess, INFINITE)
X = CloseHandle(NameOfProc.hProcess)
End Sub

5. From the Visual Basic Insert menu, select Module to add a new module to your project. Module1.Bas is created by default.

6. Add the following code to Module1.Bas (note that each Declare statement must be typed as a single line of code):
Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
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 Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Global Const NORMAL_PRIORITY_CLASS = &H20&
Global Const INFINITE = -1&
Declare Function CloseHandle Lib "kernel32" (hObject As Long) As Boolean
Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long,
ByVal dwMilliseconds As Long) As Long
Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long,
ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal
lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal
dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal
lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO,
lpProcessInformation As PROCESS_INFORMATION) As Long


Thanks for helping.
Solo se que nada se

Fausto J. Garcia Pino - MCSD.NET
.NET, Oracle, Tronador & Fondismo!
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform