Solved

program parameter and calling

Posted on 1998-10-20
3
130 Views
Last Modified: 2011-08-18
i have a program that will reside on a "Common PC."  Other PCs can run the program by calling that said program thru the network.  The problem is how do i pass parameters to the called program.  I have looked at the Shell command, but i don't think i can use that command on the calling program since it doesn't have fields that accepts parameter passing.  
0
Comment
Question by:nasia
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
waty earned 50 total points
ID: 1440874
Here is a good function to execute application, you can add parameters :

cCommandLine can contains the executable name and all the parameters. You have to treat the parameters in your application.


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 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

Private Const NORMAL_PRIORITY_CLASS = &H20&

Private 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

Public Function ShellExecute(cCommandLine As String) As Boolean
   ' #VBIDEUtils#************************************************************
   ' * Programmer Name  : Waty Thierry
   ' * Web Site         : www.geocities.com/ResearchTriangle/6311/
   ' * E-Mail           : waty.thierry@usa.net
   ' * Date             : 2/10/98
   ' * Time             : 09:48
   ' * Module Name      : Execute_Module
   ' * Module Filename  : Execute.bas
   ' * Procedure Name   : ShellExecute
   ' * Parameters       :
   ' *                    cCommandLine As String
   ' **********************************************************************
   ' * Comments         :
   ' * Runs a command as the Shell command
   ' * Note: The full path and filename extention
   ' * is required.
   ' * You might want to use Environ$("COMSPEC") & " /c " & command
   ' * if you wish to run it under the command shell (and thus it)
   ' * will search the path etc...
   ' *
   ' * returns false if the shell failed
   ' *
   ' **********************************************************************
   
   Dim NameOfProc    As PROCESS_INFORMATION
   Dim NameStart     As STARTUPINFO
   Dim i             As Long

   NameStart.cb = Len(NameStart)
   i = CreateProcessA(0&, cCommandLine, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, NameStart, NameOfProc)

   If i <> 0 Then
      ShellExecute = True
   Else
      ShellExecute = False
   End If

End Function

0
 

Author Comment

by:nasia
ID: 1440875
which function/procedure goes where.. are all these for the calling program or some will go to the called program.... ????
0
 
LVL 14

Expert Comment

by:waty
ID: 1440876
Add all in a module, and use the following function

 debug.print ShellExecute("C:\yourDir\yourprogram.exe Param1 Param2")
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now