Sign in to follow this  
Followers 0
VelvetElvis

AdlibRegister/AdlibUnregister

8 posts in this topic

Is AdlibUnregister automatically called or assumed on appiication exit?

My script uses AdlibRegister to call a routine that determines if the app has run longer than n minutes and kills it if necessary.

Is it necessary to explicitly call AdlibUnregister before terminating the app?

Share this post


Link to post
Share on other sites



I don't understand what you mean. If the process isn't running then how is it supposed to do anything? You mind writing the question another way?

Sorry if I wasn't clear. Let me try again.

I used AdlibRegister at the beginning of my app. The function it points to checks every 60 seconds to see how long the app has been running. If it's been running more than a specified number of minutes, then the function kills the app.

Must I use AdlibUNregister before I exit my application, to unregister this function? Sorry if that isn't clear enough. I'm concerned about invoking some Windows routine that remains active after my scrip terminates, which of course I don't want to do.

Hope that explains it a bit better. ;)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Oh right.

Windows actually cleans up pretty much all the handles and stuff that belongs to a process, so even if AdlibRegister uses some timer or something (hard to say as the source isn't available) Windows would do it for you.

So you can do as you want here. If you're a person that likes things to be tidy then add it. It's just 1 line anyway. If you want to go to bed 5 seconds earlier today, (:)) then skip it!

As a guideline: If you should "clean up" after yourself, it's noted so in the helpfile.

Edit: Or that is my opinion anyway, I have only been here 1 year more that you ;) What has you been doing these 2 years? ;)

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

As you can see in the helpfile

Example

AdlibRegister("MyAdlib")

;...

Exit

Func MyAdlib()

;... execution must be non blocking, avoid ...Wait(), MsgBox(), InputBox() functions

If WinActive("Error") Then

;...

EndIf

EndFunc

No "AdlibUnRegister" ! Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

As you can see in the helpfile

No "AdlibUnRegister" ! Posted Image

Thank you. I guess AdlibUnregister is _only_ required when reassigning Adlib within the same script.

Share this post


Link to post
Share on other sites

Thank you. I guess AdlibUnregister is _only_ required when reassigning Adlib within the same script.

No then you would just AdlibRegister the function again. AdlibUnregister is only for when you want it to stop.

Share this post


Link to post
Share on other sites

Thank you. I guess AdlibUnregister is _only_ required when reassigning Adlib within the same script.

As the help file says, Adlib can register more than one function at a time, reregistering the same function using AdlibRegister would just change the time. So, you don't need to unregister it, unless as Admiral said, you need it to stop being called automatically.

Several Adlib functions can be registered. Re-registering an already existing Adlib function will update it with a new time.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0