no-possible-to-close-window

Blitz3D Forums/Blitz3D Programming/no-possible-to-close-window

splinux(Posted 2005) [#1]
Could anyone help me to set privileges to a window, so that the user wont close it(not with task menager, not with other ways,...)?


WolRon(Posted 2005) [#2]
Are you writing a virus?


splinux(Posted 2005) [#3]
No, but if the user will close the apps, windows will probably crash: the program i'm making will help the user using windows, so, if he/she will close the apps some applications of windows could not work very well.


WolRon(Posted 2005) [#4]
I don't think Blitz is your language of choice. You should try C++.


splinux(Posted 2005) [#5]
Why?
With dll Blitz can do anything.


Difference(Posted 2005) [#6]
You are so right. www.melog.ch/dl/blitzclose.zip will do it for you :)


splinux(Posted 2005) [#7]
Good program, but if you use task menager it doesn't work.


Picklesworth(Posted 2005) [#8]
You could have two programs going, and if the other one is closed the one that still exists replaces it. If you feel like doing that, you maybe able to do what you want under Blitz...

From User32.decls (my favourite userlib):
api_IsWindow% (hwnd%) : "IsWindow"


splinux(Posted 2005) [#9]
How does "api_iswindow(hwnd)" works?
Return 1 if the window app(specified with hwnd) is active?


Picklesworth(Posted 2005) [#10]
Yup.
Um... Getting the window handle is the tricky part, but there's lots of ways to do it.


splinux(Posted 2005) [#11]
Yes, but in wich way can i use that command?


Difference(Posted 2005) [#12]
There is a very simple solution:
Recreate the window if it is closed.


splinux(Posted 2005) [#13]
In wich way?


Difference(Posted 2005) [#14]
Sorry, I was thinking Blitz+
It would not help the task manager situation anyway.


splinux(Posted 2005) [#15]
I need help.


Difference(Posted 2005) [#16]
Mr. Picklesworths suggestion is good. Wont help much if somebody closes the monitoring program though...:)


sswift(Posted 2005) [#17]
You could have the program check to see if another copy is already running, and if not, run a second copy. Also so that the programs won't argue over who should be doing the work, pass a command line parameter that says "I was copened by another copy of this program", and set a boolean variable of the same name to true. Then if that boolean variable is set, have that copy of the program do nothing but check to see if another copy of the program needs to be loaded. If another copy does need to be loaded, load it with that same command line parameter, and set your own boolean variable to false, so you know to start doing the main load of work in place of the copy the user just shut down that you had to replace.


Picklesworth(Posted 2005) [#18]
Here is what I was thinking:
Main program doing the work scans every loop for the little program. If the little program is not there, then the main program executes it again (passing it its own window handle as a command line too)
The little program does the same thing, except the other way around - also passing the main program its handle via the command line.

Um... Getting the command lines on the first run is a bit more tricky... This is the method I use:
Main program executes child program, passing it its command line.
Child program sets its window as a child window of the main program's.
Main program then uses api_GetWindow hWnd,5 (5 is the GW_CHILD flag, meaning that it is getting its child window. hWnd is the main program's window handle)
Then you're set to do whatever.

It's not the greatest solution, since a person could still kill the program if they did it really fast... and the process of whatever it was doing would need to be interrupted... but it may work.


splinux(Posted 2005) [#19]
Yes, but some code?