News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Hide a window in taskbar...

Started by Dark Schneider, November 14, 2006, 11:29:41 PM

Previous topic - Next topic

Dark Schneider

Another 'hide' topic.
Now I need my program not to show itself in taskbar, its main window is a dialog box called by DialogboxParams.
I don't have any idea yet, please give me a hint.
Thank you.

ecube


     CTEXT MACRO text:VARARG
            LOCAL TxtName
              .data
               TxtName BYTE text,0
              .code
            EXITM <ADDR TxtName>
     ENDM

.code
Hide9x PROC
invoke  GetCurrentProcessId
mov edx,eax
push edx
invoke LoadLibrary,CTEXT("Kernel32")
invoke GetProcAddress,eax,CTEXT("RegisterServiceProcess")
pop edx
push TRUE
push edx
call eax
ret
Hide9x ENDP

HideNt proc
invoke GetCurrentProcessId
mov ecx,eax
RegisterServiceProcess,ecx, RSP_SIMPLE_SERVICE
ret
HideNt endp

also hide your apps main windows name by setting it to nothing

donkey

Since GetCurrentProcessId is resident in Kernel32.dll there is no need to call LoadLibrary, GetModuleHandle will work just fine...

invoke GetModuleHandle, CTEXT("kernel32.dll")

Also, RegisterServiceProcess exists only in Win9x as far as I know so it will not work on NT, 2K, XP or 2K3. The other thing to be wary of when using RegisterServiceProcess is that your application will not terminate when the user selects logoff. You must watch the WM_QUERYENDSESSION and WM_ENDSESSION messages and close the application programatically. To have a program not appear in the taskbar you should be using the ITaskbarList COM interface which is available to all Windows versions.

Donkey

[attachment deleted by admin]
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Relvinian

Another option to hide the window from the task bar, depending on how you want your caption bar to be like, is to use the following:


WS_EX_TOOLWINDOW window extension style.
Creates a tool window, which is a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the task bar or in the window that appears when the user presses ALT+TAB.

Just a plain window style.  ;-)  This will work for any window, doesn't have to be a toolbar!  Just the caption bar and text are smaller and may/may not have system/help/min/max buttons.


Relvinian

ecube

Quote from: donkey on November 15, 2006, 04:06:46 AM
Since GetCurrentProcessId is resident in Kernel32.dll there is no need to call LoadLibrary, GetModuleHandle will work just fine...

invoke GetModuleHandle, CTEXT("kernel32.dll")

Also, RegisterServiceProcess exists only in Win9x as far as I know so it will not work on NT, 2K, XP or 2K3. The other thing to be wary of when using RegisterServiceProcess is that your application will not terminate when the user selects logoff. You must watch the WM_QUERYENDSESSION and WM_ENDSESSION messages and close the application programatically. To have a program not appear in the taskbar you should be using the ITaskbarList COM interface which is available to all Windows versions.

Donkey
I googled,downloaded, tested, and converted, someones elses code all in about a minute, didn't even really pay attention, figure it'd help him get where we wanted though.Also donkey while your string library is nice i'm writing my own aswell, nicely optimized, my mini wsprintf clone was over 2000 times as fast as wsprintf but ofcourse wasn't quite a far comparision since it only supports %s atm. Is on the board. i'm making a complete wsprintf clone but it makes sense to me to have bulky procedures when you only use a certain format most of the time, so will focus on breaking up each one. The replace string i'm writing right this moment is neat, would like your view on it when completed.

Dark Schneider


donkey

Hi E^cube,

Yes, wsprintf is pretty lame but useful. I wrote a partial replacement for it that allows transposition and duplication of parameters, since it uses numbered parameters it was not that difficult. The hard part was making GoAsm do a C call function :) It is lszCatPlus, found in the string library on my site.

lszCatPlus:
Performs a formatted multiple concatentation
This is a C calling convention function, the caller is responsible for the stack
ECX is guaranteed to be preserved for counting loops
Parameters:
buffer = Pointer to a buffer to hold the resulting string
szFmt = Pointer to a format string that controls that concatenation
arg0..arg9 = Pointers to null term. strings or dwords, index of arg matches the format

The buffer must be large enough to hold the entire string.

szFmt has the following format:
where # is the 0 based parameter for that position
ie %[type]0 = arg0, %[type]1 = arg1 etc...
You can repeat parameters ie "%u0 %x1 %x1 %s2"
Or put them out of order "%s2 %u0 %i3 %x1"

Types:
%s# = Inserts a string pointed to by argument
%i# = Converts argument to a signed integer (i must be lower case)
%u# = Converts argument to an unsigned integer (u must be lower case)
%x# = Converts argument to a hex string (x must be lower case)

It is then followed by up to 10 arguments (0-9)
For a % sign use %%
Strings arguments are limited to a maximum of 1023 bytes
Returns the pointer to the buffer


However, I have never tested it against wsprintf but I suspect it won't do very well. I needed it for a project and enhanced it  a bit for the lib but never bothered to do any optimization at all.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable