View Single Post
  #29  
Old September 23rd 18, 04:22 PM posted to alt.msdos.batch,alt.windows7.general
pyotr filipivich
external usenet poster
 
Posts: 752
Default how to get the title into task manger 'window'?

Herbert Kleebauer on Sun, 23 Sep 2018 09:04:29 +0200
typed in alt.windows7.general the following:
On 23.09.2018 03:07, pyotr filipivich wrote:

I already posted the few lines of source code. Here the
listing from the assembler which explains the meaning
of every byte in the 1024 byte exe:


Wow.

One more reason I don't like programming at the assembler level.
B-)



What's wrong with this source code?


I was talking about the assembler listing. Because I don't read
assembler, "TLDR".

It calls "GetCommandLine"
to get a pointer to the command line, then skips the program
name to get the pointer to the new title string given on
the command line. Then it gets the handle to the console
window (GetConsoleWindow), sets the new title (SetWindowTextA)
and terminates the program (ExitProcess). Anything else you see
in the list file is normally generated by the assembler and linker
(but if I want a small exe file to include it in a batch program,
I do it by hand). You can also write it as a two line C program, but
don't expect to get a 1 kByte binary.


Now, how do I get a Shortcut (Filename.lnk) to do this? How do I
get a batchfile to change the title from "Administrator: Filename" to
"Filename"? I see this code setting the title to "ZZ Agent", but when
I add it to ZZ Agent.bat - I don't see any change.

Yes, I know I am whining. But it is not intuitively obvious, to
me, and if I had a C compiler, there are a number of things I could
"do for myself". (I had a small C program which stripped out
non-printing characters, just great for massaging and clearing up
downloaded text files.


winmain::

jsr.l (GetCommandLine)
; skip program name
eor.l r1,r1 ; not within "" flag
dec.l r0
_20: inc.l r0
cmp.b #0,(r0)
beq.b _10
cmp.b #'"',(r0)
bne.b _30
not.l r1
_30: or.l r1,r1
bne.b _20
cmp.b #' ',(r0)
bne.b _20
inc.l r0

_10: move.l r0,-(sp)
jsr.l (GetConsoleWindow)
move.l r0,-(sp)
jsr.l (SetWindowTextA)
moveq.l #0,-(sp)
jsr.l (ExitProcess) ; exit program

--
pyotr filipivich
Next month's Panel: Graft - Boon or blessing?
Ads