Skip to main content

[archive] command line

  • March 20, 2003
  • 4 replies
  • 0 views

Dominique Sacre
Forum|alt.badge.img+2

[Migrated content. Thread originally posted on 19 March 2003]

I want to now witch command line start the application like
wrun32.exe -wd -C c:\\lcm\\\\CBLCONFI utmenu

I am searching a way to have -wd -C c:\\lcm\\cblcondi utmenu

4 replies

Dominique Sacre
Forum|alt.badge.img+2

[Migrated content. Thread originally posted on 19 March 2003]

I want to now witch command line start the application like
wrun32.exe -wd -C c:\\lcm\\\\CBLCONFI utmenu

I am searching a way to have -wd -C c:\\lcm\\cblcondi utmenu
Dear Micr4517,

it is sometimes hard to figure what your question is, could you please try to use more words, possibly examples to illustrate what you are after?

Dominique Sacre
Forum|alt.badge.img+2

[Migrated content. Thread originally posted on 19 March 2003]

I want to now witch command line start the application like
wrun32.exe -wd -C c:\\lcm\\\\CBLCONFI utmenu

I am searching a way to have -wd -C c:\\lcm\\cblcondi utmenu
I try accept ws-command from command-line this return the command line after the program what i am searching is command line from the runtime.

Dominique Sacre
Forum|alt.badge.img+2

[Migrated content. Thread originally posted on 19 March 2003]

I want to now witch command line start the application like
wrun32.exe -wd -C c:\\lcm\\\\CBLCONFI utmenu

I am searching a way to have -wd -C c:\\lcm\\cblcondi utmenu
To get the absolute command line, you will have to use the Windows API. The function you are seeking is GetCommandLine in kernel32.dll.

This one is a little bit tricky to use, as it makes use of dynamic memory. Fortunately, I have a demo program for this:

IDENTIFICATION DIVISION.
PROGRAM-ID. GetCmdLine.
DATE-WRITTEN. 2003/01/24
REMARKS.
*This program illustrates two issues. First of all it shows how to
*specificly access the entire commandline as it was provided when your
*application were started, including the runtime name.
*Aside of that, it also provides an example of how to copy a null
*terminated ANSI string in which the length by characters are unknown
*to a cobol pic x variable.
* Copyright (c) 1996-2003 by Acucorp, Inc. Users of ACUCOBOL
* may freely modify and redistribute this program.

WORKING-STORAGE SECTION.
77 lpString PIC 9(9) COMP-5.
77 SingleChar PIC X.
77 StringBuffer PIC X(1024).
77 StrCounter PIC 9(04).

PROCEDURE DIVISION.
MAIN-LOGIC.
*We're calling the API, make sure we use the correct calling
*convention
SET ENVIRONMENT "DLL-CONVENTION" TO "1".
*The function we are about to use, are located in kernel32.dll
CALL "KERNEL32.DLL".
*Call the function to get the command line, note the case sensitivity
*and also the 'A', indicating that we are calling the ANSI version of
*the function. The function has no parameters, thus no USING, but it
*returns the value we want, thus the use of GIVING.
CALL "GetCommandLineA" GIVING lpString.

INITIALIZE SingleChar
StringBuffer.
MOVE 1 TO StrCounter.
*NULL terminated strings use character code 0 to indicate end of
*string, let us perform until we reach that character. However,
*as we haven't yet got the first character, we use the term
*WITH TEST AFTER.
PERFORM WITH TEST AFTER UNTIL SingleChar = LOW-VALUE
*Copy the character located at the memory address that lpString
*is pointing at to our variable SingleChar.
CALL "C$MEMCPY" USING
BY REFERENCE SingleChar | Target address
BY VALUE lpString | Source address
BY VALUE 1 | Copy 1 byte
END-CALL
ADD 1 TO lpString | Increment to next char
*If we are not at the end of the string, add the character to our
*buffer.
IF SingleChar NOT = LOW-VALUES
STRING SingleChar DELIMITED BY SIZE
INTO StringBuffer WITH
POINTER StrCounter
END-STRING
END-IF
END-PERFORM.
*We do this INSPECT only because it helps keeping the message dialog
*small. If we don't the dialog will be huge as this is a pic x(1024)
INSPECT StringBuffer REPLACING TRAILING
SPACES BY LOW-VALUES.
DISPLAY MESSAGE BOX
StringBuffer
TITLE "GetCommandLine Example".
CANCEL "KERNEL32.DLL".
GOBACK.

Dominique Sacre
Forum|alt.badge.img+2

[Migrated content. Thread originally posted on 19 March 2003]

I want to now witch command line start the application like
wrun32.exe -wd -C c:\\lcm\\\\CBLCONFI utmenu

I am searching a way to have -wd -C c:\\lcm\\cblcondi utmenu
It is exactly what i was searching for!