Solved

program parameter and calling

Posted on 1998-10-20
3
134 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

749 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