Uncloseable Window

Posted on 2002-05-07
Medium Priority
Last Modified: 2012-06-27
Hi there, basically, I would like some code that will stop my app from closing. On RM networks, it closes any applications that are not meant to be running when you log off the network and i want my program to keep running.

thanks for your help, Jack.
Question by:Portal111
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6994485
Please maintain your open questions:

Hiding Objects Date: 07/13/2001 10:20AM PST
Getting Process Icons Date: 01/07/2002 11:30PM PST
Using The Tint Command / If There is One Date: 12/05/2001 10:18AM PST

LVL 22

Expert Comment

ID: 6995461
Here's a snippet that references a largely undocumented API call that let's the caller survive a logoff.  This is one of the tings I do to simulate services on 95.

Yes, I know it's not not VB, but the switch to VB should go pretty easy.

if (Kernel32==NULL)
   PostMsg("Unable to get KERNEL32.DLL");
   return 0;

if (RegisterServiceProcess==NULL)
   PostMsg("RegisterServiceProcess entry point not found in KERNEL32");
   return 0;
if (1!=RegisterServiceProcess(GetCurrentProcessId(),1))
   PostMsg("Unable to register service");
   return 0;
LVL 22

Accepted Solution

cookre earned 800 total points
ID: 6995465
Here's one link of many to VB samples:

Do a search on 'registerserviceprocess 95 vb' to see all of them.  

Note that not only does the process survive a logoff, it doesn't show up in the ctrl-alt-delete task list either.

Expert Comment

ID: 6996297
In your form query unload event

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
cancel = true
End Sub

Author Comment

ID: 7610047
Nice1, thanks! sorry for the really really slow response. Jack

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

624 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